From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=193.142.43.55 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796114503; b=FODa8SnqLnSFI9OGD3GQFkf9oPLXDOOvVvt8IZX3ZS2zcGy2P4AZxqYQbwfkvfripQWD idf5BUL/Tqd8KBRu7Y9M7LAq7Mev0AXT8c+Rv8Hqv07dis34yCt0ZKISJ1c+oj9lolK5f 6CETY6sda5yWGAXhtFb81Gco+ucK2tdzlGIfLSCo8+yNcSWNA29c05kBXNNKfkzStZmY/ 2zeE2GJUeRw1+Bom6W+6UcX6s2y9jAq5yfeKNyRScamgGXqoBX2unvG0zSF3sg17/Bjg4 +QEFYipfqGTAbnwalmGzxcCe0Q2SwyQ64mbzNmLhW268ZV8zy3CUApGp7Uu2VgVTN5Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796114503; h=DMARC-Filter:Date:DKIM-Signature:DKIM-Signature:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; bh=ujRhjMHMMU+uySaAGnDVSXYbGKTnDO2Bm8XrSIIjn8g=; b=LtZFGoCRN7ioFkcbXYA9guXwupeRYOhrMpVZIjLvBxDdeJBcqevZ3qMx5Z8Cqte04uYs 56SfCJnPUXly0Nwmhn1BLeylfRJ3I+RrlQjDm4NRzWLXXUVYmw58dv8f09TwLK/r1czQm xWHq15zCwPz4zIjmYF2LJ2Ub2sXgp2z+ZXuPSRuIaV+tQl7BleWuf3cKi7oSLrSytM1TB ImfQgzemBCmQouhHITlKrQEQ680r+A1tDTHTa6DiL/q9msrauv0IiKYzlKNNGa+morBsk uM+kMcpgS49wMd0nRk/Q80SmEhQWzdhtAWBwPSWxuLq0YkGpEp5Aiu/fezKxL5FfXPg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=rsa-sha256 header.s=2020 header.b=bVr+62AG; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=lWfuSYi6; arc=none smtp.remote-ip=193.142.43.55 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3156606A31A for ; Tue, 1 Dec 2026 08:41:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C3156606A31A 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.a=rsa-sha256 header.s=2020 header.b=bVr+62AG; dkim=pass header.d=linutronix.de header.i=@linutronix.de header.a=ed25519-sha256 header.s=2020e header.b=lWfuSYi6 Date: Tue, 1 Dec 2026 09:41:38 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1796114500; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ujRhjMHMMU+uySaAGnDVSXYbGKTnDO2Bm8XrSIIjn8g=; b=bVr+62AGzLOW4BcCmIEaH1g4q1V7DJp5tFECvAobpinOaQpWgjqn73AMhlrIz6ORkIE9FL O0CVxvozMV6fC57mJwFPXjBKc1+do7w8tfPU7g67o99mIysRfU8iMSGgZqFkonq1MFCEnY Tp4xPK3pIfKZrmJEEVoKGA5GnHpSzy3thFirLJqM3jClX9Sj8fZJeO6c3VaDrDwybRma00 RhG2JpxTWE5Xdw/MBlytig+Z6eaut+MAPFDTZRsu9DkfWeN2B1PfwU/5Y7Kx5tBMkQpl+s JkZIfe8+tyaz6ru3toKo7+c0pMZOa8ykyu2TdM//ZCNPv/8NT2b2jpQBfJ679w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1796114500; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ujRhjMHMMU+uySaAGnDVSXYbGKTnDO2Bm8XrSIIjn8g=; b=lWfuSYi6h05gPFkm9uElgdM/ukadC24UjgrzcV6dD+E+t7wxhE+qTfnfW9ZwGB59w8por3 kDNC1r2l04dyzIBw== From: Sebastian Andrzej Siewior To: "Vlastimil Babka (SUSE)" Cc: Jan Kiszka , Harry Yoo , Jiayuan Chen , linux-rt-devel@lists.linux.dev, Steven Rostedt , Clark Williams , "Peter Zijlstra (Intel)" , linux-kernel@vger.kernel.org, Florian Bezdeka Subject: Re: [PATCH v2] irq_work: Fix use-after-free in irq_work_single on PREEMPT_RT Message-ID: <20261201084138.4kc3M7Mp@linutronix.de> References: <20260330073234.303732-1-jiayuan.chen@linux.dev> <16fda1b1-2c72-4d05-b1c8-f424ac2848c6@siemens.com> <20260819105259.7ENaDrl2@linutronix.de> <60887e69-ae28-495c-a6d7-7d0a94fd1aa8@siemens.com> <5c553fca-3a7a-4bd6-b41a-00594f854440@kernel.org> <20261201074102.kypEt88L@linutronix.de> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20261201074102.kypEt88L@linutronix.de> On 2026-12-01 08:41:02 [+0100], To Vlastimil Babka (SUSE) wrote: > On 2026-11-27 21:44:52 [+0100], Vlastimil Babka (SUSE) wrote: > > Hi, > > > > for slab we recently got proposed the AI fix below. While it seems correct > > to me, it feels wrong to do such an ad-hoc workaround. I'd expect there > > would be other cases where the work is static and no UAF can exist. Can we > > accomodate them in a generic way? Thanks. > > Something like the below with the move of static_obj() to somewhere in > mm/? > > diff --git a/kernel/irq_work.c b/kernel/irq_work.c > index 73eabcbdcd50c..4e26a4ecdad8c 100644 > --- a/kernel/irq_work.c > +++ b/kernel/irq_work.c > @@ -305,7 +305,8 @@ void irq_work_sync(struct irq_work *work) > * after removing IRQ_WORK_BUSY. It is always > * accessed within a RCU-read section. > */ > - synchronize_rcu(); > + if (!static_obj(&work->irqwait)) > + synchronize_rcu(); > return; > } I had this in quick testing and it almost hit nothing (as in avoided a synchronize_rcu()). I got deferred_work_barrier() a few times after a rmmod btrfs. I got sched_mm_cid_exit() which is non-static way more often. Initially I suggested this synchronize_rcu() and a RCU section because almost everything was in place and cancel+ irq_work_sync() should not happen *that* often. But it is more often than I expected. There I am thinking to revive Jiayuan's original patch and solve this issue without synchronize_rcu() and the need for a RCU read section. This would avoid both issues. Sebastian