mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] irq_work: Fix use-after-free in irq_work_run_cpu() on PREEMPT_RT
@ 2026-12-01 13:25 Andrea Parri
  0 siblings, 0 replies; only message in thread
From: Andrea Parri @ 2026-12-01 13:25 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior, Peter Zijlstra, Thomas Gleixner
  Cc: Jiayuan Chen, Steven Rostedt, Clark Williams, Vlastimil Babka,
	linux-rt-devel, linux-kernel, Sashiko

On PREEMPT_RT, irq_work_sync() relies on synchronize_rcu() for
!IRQ_WORK_HARD_IRQ items, because irq_work_single() still touches @work
after clearing IRQ_WORK_BUSY.  run_irq_workd() holds the RCU read lock
for that, but irq_work_run_cpu(), which runs a dead CPU's lazy items in
preemptible task context, does not.  If it is preempted right after
clearing IRQ_WORK_BUSY, irq_work_sync() can return and the caller can
free @work while irq_work_single() still uses it.

Hold the RCU read lock in irq_work_run_cpu(), as run_irq_workd() does.

The fix, the changelog and the test were written with the help of an
LLM.

Fixes: 40dcc9bdbef3 ("irq_work: Flush lazy work CPU down on PREEMPT_RT")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260911143815.997254-1-bigeasy@linutronix.de?part=2
Signed-off-by: Andrea Parri <parri.andrea@gmail.com>
---
Changes in v2:
- Shorten the changelog (Sebastian).

v1: https://lore.kernel.org/all/20261130093411.5582-1-parri.andrea@gmail.com/

 kernel/irq_work.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/irq_work.c b/kernel/irq_work.c
index 73eabcbdcd50c..121f604569d17 100644
--- a/kernel/irq_work.c
+++ b/kernel/irq_work.c
@@ -271,6 +271,7 @@ void irq_work_run_cpu(unsigned int cpu)
 	if (!IS_ENABLED(CONFIG_PREEMPT_RT))
 		return;
 
+	guard(rcu)();
 	irq_work_run_list(per_cpu_ptr(&lazy_list, cpu));
 }
 
-- 
2.53.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-01 13:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01 13:25 [PATCH v2] irq_work: Fix use-after-free in irq_work_run_cpu() on PREEMPT_RT Andrea Parri

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®