From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Felix Hoffmann <f3lix.dev@gmx.de>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>
Subject: [PATCH 7.2 12/82] futex: Avoid private hash use-after-free on final put
Date: Tue, 25 Aug 2026 15:24:59 +0200 [thread overview]
Message-ID: <20260825132542.010975254@linuxfoundation.org> (raw)
In-Reply-To: <20260825132541.560541185@linuxfoundation.org>
7.2-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Hoffmann <f3lix.dev@gmx.de>
commit 1c7efabfbaf796f11000a46094a69955a01ec6cc upstream.
futex_private_hash_put() drops the reference to fph before evaluating
fph->mm for wake_up_var(). futex_ref_put() enables preemption again before
returning. If that put drops the final reference and the task is preempted,
another task can pivot to the replacement hash and free the old hash after
an RCU grace period. The first task then reads fph->mm from the freed
allocation when it resumes.
KASAN reports a slab-use-after-free in futex_private_hash_put(), with the
read at offset 24 in a freed kmalloc-512 allocation. The allocation and
free stacks point to futex_hash_allocate() and the RCU free path,
respectively.
Load the mm pointer while the fph reference is still held and pass the
saved value to wake_up_var(). wake_up_var() uses the pointer as a waitqueue
key and does not dereference the mm through it.
Fixes: bd54df5ea7ca ("futex: Allow to resize the private local hash")
Signed-off-by: Felix Hoffmann <f3lix.dev@gmx.de>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260731155024.1150011-1-f3lix.dev@gmx.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
kernel/futex/core.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
--- a/kernel/futex/core.c
+++ b/kernel/futex/core.c
@@ -143,8 +143,14 @@ static bool futex_private_hash_get(struc
void futex_private_hash_put(struct futex_private_hash *fph)
{
- if (fph && futex_ref_put(fph))
- wake_up_var(fph->mm);
+ struct mm_struct *mm;
+
+ if (!fph)
+ return;
+
+ mm = fph->mm;
+ if (futex_ref_put(fph))
+ wake_up_var(mm);
}
static struct futex_hash_bucket *
next prev parent reply other threads:[~2026-08-25 13:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260825132541.560541185@linuxfoundation.org>
2026-08-25 13:24 ` [PATCH 7.2 01/82] PCI: host-generic: Fix NULL pointer dereference on 32-bit CAM systems Greg Kroah-Hartman
2026-08-25 13:24 ` [PATCH 7.2 02/82] Bluetooth: RFCOMM: take rfcomm_mutex for the deferred setup accept Greg Kroah-Hartman
2026-08-25 13:24 ` [PATCH 7.2 10/82] futex: Sanitize and document task_struct::futex::state transitions Greg Kroah-Hartman
2026-08-25 13:24 ` [PATCH 7.2 11/82] futex/pi: Plug private futex exec() race Greg Kroah-Hartman
2026-08-25 13:24 ` Greg Kroah-Hartman [this message]
2026-08-25 13:25 ` [PATCH 7.2 13/82] futex: Fix race on the initial mm->futex.phash.ref allocation Greg Kroah-Hartman
2026-08-25 13:25 ` [PATCH 7.2 14/82] io_uring/futex: dont mark futex wake requests as inflight Greg Kroah-Hartman
2026-08-25 13:25 ` [PATCH 7.2 15/82] io_uring/futex: only mark private futex waits " Greg Kroah-Hartman
2026-08-25 13:25 ` [PATCH 7.2 16/82] ALSA: dummy: Check card index validity at probe Greg Kroah-Hartman
2026-08-25 13:25 ` [PATCH 7.2 17/82] io_uring/cmd: fix iovec leak when the async cmd is not recycled Greg Kroah-Hartman
2026-08-25 13:25 ` [PATCH 7.2 18/82] io_uring/io-wq: fix worker accounting when canceling creation callbacks Greg Kroah-Hartman
2026-08-25 13:25 ` [PATCH 7.2 19/82] io_uring/rsrc: fix folio size overflow in io_vec_fill_bvec() Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260825132542.010975254@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=f3lix.dev@gmx.de \
--cc=patches@lists.linux.dev \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox