Skip to contentSkip to conversation

netfilter: nft_connlimit: fix possible data race on connection count

PATCH New Fernando Fernandez Mancera 1 participant 1 message Oct 24, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 netfilter: nft_connlimit: fix possible data race on connection count

nft_connlimit_eval() reads priv->list->count to check if the connection limit has been exceeded. This value is being read without a lock and can be modified by a different process. Use READ_ONCE() for correctness.

Fixes df4a90250976 ("netfilter: nf_conncount: merge lookup and add functions")

---
v2: adjusted commit message to reflect what is actually fixing

---
 net/netfilter/nft_connlimit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nft_connlimit.c +1 -1
index 92b984fa8175..fc35a11cdca2 100644
@@ -48,7 +48,7 @@ static inline void nft_connlimit_do_eval(struct nft_connlimit *priv,
 		return;
 	}
 
-	count = priv->list->count;
+	count = READ_ONCE(priv->list->count);
 
 	if ((count > priv->limit) ^ priv->invert) {
 		regs->verdict.code = NFT_BREAK;
Signature · 1 line
2.51.0