Re: [PATCH v2] irq_work: Fix use-after-free in irq_work_single on PREEMPT_RT

From: Sebastian Andrzej Siewior

Date: Tue Dec 01 2026 - 02:41:10 EST


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;
}

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index fdae495bf918b..08dbdcbc46687 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -840,7 +840,7 @@ static int very_verbose(struct lock_class *class)
* Is this the address of a static object:
*/
#ifdef __KERNEL__
-static int static_obj(const void *obj)
+int static_obj(const void *obj)
{
unsigned long addr = (unsigned long) obj;


Sebastian