Forwarded: [PATCH] futex: Fix use-after-free in futex_unqueue() on private hash teardown

From: syzbot

Date: Tue Feb 10 2026 - 22:38:22 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx, syzkaller-bugs@xxxxxxxxxxxxxxxx.

***

Subject: [PATCH] futex: Fix use-after-free in futex_unqueue() on private hash teardown
Author: suunj1331@xxxxxxxxx

futex_hash_free() frees the private hash table with kvfree() in the
__mmput() path. However, a task sharing the same mm via CLONE_VM may
still be in futex_unqueue() which relies on RCU read-side protection
(guard(rcu)) when acquiring the hash bucket spinlock.

Since kvfree() does not respect RCU grace periods, the hash bucket
memory can be reclaimed while futex_unqueue() is still referencing it,
leading to a use-after-free on the embedded spinlock.

Use kvfree_rcu() instead, which defers freeing until after an RCU grace
period, matching the protection already assumed by futex_unqueue().

The futex_private_hash structure already has an rcu_head field used by
the pivot path (__futex_pivot_hash), so no structural changes are needed.

Fixes: 80367ad01d93 ("futex: Add basic infrastructure for local task local hash")
Reported-by: syzbot+6c1861115b4253e45969@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=6c1861115b4253e45969
Signed-off-by: SeungJu Cheon <suunj1331@xxxxxxxxx>
---
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

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 cf7e610eac42..b625455a7e9f 100644
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -1736,7 +1736,7 @@ void futex_hash_free(struct mm_struct *mm)
kvfree(mm->futex_phash_new);
fph = rcu_dereference_raw(mm->futex_phash);
if (fph)
- kvfree(fph);
+ kvfree_rcu(fph, rcu);
}

static bool futex_pivot_pending(struct mm_struct *mm)
--
2.52.0