Skip to content

Commit 68d0415

Browse files
Florian Westphalgregkh
authored andcommitted
netfilter: nf_conncount: callers must hold rcu read lock
[ Upstream commit 64d7d5a ] rcu_derefence_raw() should not have been used here, it concealed this bug. Its used because struct rb_node lacks __rcu annotated pointers, so plain rcu_derefence causes sparse warnings. The major tradeoff is that rcu_derefence_raw() doesn't warn when the caller isn't in a rcu read section. Extend the rcu read lock scope accordingly and cause sparse warnings, those warnings are the lesser evil. Fixes: 11efd5c ("openvswitch: Support conntrack zone limit") Closes: https://sashiko.dev/#/patchset/20260603230610.7900-1-fw%40strlen.de Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b8c9082 commit 68d0415

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

net/netfilter/nf_conncount.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,17 +499,17 @@ count_tree(struct net *net,
499499
hash = jhash2(key, data->keylen, conncount_rnd) % CONNCOUNT_SLOTS;
500500
root = &data->root[hash];
501501

502-
parent = rcu_dereference_raw(root->rb_node);
502+
parent = rcu_dereference(root->rb_node);
503503
while (parent) {
504504
int diff;
505505

506506
rbconn = rb_entry(parent, struct nf_conncount_rb, node);
507507

508508
diff = key_diff(key, rbconn->key, data->keylen);
509509
if (diff < 0) {
510-
parent = rcu_dereference_raw(parent->rb_left);
510+
parent = rcu_dereference(parent->rb_left);
511511
} else if (diff > 0) {
512-
parent = rcu_dereference_raw(parent->rb_right);
512+
parent = rcu_dereference(parent->rb_right);
513513
} else {
514514
int ret;
515515

net/openvswitch/conntrack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1774,10 +1774,10 @@ static int ovs_ct_limit_get_zone_limit(struct net *net,
17741774
} else {
17751775
rcu_read_lock();
17761776
limit = ct_limit_get(info, zone);
1777-
rcu_read_unlock();
17781777

17791778
err = __ovs_ct_limit_get_zone_limit(
17801779
net, info->data, zone, limit, reply);
1780+
rcu_read_unlock();
17811781
if (err)
17821782
return err;
17831783
}

0 commit comments

Comments
 (0)