* [PATCH net] lib: cpu_rmap: Fix potential use-after-free in irq_cpu_rmap_release()
@ 2023-06-02 18:28 Ben Hutchings
2023-06-06 8:18 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ben Hutchings @ 2023-06-02 18:28 UTC (permalink / raw)
To: netdev; +Cc: Thomas Gleixner, linux-kernel, Eli Cohen
[-- Attachment #1: Type: text/plain, Size: 877 bytes --]
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 ...")
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
I noticed this issue when reviewing stable changes. I haven't tested
the change.
Ben.
lib/cpu_rmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/cpu_rmap.c b/lib/cpu_rmap.c
index 73c1636b927b..4c348670da31 100644
--- a/lib/cpu_rmap.c
+++ b/lib/cpu_rmap.c
@@ -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);
}
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net] lib: cpu_rmap: Fix potential use-after-free in irq_cpu_rmap_release()
2023-06-02 18:28 [PATCH net] lib: cpu_rmap: Fix potential use-after-free in irq_cpu_rmap_release() Ben Hutchings
@ 2023-06-06 8:18 ` Simon Horman
2023-06-06 10:59 ` Paolo Abeni
2023-06-08 4:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-06-06 8:18 UTC (permalink / raw)
To: Ben Hutchings; +Cc: netdev, Thomas Gleixner, linux-kernel, Eli Cohen
On Fri, Jun 02, 2023 at 08:28:15PM +0200, Ben Hutchings wrote:
> 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 ...")
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] lib: cpu_rmap: Fix potential use-after-free in irq_cpu_rmap_release()
2023-06-02 18:28 [PATCH net] lib: cpu_rmap: Fix potential use-after-free in irq_cpu_rmap_release() Ben Hutchings
2023-06-06 8:18 ` Simon Horman
@ 2023-06-06 10:59 ` Paolo Abeni
2023-06-08 4:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Paolo Abeni @ 2023-06-06 10:59 UTC (permalink / raw)
To: Ben Hutchings, netdev
Cc: Thomas Gleixner, linux-kernel, Eli Cohen, jacob.e.keller, saeedm
Hi,
On Fri, 2023-06-02 at 20:28 +0200, Ben Hutchings wrote:
> 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 ...")
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
The patch LGTM, but please include the full blamed commit title into
the fixes tag. A new version will be needed.
Also add Jacob and Saeed to the cc-list
Thanks,
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] lib: cpu_rmap: Fix potential use-after-free in irq_cpu_rmap_release()
2023-06-02 18:28 [PATCH net] lib: cpu_rmap: Fix potential use-after-free in irq_cpu_rmap_release() Ben Hutchings
2023-06-06 8:18 ` Simon Horman
2023-06-06 10:59 ` Paolo Abeni
@ 2023-06-08 4:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-06-08 4:30 UTC (permalink / raw)
To: Ben Hutchings; +Cc: netdev, tglx, linux-kernel, elic
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 2 Jun 2023 20:28:15 +0200 you wrote:
> 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 ...")
> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
>
> [...]
Here is the summary with links:
- [net] lib: cpu_rmap: Fix potential use-after-free in irq_cpu_rmap_release()
https://git.kernel.org/netdev/net/c/7c5d4801ecf0
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-08 4:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-02 18:28 [PATCH net] lib: cpu_rmap: Fix potential use-after-free in irq_cpu_rmap_release() Ben Hutchings
2023-06-06 8:18 ` Simon Horman
2023-06-06 10:59 ` Paolo Abeni
2023-06-08 4:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).