Skip to content

Commit b857174

Browse files
Sebastian Andrzej SiewiorKAGA-KOKO
authored andcommitted
locking/ww_mutex: Initialize waiter.ww_ctx properly
The consolidation of the debug code for mutex waiter intialization sets waiter::ww_ctx to a poison value unconditionally. For regular mutexes this is intended to catch the case where waiter_ww_ctx is dereferenced accidentally. For ww_mutex the poison value has to be overwritten either with a context pointer or NULL for ww_mutexes without context. The rework broke this as it made the store conditional on the context pointer instead of the argument which signals whether ww_mutex code should be compiled in or optiized out. As a result waiter::ww_ctx ends up with the poison pointer for contextless ww_mutexes which causes a later dereference of the poison pointer because it is != NULL. Use the build argument instead so for ww_mutex the poison value is always overwritten. Fixes: c0afb0f ("locking/ww_mutex: Gather mutex_waiter initialization") Reported-by: Guenter Roeck <[email protected]> Suggested-by: Peter Zijlstra <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9ae6ab2 commit b857174

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/locking/mutex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ __mutex_lock_common(struct mutex *lock, unsigned int state, unsigned int subclas
618618

619619
debug_mutex_lock_common(lock, &waiter);
620620
waiter.task = current;
621-
if (ww_ctx)
621+
if (use_ww_ctx)
622622
waiter.ww_ctx = ww_ctx;
623623

624624
lock_contended(&lock->dep_map, ip);

0 commit comments

Comments
 (0)