Skip to content

Commit

Permalink
[PARISC] futex: special case cmpxchg NULL in kernel space
Browse files Browse the repository at this point in the history
Commit a0c1e90 added code to futex.c
to detect whether futex_atomic_cmpxchg_inatomic was implemented at run
time:

+       curval = cmpxchg_futex_value_locked(NULL, 0, 0);
+       if (curval == -EFAULT)
+               futex_cmpxchg_enabled = 1;

This is bogus on parisc, since page zero in kernel virtual space is the
gateway page for syscall entry, and should not be read from the kernel.
(That, and we really don't like the kernel faulting on its own address
 space...)

Signed-off-by: Kyle McMartin <kyle@mcmartin.ca>
  • Loading branch information
Kyle McMartin committed Mar 16, 2008
1 parent dc39455 commit c20a84c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions include/asm-parisc/futex.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
int err = 0;
int uval;

/* futex.c wants to do a cmpxchg_inatomic on kernel NULL, which is
* our gateway page, and causes no end of trouble...
*/
if (segment_eq(KERNEL_DS, get_fs()) && !uaddr)
return -EFAULT;

if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int)))
return -EFAULT;

Expand All @@ -67,5 +73,5 @@ futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval)
return uval;
}

#endif
#endif
#endif /*__KERNEL__*/
#endif /*_ASM_PARISC_FUTEX_H*/

0 comments on commit c20a84c

Please sign in to comment.