Commit d8ad075e authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky

[S390] don't call handle_mm_fault() if in an atomic context.

There are several places in the futex code where a spin_lock is held
and still uaccesses happen. Deadlocks are avoided by increasing the
preempt count. The pagefault handler will then not take any locks
but will immediately search the fixup tables.
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent de338a37
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
*/ */
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/hardirq.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/futex.h> #include <asm/futex.h>
...@@ -18,6 +19,8 @@ static inline int __handle_fault(struct mm_struct *mm, unsigned long address, ...@@ -18,6 +19,8 @@ static inline int __handle_fault(struct mm_struct *mm, unsigned long address,
struct vm_area_struct *vma; struct vm_area_struct *vma;
int ret = -EFAULT; int ret = -EFAULT;
if (in_atomic())
return ret;
down_read(&mm->mmap_sem); down_read(&mm->mmap_sem);
vma = find_vma(mm, address); vma = find_vma(mm, address);
if (unlikely(!vma)) if (unlikely(!vma))
......
...@@ -258,8 +258,6 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old) ...@@ -258,8 +258,6 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old)
{ {
int oldval = 0, newval, ret; int oldval = 0, newval, ret;
pagefault_disable();
switch (op) { switch (op) {
case FUTEX_OP_SET: case FUTEX_OP_SET:
__futex_atomic_op("lr %2,%5\n", __futex_atomic_op("lr %2,%5\n",
...@@ -284,7 +282,6 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old) ...@@ -284,7 +282,6 @@ int futex_atomic_op(int op, int __user *uaddr, int oparg, int *old)
default: default:
ret = -ENOSYS; ret = -ENOSYS;
} }
pagefault_enable();
*old = oldval; *old = oldval;
return ret; return ret;
} }
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/futex.h> #include <linux/futex.h>
#include <linux/uaccess.h>
#include <asm/errno.h> #include <asm/errno.h>
#include <asm/uaccess.h>
static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
{ {
...@@ -21,7 +21,9 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) ...@@ -21,7 +21,9 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
return -EFAULT; return -EFAULT;
pagefault_disable();
ret = uaccess.futex_atomic_op(op, uaddr, oparg, &oldval); ret = uaccess.futex_atomic_op(op, uaddr, oparg, &oldval);
pagefault_enable();
if (!ret) { if (!ret) {
switch (cmp) { switch (cmp) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment