Skip to content

Commit 59c3984

Browse files
Prasad SodagudiKAGA-KOKO
authored andcommitted
genirq: Prevent use-after-free and work list corruption
When irq_set_affinity_notifier() replaces the notifier, then the reference count on the old notifier is dropped which causes it to be freed. But nothing ensures that the old notifier is not longer queued in the work list. If it is queued this results in a use after free and possibly in work list corruption. Ensure that the work is canceled before the reference is dropped. Signed-off-by: Prasad Sodagudi <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent 8c2ffd9 commit 59c3984

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

kernel/irq/manage.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,10 @@ irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify)
357357
desc->affinity_notify = notify;
358358
raw_spin_unlock_irqrestore(&desc->lock, flags);
359359

360-
if (old_notify)
360+
if (old_notify) {
361+
cancel_work_sync(&old_notify->work);
361362
kref_put(&old_notify->kref, old_notify->release);
363+
}
362364

363365
return 0;
364366
}

0 commit comments

Comments
 (0)