Skip to content

Commit 2cea0ed

Browse files
committed
Merge tag 'locking-urgent-2025-09-26' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull locking fixes from Ingo Molnar: "Fix a PI-futexes race, and fix a copy_process() futex cleanup bug" * tag 'locking-urgent-2025-09-26' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: futex: Use correct exit on failure from futex_hash_allocate_default() futex: Prevent use-after-free during requeue-PI
2 parents 8b07f74 + 4ec3c15 commit 2cea0ed

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

kernel/fork.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2295,7 +2295,7 @@ __latent_entropy struct task_struct *copy_process(
22952295
if (need_futex_hash_allocate_default(clone_flags)) {
22962296
retval = futex_hash_allocate_default();
22972297
if (retval)
2298-
goto bad_fork_core_free;
2298+
goto bad_fork_cancel_cgroup;
22992299
/*
23002300
* If we fail beyond this point we don't free the allocated
23012301
* futex hash map. We assume that another thread will be created

kernel/futex/requeue.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,9 @@ static inline
230230
void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key,
231231
struct futex_hash_bucket *hb)
232232
{
233-
q->key = *key;
233+
struct task_struct *task;
234234

235+
q->key = *key;
235236
__futex_unqueue(q);
236237

237238
WARN_ON(!q->rt_waiter);
@@ -243,10 +244,11 @@ void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key,
243244
futex_hash_get(hb);
244245
q->drop_hb_ref = true;
245246
q->lock_ptr = &hb->lock;
247+
task = READ_ONCE(q->task);
246248

247249
/* Signal locked state to the waiter */
248250
futex_requeue_pi_complete(q, 1);
249-
wake_up_state(q->task, TASK_NORMAL);
251+
wake_up_state(task, TASK_NORMAL);
250252
}
251253

252254
/**

0 commit comments

Comments
 (0)