summaryrefslogtreecommitdiffstats
path: root/kernel/futex/core.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2024-01-29 08:59:23 +0100
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2024-01-29 08:59:23 +0100
commitc8282f7b8523a4d37e5fefa220d93f2be06650e2 (patch)
tree6ec17a2ea545b174dc903f6135f5b6258a1c4e2e /kernel/futex/core.c
parent04447d48afd365a837e23cde631517f166045b9d (diff)
parent41bccc98fb7931d63d03f326a746ac4d429c1dd3 (diff)
downloadlinux-stable-c8282f7b8523a4d37e5fefa220d93f2be06650e2.tar.gz
linux-stable-c8282f7b8523a4d37e5fefa220d93f2be06650e2.tar.bz2
linux-stable-c8282f7b8523a4d37e5fefa220d93f2be06650e2.zip
Merge tag 'v6.8-rc2'
Linux 6.8-rc2 The vb2 fixes from v6.8-rc2 are needed for the work on the new vb2 delete buffers feature. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'kernel/futex/core.c')
-rw-r--r--kernel/futex/core.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/kernel/futex/core.c b/kernel/futex/core.c
index e0e853412c15..1e78ef24321e 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -627,12 +627,21 @@ retry:
}
/*
- * PI futexes can not be requeued and must remove themselves from the
- * hash bucket. The hash bucket lock (i.e. lock_ptr) is held.
+ * PI futexes can not be requeued and must remove themselves from the hash
+ * bucket. The hash bucket lock (i.e. lock_ptr) is held.
*/
void futex_unqueue_pi(struct futex_q *q)
{
- __futex_unqueue(q);
+ /*
+ * If the lock was not acquired (due to timeout or signal) then the
+ * rt_waiter is removed before futex_q is. If this is observed by
+ * an unlocker after dropping the rtmutex wait lock and before
+ * acquiring the hash bucket lock, then the unlocker dequeues the
+ * futex_q from the hash bucket list to guarantee consistent state
+ * vs. userspace. Therefore the dequeue here must be conditional.
+ */
+ if (!plist_node_empty(&q->list))
+ __futex_unqueue(q);
BUG_ON(!q->pi_state);
put_pi_state(q->pi_state);