]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
netfilter: nft_connlimit: fix possible data race on connection count
authorFernando Fernandez Mancera <fmancera@suse.de>
Fri, 24 Oct 2025 15:54:39 +0000 (17:54 +0200)
committerFlorian Westphal <fw@strlen.de>
Wed, 29 Oct 2025 13:47:59 +0000 (14:47 +0100)
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")
Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/nft_connlimit.c

index 92b984fa8175c298f9829c34cf9f630d053a4e82..fc35a11cdca2097e6cbaeb09ea1e1a814d6319e4 100644 (file)
@@ -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;