Skip to content

Commit 5a07168

Browse files
Chen JieKAGA-KOKO
authored andcommitted
futex: Ensure that futex address is aligned in handle_futex_death()
The futex code requires that the user space addresses of futexes are 32bit aligned. sys_futex() checks this in futex_get_keys() but the robust list code has no alignment check in place. As a consequence the kernel crashes on architectures with strict alignment requirements in handle_futex_death() when trying to cmpxchg() on an unaligned futex address which was retrieved from the robust list. [ tglx: Rewrote changelog, proper sizeof() based alignement check and add comment ] Fixes: 0771dfe ("[PATCH] lightweight robust futexes: core") Signed-off-by: Chen Jie <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: <[email protected]> Cc: <[email protected]> Cc: <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent 82efcab commit 5a07168

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

kernel/futex.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3436,6 +3436,10 @@ static int handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int p
34363436
{
34373437
u32 uval, uninitialized_var(nval), mval;
34383438

3439+
/* Futex address must be 32bit aligned */
3440+
if ((((unsigned long)uaddr) % sizeof(*uaddr)) != 0)
3441+
return -1;
3442+
34393443
retry:
34403444
if (get_user(uval, uaddr))
34413445
return -1;

0 commit comments

Comments
 (0)