All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: gtp: Fix Use-After-Free in gtp_dellink
@ 2024-04-22  9:39 Hyunwoo Kim
  2024-04-22 10:41 ` Eric Dumazet
  2024-04-24 11:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Hyunwoo Kim @ 2024-04-22  9:39 UTC (permalink / raw
  To: pablo, edumazet, laforge
  Cc: v4bel, imv4bel, davem, kuba, pabeni, osmocom-net-gprs, netdev

Since call_rcu, which is called in the hlist_for_each_entry_rcu traversal
of gtp_dellink, is not part of the RCU read critical section, it
is possible that the RCU grace period will pass during the traversal and
the key will be free.

To prevent this, it should be changed to hlist_for_each_entry_safe.

Fixes: 94dc550a5062 ("gtp: fix an use-after-free in ipv4_pdp_find()")
Signed-off-by: Hyunwoo Kim <v4bel@theori.io>
---
 drivers/net/gtp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
index ba4704c2c640..e62d6cbdf9bc 100644
--- a/drivers/net/gtp.c
+++ b/drivers/net/gtp.c
@@ -1098,11 +1098,12 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
 static void gtp_dellink(struct net_device *dev, struct list_head *head)
 {
 	struct gtp_dev *gtp = netdev_priv(dev);
+	struct hlist_node *next;
 	struct pdp_ctx *pctx;
 	int i;
 
 	for (i = 0; i < gtp->hash_size; i++)
-		hlist_for_each_entry_rcu(pctx, &gtp->tid_hash[i], hlist_tid)
+		hlist_for_each_entry_safe(pctx, next, &gtp->tid_hash[i], hlist_tid)
 			pdp_context_delete(pctx);
 
 	list_del_rcu(&gtp->list);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: gtp: Fix Use-After-Free in gtp_dellink
  2024-04-22  9:39 [PATCH] net: gtp: Fix Use-After-Free in gtp_dellink Hyunwoo Kim
@ 2024-04-22 10:41 ` Eric Dumazet
  2024-04-24 11:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2024-04-22 10:41 UTC (permalink / raw
  To: Hyunwoo Kim
  Cc: pablo, laforge, imv4bel, davem, kuba, pabeni, osmocom-net-gprs,
	netdev

On Mon, Apr 22, 2024 at 11:39 AM Hyunwoo Kim <v4bel@theori.io> wrote:
>
> Since call_rcu, which is called in the hlist_for_each_entry_rcu traversal
> of gtp_dellink, is not part of the RCU read critical section, it
> is possible that the RCU grace period will pass during the traversal and
> the key will be free.
>
> To prevent this, it should be changed to hlist_for_each_entry_safe.
>
> Fixes: 94dc550a5062 ("gtp: fix an use-after-free in ipv4_pdp_find()")
> Signed-off-by: Hyunwoo Kim <v4bel@theori.io>

Reviewed-by: Eric Dumazet <edumazet@google.com>

Thanks !

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] net: gtp: Fix Use-After-Free in gtp_dellink
  2024-04-22  9:39 [PATCH] net: gtp: Fix Use-After-Free in gtp_dellink Hyunwoo Kim
  2024-04-22 10:41 ` Eric Dumazet
@ 2024-04-24 11:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-04-24 11:10 UTC (permalink / raw
  To: Hyunwoo Kim
  Cc: pablo, edumazet, laforge, imv4bel, davem, kuba, pabeni,
	osmocom-net-gprs, netdev

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Mon, 22 Apr 2024 05:39:30 -0400 you wrote:
> Since call_rcu, which is called in the hlist_for_each_entry_rcu traversal
> of gtp_dellink, is not part of the RCU read critical section, it
> is possible that the RCU grace period will pass during the traversal and
> the key will be free.
> 
> To prevent this, it should be changed to hlist_for_each_entry_safe.
> 
> [...]

Here is the summary with links:
  - net: gtp: Fix Use-After-Free in gtp_dellink
    https://git.kernel.org/netdev/net/c/f2a904107ee2

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] 3+ messages in thread

end of thread, other threads:[~2024-04-24 11:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-22  9:39 [PATCH] net: gtp: Fix Use-After-Free in gtp_dellink Hyunwoo Kim
2024-04-22 10:41 ` Eric Dumazet
2024-04-24 11:10 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.