From nobody Sat Jun 13 02:04:57 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48DAE1A23A4; Mon, 11 May 2026 14:31:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778509904; cv=none; b=W+Zk9d6xfyIOqs8P2+eWLT36MI+7YFmQ0cHAIeBttg+GmU2hZ8YTw+h1m0mvpk8AnTfyyb+WutqnYROv/D7anPRaGaQ6hj0/OSZ5/WlwfJrxV8kePsLQbB9DshArAt1TdiXWc2PJ1m70S6xQjuv5nsr1PdUZ1k+EkiqL1diE0GE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778509904; c=relaxed/simple; bh=J1GPMjvgMRr96DUxfyQ9BSbDjo1dHZL3jo9ldGIUfH4=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=XtI72VmDZ2Q5JYZfMXElvX0ogdT+JmBLDR5OnG2cwEfJ2Im3bfTPSWzd/Yzd1xlTwD0Ve3ZAv5U2Mgf+XFCT+1tChGOcZlX5HSRFo0Ift72AUr9cnyfbGaBIBLFZ8Fr4wIxhlE/gWK6iPyk24OxYECM4iGiw2JYrIB+rRpZ8b+k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=v5df2UkI; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ScrAEadl; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="v5df2UkI"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ScrAEadl" Date: Mon, 11 May 2026 14:31:39 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1778509901; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4pwCJ7iLCIVxGv0Azk1bHK+z4ziSUwrL/3eJ9jpwCMo=; b=v5df2UkIM1qI1Q/XMUd5XU5LpnnKl3EScOxgTRBEA7vs2X52cnn/19Z2CvdiRwVftyFLJE 6dygdeDqqWr9SAjlH8XCo2YOU4gKV7VUxGO9soXlsvwrerLqNrZRjwAS2PYLnzmjbLYI1d Q3KUiSshBXRDmJup/gb9HJrUDXva1p4AGE62qd1JFd2gWs5wYBplK3s5KlHlyiRX1+VoJi lTeSRfFWazU/BV6wvKynAofDglN3lT+bL1sWWzHxlPxAnv0fe0m8xOfZgOxmQ8m11aGKSF QI6gGVplhoS2/2HH5CQEPhxhRdd+45ri/8z1qb45HZZczWV78QIdiDhgFv4HLg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1778509901; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4pwCJ7iLCIVxGv0Azk1bHK+z4ziSUwrL/3eJ9jpwCMo=; b=ScrAEadlId3/hNJCAsezpXphxnrZtpTdM8+w+JS6qiJF7SKRWu9fJh4UiLMMbMhXnWRi12 CK+QnXUmL9z4n1Cg== From: "tip-bot2 for Jiayuan Chen" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/urgent] irq_work: Fix use-after-free in irq_work_single() on PREEMPT_RT Cc: Sebastian Andrzej Siewior , Steven Rostedt , Jiayuan Chen , Thomas Gleixner , x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org In-Reply-To: <20260330073234.303732-1-jiayuan.chen@linux.dev> References: <20260330073234.303732-1-jiayuan.chen@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177850989979.188840.722327764992867720.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the irq/urgent branch of tip: Commit-ID: 91840be8f710370607f949a627e070896faeddb8 Gitweb: https://git.kernel.org/tip/91840be8f710370607f949a627e070896= faeddb8 Author: Jiayuan Chen AuthorDate: Mon, 30 Mar 2026 15:32:29 +08:00 Committer: Thomas Gleixner CommitterDate: Mon, 11 May 2026 16:28:04 +02:00 irq_work: Fix use-after-free in irq_work_single() on PREEMPT_RT On PREEMPT_RT, non-HARD irq_work runs in per-CPU kthreads via run_irq_workd(), so irq_work_sync() uses rcuwait() to wait for BUSY=3D=3D0. After irq_work_single() clears BUSY via atomic_cmpxchg(), it still dereferences @work for irq_work_is_hard() and rcuwait_wake_up(). An irq_work_sync() caller on another CPU that enters after BUSY is cleared can observe BUSY=3D=3D0 immediately, return, and free the work before those accesses complete =E2=80=94 causing a use-after-free. Fix this by wrapping run_irq_workd() in guard(rcu)() so that the entire irq_work_single() execution is within an RCU read-side critical section. Then add synchronize_rcu() in irq_work_sync() after rcuwait_wait_event() to ensure the caller waits for the RCU grace period before returning, preventing premature frees. Fixes: 810979682ccc ("irq_work: Allow irq_work_sync() to sleep if irq_work(= ) no IRQ support.") Suggested-by: Sebastian Andrzej Siewior Suggested-by: Steven Rostedt Signed-off-by: Jiayuan Chen Signed-off-by: Thomas Gleixner Reviewed-by: Sebastian Andrzej Siewior Link: https://patch.msgid.link/20260330073234.303732-1-jiayuan.chen@linux.d= ev --- kernel/irq_work.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/irq_work.c b/kernel/irq_work.c index 120fd73..f7e2dc2 100644 --- a/kernel/irq_work.c +++ b/kernel/irq_work.c @@ -292,6 +292,12 @@ void irq_work_sync(struct irq_work *work) !arch_irq_work_has_interrupt()) { rcuwait_wait_event(&work->irqwait, !irq_work_is_busy(work), TASK_UNINTERRUPTIBLE); + /* + * Ensure irq_work_single() does not access @work + * after removing IRQ_WORK_BUSY. It is always + * accessed within a RCU-read section. + */ + synchronize_rcu(); return; } =20 @@ -302,6 +308,7 @@ EXPORT_SYMBOL_GPL(irq_work_sync); =20 static void run_irq_workd(unsigned int cpu) { + guard(rcu)(); irq_work_run_list(this_cpu_ptr(&lazy_list)); } =20