linux/kernel/locking
John Stultz 82f9cc0949 locking: rtmutex: Fix wake_q logic in task_blocks_on_rt_mutex
Anders had bisected a crash using PREEMPT_RT with linux-next and
isolated it down to commit 894d1b3db4 ("locking/mutex: Remove
wakeups from under mutex::wait_lock"), where it seemed the
wake_q structure was somehow getting corrupted causing a null
pointer traversal.

I was able to easily repoduce this with PREEMPT_RT and managed
to isolate down that through various call stacks we were
actually calling wake_up_q() twice on the same wake_q.

I found that in the problematic commit, I had added the
wake_up_q() call in task_blocks_on_rt_mutex() around
__ww_mutex_add_waiter(), following a similar pattern in
__mutex_lock_common().

However, its just wrong. We haven't dropped the lock->wait_lock,
so its contrary to the point of the original patch. And it
didn't match the __mutex_lock_common() logic of re-initializing
the wake_q after calling it midway in the stack.

Looking at it now, the wake_up_q() call is incorrect and should
just be removed. So drop the erronious logic I had added.

Fixes: 894d1b3db4 ("locking/mutex: Remove wakeups from under mutex::wait_lock")
Closes: https://lore.kernel.org/lkml/6afb936f-17c7-43fa-90e0-b9e780866097@app.fastmail.com/
Reported-by: Anders Roxell <anders.roxell@linaro.org>
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: John Stultz <jstultz@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Juri Lelli <juri.lelli@redhat.com>
Tested-by: Anders Roxell <anders.roxell@linaro.org>
Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
Link: https://lore.kernel.org/r/20241114190051.552665-1-jstultz@google.com
2024-12-02 12:01:29 +01:00
..
irqflag-debug.c lockdep: Noinstr annotate warn_bogus_irq_restore() 2021-02-10 14:44:39 +01:00
lock_events_list.h locking/rwsem: Remove reader optimistic spinning 2020-12-09 17:08:48 +01:00
lock_events.c locking/debug: Fix debugfs API return value checks to use IS_ERR() 2023-10-03 10:11:25 +02:00
lock_events.h locking/qspinlock: Always evaluate lockevent* non-event parameter once 2024-03-21 20:45:17 +01:00
lockdep_internals.h locking/lockdep: Iterate lock_classes directly when reading lockdep files 2022-02-16 15:57:58 +01:00
lockdep_proc.c locking/lockdep: Simplify character output in seq_line() 2024-08-06 10:46:43 -07:00
lockdep_states.h locking/lockdep: Rework FS_RECLAIM annotation 2017-08-10 12:29:03 +02:00
lockdep.c lockdep: Use info level for lockdep initial info messages 2024-10-17 21:21:16 -07:00
locktorture.c locktorture: Add MODULE_DESCRIPTION() 2024-05-30 15:31:45 -07:00
Makefile lockdep: allow instrumenting lockdep.c with KMSAN 2022-12-11 18:12:11 -08:00
mcs_spinlock.h locking: Fix typos in comments 2021-03-22 02:45:52 +01:00
mutex-debug.c locking/mutex: Introduce devm_mutex_init() 2024-04-11 17:34:41 +01:00
mutex.c locking/mutex: Expose __mutex_owner() 2024-10-14 12:52:41 +02:00
mutex.h locking/mutex: Expose __mutex_owner() 2024-10-14 12:52:41 +02:00
osq_lock.c locking/osq_lock: Use atomic_try_cmpxchg_release() in osq_unlock() 2024-10-25 10:01:50 +02:00
percpu-rwsem.c locking/percpu-rwsem: Trigger contention tracepoints only if contended 2024-02-28 13:10:29 +01:00
qrwlock.c locking: Add __lockfunc to slow path functions 2022-08-19 19:47:51 +02:00
qspinlock_paravirt.h locking/pvqspinlock: Convert fields of 'enum vcpu_state' to uppercase 2024-10-17 21:21:16 -07:00
qspinlock_stat.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
qspinlock.c x86/xen: remove deprecated xen_nopvspin boot parameter 2024-07-11 16:33:51 +02:00
rtmutex_api.c Scheduler changes for v6.13: 2024-11-19 14:16:06 -08:00
rtmutex_common.h locking/mutex: Remove wakeups from under mutex::wait_lock 2024-10-14 12:52:40 +02:00
rtmutex.c locking: rtmutex: Fix wake_q logic in task_blocks_on_rt_mutex 2024-12-02 12:01:29 +01:00
rwbase_rt.c locking/mutex: Remove wakeups from under mutex::wait_lock 2024-10-14 12:52:40 +02:00
rwsem.c locking/mutex: Remove wakeups from under mutex::wait_lock 2024-10-14 12:52:40 +02:00
semaphore.c locking: Add __sched to semaphore functions 2022-09-15 16:14:03 +02:00
spinlock_debug.c sched.h: move pid helpers to pid.h 2023-12-20 19:26:31 -05:00
spinlock_rt.c Scheduler changes for v6.13: 2024-11-19 14:16:06 -08:00
spinlock.c locking/spinlocks: Make __raw_* lock ops static 2024-10-07 09:28:35 +02:00
test-ww_mutex.c locking/ww_mutex: Adjust to lockdep nest_lock requirements 2024-10-09 15:08:25 +02:00
ww_mutex.h locking/mutex: Make mutex::wait_lock irq safe 2024-10-14 12:52:40 +02:00
ww_rt_mutex.c locking/rtmutex: Avoid unconditional slowpath for DEBUG_RT_MUTEXES 2023-09-20 09:31:11 +02:00