Skip to content

Commit

Permalink
lib: cpu_rmap: Fix potential use-after-free in irq_cpu_rmap_release()
Browse files Browse the repository at this point in the history
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: 4e0473f ("lib: cpu_rmap: Avoid use after free on rmap->obj array entries")
Signed-off-by: Ben Hutchings <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
bwhacks authored and kuba-moo committed Jun 8, 2023
1 parent 44f8baa commit 7c5d480
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cpu_rmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,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);
}

Expand Down

0 comments on commit 7c5d480

Please sign in to comment.