summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2023-06-02 20:28:15 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-06-14 10:59:56 +0200
commita6ca812973923229e1582efd1c8e221b4382308a (patch)
treefb4d6bf7ba146e91862ad5a3926d7e5e53f699ed /lib
parent198da74a4e8d4c2b2669eebc9f85e19e80cfae5a (diff)
downloadlinux-stable-a6ca812973923229e1582efd1c8e221b4382308a.tar.gz
linux-stable-a6ca812973923229e1582efd1c8e221b4382308a.tar.bz2
linux-stable-a6ca812973923229e1582efd1c8e221b4382308a.zip
lib: cpu_rmap: Fix potential use-after-free in irq_cpu_rmap_release()
[ Upstream commit 7c5d4801ecf0564c860033d89726b99723c55146 ] irq_cpu_rmap_release() calls cpu_rmap_put(), which may free the rmap. So we need to clear the pointer to our glue structure in rmap before doing that, not after. Fixes: 4e0473f1060a ("lib: cpu_rmap: Avoid use after free on rmap->obj array entries") Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Reviewed-by: Simon Horman <simon.horman@corigine.com> Link: https://lore.kernel.org/r/ZHo0vwquhOy3FaXc@decadent.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/cpu_rmap.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/cpu_rmap.c b/lib/cpu_rmap.c
index 920403fa5b0d..51621fde0b48 100644
--- a/lib/cpu_rmap.c
+++ b/lib/cpu_rmap.c
@@ -268,8 +268,8 @@ static void irq_cpu_rmap_release(struct kref *ref)
struct irq_glue *glue =
container_of(ref, struct irq_glue, notify.kref);
- cpu_rmap_put(glue->rmap);
glue->rmap->obj[glue->index] = NULL;
+ cpu_rmap_put(glue->rmap);
kfree(glue);
}