diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2015-02-17 16:18:05 +0100 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2016-06-24 16:32:53 -0400 |
commit | f3472abebb0a9a5f836d7d5b47db0095774ad5fb (patch) | |
tree | a399276d23d0159f624236f74b71d1b2731d9b34 | |
parent | 58db8c8e2bf750fe3a9c6aefaaade72d5fa61096 (diff) | |
download | linux-rt-f3472abebb0a9a5f836d7d5b47db0095774ad5fb.tar.gz |
rt-mutex: avoid a NULL pointer dereference on deadlock
With task_blocks_on_rt_mutex() returning early -EDEADLK we never add the
waiter to the waitqueue. Later, we try to remove it via remove_waiter()
and go boom in rt_mutex_top_waiter() because rb_entry() gives a NULL
pointer.
Tested on v3.18-RT where rtmutex is used for regular mutex and I tried
to get one twice in a row.
Not sure when this started but I guess 397335f00 ("rtmutex: Fix deadlock
detector for real") or commit 3d5c9340 ("rtmutex: Handle deadlock
detection smarter").
Cc: stable-rt@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | kernel/rtmutex.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c index 1889aedfad86..4cc273b85beb 100644 --- a/kernel/rtmutex.c +++ b/kernel/rtmutex.c @@ -1487,7 +1487,8 @@ rt_mutex_slowlock(struct rt_mutex *lock, int state, set_current_state(TASK_RUNNING); if (unlikely(ret)) { - remove_waiter(lock, &waiter); + if (rt_mutex_has_waiters(lock)) + remove_waiter(lock, &waiter); rt_mutex_handle_deadlock(ret, chwalk, &waiter); } |