diff options
| author | Richard Patel <ripatel@wii.dev> | 2026-10-09 14:58:42 +0000 |
|---|---|---|
| committer | Thomas Gleixner <tglx@kernel.org> | 2026-10-16 00:18:40 +0200 |
| commit | 89a9e003a2ef73f67dff03dfd59e0a5474b56b0b (patch) | |
| tree | 1ca7993255d9a075d3f34815657fb73646e645e0 /kernel | |
| parent | d04adff6860587e843948b0c31174f8ae11b8dfe (diff) | |
| download | linux-89a9e003a2ef73f67dff03dfd59e0a5474b56b0b.tar.gz linux-89a9e003a2ef73f67dff03dfd59e0a5474b56b0b.zip | |
genirq: Move interrupt thread exit_work object to irqaction
irq_thread() registers irq_thread_dtor() as exit task_work using a
stack-allocated callback_head. On normal interrupt thread exit, this work
gets cancelled and never runs.
On x86, an abnormal interrupt thread exit (e.g. handler oops) discards the
stack, including the callback_head, while that callback_head is still
pending. By the time exit_task_work() runs, the stack memory formerly
backing callback_head is already clobbered.
irq_thread() <-- on_exit_work allocated
** IRQ handler faults **
oops_end()
rewind_stack_and_make_dead() <-- on_exit_work freed
make_task_dead()
do_exit(SIGSEGV)
...
exit_shm() <-- on_exit_work clobbered
...
exit_task_work() <-- stack use-after-free
exit_shm()+0x30 <-- wild jump to return addr
Thus, a benign threaded IRQ oops (e.g. a NULL pointer deref) is
turned into a wild jump. This is caught by kernel IBT:
** first fault **
Oops: general protection fault, kernel NULL pointer dereference 0x3c0: 0000 [#1] SMP NOPTI
...
** second fault **
Missing ENDBR: exit_shm+0x30/0x1c0
kernel BUG at arch/x86/kernel/cet.c:133!
...
? task_work_run+0x5c/0x90
? do_exit+0x209/0x460
? rewind_stack_and_make_dead+0x16/0x20
...
note: irq/165-AudioDS[1427] exited with irqs disabled
Fixing recursive fault but reboot is needed!
Fix this by storing the callback_head in struct irqaction. The irqaction
is only freed once irq_thread_dtor() finishes.
Fixes: 2deb4be28077 ("x86/dumpstack: When OOPSing, rewind the stack before do_exit()")
Signed-off-by: Richard Patel <ripatel@wii.dev>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261009145842.1616117-3-ripatel@wii.dev
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/irq/manage.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 87a2476ea259..3b647d9b458a 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1201,9 +1201,9 @@ static void __irq_thread_dtor(struct irqaction *action) irq_finalize_oneshot(desc, action); } -static void irq_thread_dtor(struct callback_head *unused) +static void irq_thread_dtor(struct callback_head *work) { - struct irqaction *action = kthread_data(current); + struct irqaction *action = container_of(work, struct irqaction, thread_dtor); __irq_thread_dtor(action); clear_and_wake_up_bit(IRQTF_EXIT_WORK, &action->thread_flags); @@ -1250,7 +1250,6 @@ static void wake_up_and_wait_for_irq_thread_ready(struct irq_desc *desc, */ static int irq_thread(void *data) { - struct callback_head on_exit_work; struct irqaction *action = data; struct irq_desc *desc = irq_to_desc(action->irq); irqreturn_t (*handler_fn)(struct irq_desc *desc, @@ -1270,8 +1269,8 @@ static int irq_thread(void *data) handler_fn = irq_thread_fn; set_bit(IRQTF_EXIT_WORK, &action->thread_flags); - init_task_work(&on_exit_work, irq_thread_dtor); - task_work_add(current, &on_exit_work, TWA_NONE); + init_task_work(&action->thread_dtor, irq_thread_dtor); + task_work_add(current, &action->thread_dtor, TWA_NONE); while (!irq_wait_for_interrupt(desc, action)) { irqreturn_t action_ret; |
