summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorChen Jie <chenjie6@huawei.com>2019-03-15 03:44:38 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-03-27 14:14:40 +0900
commit36d52f5bcd573dee4ed5527a1816f39d9d3f05d0 (patch)
tree1560aab03d384d126fc7bc84297d40a2f9ef48d0 /kernel
parent837becb30c3b54268620042158161d82b7d5732f (diff)
futex: Ensure that futex address is aligned in handle_futex_death()
commit 5a07168d8d89b00fe1760120714378175b3ef992 upstream. 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: 0771dfefc9e5 ("[PATCH] lightweight robust futexes: core") Signed-off-by: Chen Jie <chenjie6@huawei.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: <dvhart@infradead.org> Cc: <peterz@infradead.org> Cc: <zengweilin@huawei.com> Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/1552621478-119787-1-git-send-email-chenjie6@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/futex.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/kernel/futex.c b/kernel/futex.c
index c5fca746edc4..5a26d843a015 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -3432,6 +3432,10 @@ int handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi)
{
u32 uval, uninitialized_var(nval), mval;
+ /* Futex address must be 32bit aligned */
+ if ((((unsigned long)uaddr) % sizeof(*uaddr)) != 0)
+ return -1;
+
retry:
if (get_user(uval, uaddr))
return -1;