All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: openvswitch: Fix Use-After-Free in ovs_ct_exit
@ 2024-04-22  9:37 Hyunwoo Kim
  2024-04-22 10:40 ` Eric Dumazet
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Hyunwoo Kim @ 2024-04-22  9:37 UTC (permalink / raw)
  To: pshelar, edumazet; +Cc: v4bel, imv4bel, davem, kuba, pabeni, netdev, dev

Since kfree_rcu, which is called in the hlist_for_each_entry_rcu traversal
of ovs_ct_limit_exit, 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: 11efd5cb04a1 ("openvswitch: Support conntrack zone limit")
Signed-off-by: Hyunwoo Kim <v4bel@theori.io>
---
 net/openvswitch/conntrack.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c
index 74b63cdb5992..2928c142a2dd 100644
--- a/net/openvswitch/conntrack.c
+++ b/net/openvswitch/conntrack.c
@@ -1593,9 +1593,9 @@ static void ovs_ct_limit_exit(struct net *net, struct ovs_net *ovs_net)
 	for (i = 0; i < CT_LIMIT_HASH_BUCKETS; ++i) {
 		struct hlist_head *head = &info->limits[i];
 		struct ovs_ct_limit *ct_limit;
+		struct hlist_node *next;
 
-		hlist_for_each_entry_rcu(ct_limit, head, hlist_node,
-					 lockdep_ovsl_is_held())
+		hlist_for_each_entry_safe(ct_limit, next, head, hlist_node)
 			kfree_rcu(ct_limit, rcu);
 	}
 	kfree(info->limits);
-- 
2.34.1


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

* Re: [PATCH] net: openvswitch: Fix Use-After-Free in ovs_ct_exit
  2024-04-22  9:37 [PATCH] net: openvswitch: Fix Use-After-Free in ovs_ct_exit Hyunwoo Kim
@ 2024-04-22 10:40 ` Eric Dumazet
  2024-04-24 14:58 ` [ovs-dev] " Aaron Conole
  2024-04-25  2:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2024-04-22 10:40 UTC (permalink / raw)
  To: Hyunwoo Kim; +Cc: pshelar, imv4bel, davem, kuba, pabeni, netdev, dev

On Mon, Apr 22, 2024 at 11:37 AM Hyunwoo Kim <v4bel@theori.io> wrote:
>
> Since kfree_rcu, which is called in the hlist_for_each_entry_rcu traversal
> of ovs_ct_limit_exit, 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: 11efd5cb04a1 ("openvswitch: Support conntrack zone limit")
> Signed-off-by: Hyunwoo Kim <v4bel@theori.io>

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

Thanks !

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

* Re: [ovs-dev] [PATCH] net: openvswitch: Fix Use-After-Free in ovs_ct_exit
  2024-04-22  9:37 [PATCH] net: openvswitch: Fix Use-After-Free in ovs_ct_exit Hyunwoo Kim
  2024-04-22 10:40 ` Eric Dumazet
@ 2024-04-24 14:58 ` Aaron Conole
  2024-04-25  2:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Aaron Conole @ 2024-04-24 14:58 UTC (permalink / raw)
  To: Hyunwoo Kim; +Cc: pshelar, edumazet, dev, netdev, imv4bel, kuba, pabeni, davem

Hyunwoo Kim <v4bel@theori.io> writes:

> Since kfree_rcu, which is called in the hlist_for_each_entry_rcu traversal
> of ovs_ct_limit_exit, 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: 11efd5cb04a1 ("openvswitch: Support conntrack zone limit")
> Signed-off-by: Hyunwoo Kim <v4bel@theori.io>
> ---

Reviewed-by: Aaron Conole <aconole@redhat.com>


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

* Re: [PATCH] net: openvswitch: Fix Use-After-Free in ovs_ct_exit
  2024-04-22  9:37 [PATCH] net: openvswitch: Fix Use-After-Free in ovs_ct_exit Hyunwoo Kim
  2024-04-22 10:40 ` Eric Dumazet
  2024-04-24 14:58 ` [ovs-dev] " Aaron Conole
@ 2024-04-25  2:40 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-04-25  2:40 UTC (permalink / raw)
  To: Hyunwoo Kim; +Cc: pshelar, edumazet, imv4bel, davem, kuba, pabeni, netdev, dev

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 22 Apr 2024 05:37:17 -0400 you wrote:
> Since kfree_rcu, which is called in the hlist_for_each_entry_rcu traversal
> of ovs_ct_limit_exit, 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: openvswitch: Fix Use-After-Free in ovs_ct_exit
    https://git.kernel.org/netdev/net/c/5ea7b72d4fac

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:[~2024-04-25  2:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-22  9:37 [PATCH] net: openvswitch: Fix Use-After-Free in ovs_ct_exit Hyunwoo Kim
2024-04-22 10:40 ` Eric Dumazet
2024-04-24 14:58 ` [ovs-dev] " Aaron Conole
2024-04-25  2:40 ` 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.