[PATCH 11/14] futex: Verify exit_mutex ownership in futex_exit_recursive()
From: Bart Van Assche
Date: Mon Nov 02 2026 - 17:50:30 EST
futex_exit_recursive() unlocks tsk->futex.exit_mutex if the futex state
is FUTEX_STATE_EXITING. It uses __assume_ctx_lock() to inform Clang's
context analysis that this mutex is held. However, __assume_ctx_lock()
does not verify that assumption. Convert the __assume_ctx_lock() call
into a lockdep_assume_ctx_held() call such that the lock ownership
assumption is also verified at runtime by lockdep.
Cc: Marco Elver <elver@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>
---
kernel/futex/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index a240638f69e5..4e5aa0160dd2 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -1503,7 +1503,7 @@ void futex_exit_recursive(struct task_struct *tsk)
{
/* If the state is FUTEX_STATE_EXITING then futex_exit_mutex is held */
if (tsk->futex.state == FUTEX_STATE_EXITING) {
- __assume_ctx_lock(&tsk->futex.exit_mutex);
+ lockdep_assume_ctx_held(&tsk->futex.exit_mutex);
mutex_unlock(&tsk->futex.exit_mutex);
}
tsk->futex.state = FUTEX_STATE_DEAD;