]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
futex: Fix potential use-after-free in FUTEX_REQUEUE_PI
authorPeter Zijlstra <peterz@infradead.org>
Sat, 4 Mar 2017 09:27:18 +0000 (10:27 +0100)
committerTim Gardner <tim.gardner@canonical.com>
Wed, 22 Mar 2017 14:02:34 +0000 (08:02 -0600)
commit971ad6f57629ba6f3d9fb821fc3b2bdbd911cde5
tree0d79c7479de2a3c0a4d844566025081e320fe12b
parent8aa0d09bf45aff05d4bb5a46375ba78efaac086b
futex: Fix potential use-after-free in FUTEX_REQUEUE_PI

BugLink: http://bugs.launchpad.net/bugs/1675032
commit c236c8e95a3d395b0494e7108f0d41cf36ec107c upstream.

While working on the futex code, I stumbled over this potential
use-after-free scenario. Dmitry triggered it later with syzkaller.

pi_mutex is a pointer into pi_state, which we drop the reference on in
unqueue_me_pi(). So any access to that pointer after that is bad.

Since other sites already do rt_mutex_unlock() with hb->lock held, see
for example futex_lock_pi(), simply move the unlock before
unqueue_me_pi().

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Cc: juri.lelli@arm.com
Cc: bigeasy@linutronix.de
Cc: xlpang@redhat.com
Cc: rostedt@goodmis.org
Cc: mathieu.desnoyers@efficios.com
Cc: jdesfossez@efficios.com
Cc: dvhart@infradead.org
Cc: bristot@redhat.com
Link: http://lkml.kernel.org/r/20170304093558.801744246@infradead.org
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
kernel/futex.c