mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrea Parri <parri.andrea@gmail.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@kernel.org>
Cc: Jiayuan Chen <jiayuan.chen@linux.dev>,
	Steven Rostedt <rostedt@goodmis.org>,
	Clark Williams <clrkwllms@kernel.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
	Sashiko <sashiko-bot@kernel.org>
Subject: [PATCH v2] irq_work: Fix use-after-free in irq_work_run_cpu() on PREEMPT_RT
Date: Tue,  1 Dec 2026 14:25:29 +0100	[thread overview]
Message-ID: <20261201132530.6995-1-parri.andrea@gmail.com> (raw)

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


                 reply	other threads:[~2026-12-01 13:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261201132530.6995-1-parri.andrea@gmail.com \
    --to=parri.andrea@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=clrkwllms@kernel.org \
    --cc=jiayuan.chen@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sashiko-bot@kernel.org \
    --cc=tglx@kernel.org \
    --cc=vbabka@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

all inboxes | Powered by JetHome®