projects/linux·commit f4d46809

Merge tag 'wq-for-6.14-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq

f4d46809 · Linus Torvalds <[email protected]> · 2025-02-14 10:58:03 -08:00

Pull workqueue fix from Tejun Heo:

 - Fix a regression where a worker pool can be freed before rescuer
   workers are done with it leading to user-after-free

* tag 'wq-for-6.14-rc2-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq:
  workqueue: Put the pwq after detaching the rescuer from the pool
Commit
f4d4680965aa3be2b2bf392a54fabb244fdce46a
Parents
111b2959 · e7694611

Merge commit. Changes below are compared with the first parent: 111b2959.

Changes

1 files changed · +6 −6

FileStatusAddDelContent
kernel/workqueue.cmodified+6−6View file

kernel/workqueue.c

View file
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 3c2c453..97152f2 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3517,12 +3517,6 @@ repeat:
}
/*
- * Put the reference grabbed by send_mayday(). @pool won't
- * go away while we're still attached to it.
- */
- put_pwq(pwq);
-
- /*
* Leave this pool. Notify regular workers; otherwise, we end up
* with 0 concurrency and stalling the execution.
*/
@@ -3532,6 +3526,12 @@ repeat:
worker_detach_from_pool(rescuer);
+ /*
+ * Put the reference grabbed by send_mayday(). @pool might
+ * go away any time after it.
+ */
+ put_pwq_unlocked(pwq);
+
raw_spin_lock_irq(&wq_mayday_lock);
}