]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
genirq: Prevent use-after-free and work list corruption
authorPrasad Sodagudi <psodagud@codeaurora.org>
Sun, 24 Mar 2019 14:57:04 +0000 (07:57 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 2 Jul 2019 10:07:53 +0000 (12:07 +0200)
BugLink: https://bugs.launchpad.net/bugs/1834529
[ Upstream commit 59c39840f5abf4a71e1810a8da71aaccd6c17d26 ]

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 <psodagud@codeaurora.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: marc.zyngier@arm.com
Link: https://lkml.kernel.org/r/1553439424-6529-1-git-send-email-psodagud@codeaurora.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Connor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
kernel/irq/manage.c

index 3b3d6f654e0e3deacd4fe66494b5f94aab73302b..d21d0ab470a1dddbcd6f7ac9823fb8a4cc9e3943 100644 (file)
@@ -362,8 +362,10 @@ irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify)
        desc->affinity_notify = notify;
        raw_spin_unlock_irqrestore(&desc->lock, flags);
 
-       if (old_notify)
+       if (old_notify) {
+               cancel_work_sync(&old_notify->work);
                kref_put(&old_notify->kref, old_notify->release);
+       }
 
        return 0;
 }