Skip to content

Commit 5ea7b72

Browse files
V4bel-theorikuba-moo
authored andcommitted
net: openvswitch: Fix Use-After-Free in ovs_ct_exit
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: 11efd5c ("openvswitch: Support conntrack zone limit") Signed-off-by: Hyunwoo Kim <v4bel@theori.io> Reviewed-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Aaron Conole <aconole@redhat.com> Link: https://lore.kernel.org/r/ZiYvzQN/Ry5oeFQW@v4bel-B760M-AORUS-ELITE-AX Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 5b5f724 commit 5ea7b72

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/openvswitch/conntrack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,9 +1593,9 @@ static void ovs_ct_limit_exit(struct net *net, struct ovs_net *ovs_net)
15931593
for (i = 0; i < CT_LIMIT_HASH_BUCKETS; ++i) {
15941594
struct hlist_head *head = &info->limits[i];
15951595
struct ovs_ct_limit *ct_limit;
1596+
struct hlist_node *next;
15961597

1597-
hlist_for_each_entry_rcu(ct_limit, head, hlist_node,
1598-
lockdep_ovsl_is_held())
1598+
hlist_for_each_entry_safe(ct_limit, next, head, hlist_node)
15991599
kfree_rcu(ct_limit, rcu);
16001600
}
16011601
kfree(info->limits);

0 commit comments

Comments
 (0)