Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796165123; b=3iJK1LF3rDSkWq/Zke6XiRsmus4UOyfnHXvoEnbv/IycD6aR1cr8vAV2FfomK99OYM/V U0r7KZbMYYIZNCUh1QfOOim00yjpCisFTWpx7Gj2zqRyrkK7t0CE+IZQ85iCAgjMZjXCO PB/ZyIZ+J05whoLpnbxG3sh9CtUmZnb8+5GxfcIuS4C0R7GF/B4f7B2fOqhDXhBvl3eRf 9roRKLb/bn7O/izSQ1TtnsEP6bLUiRMze6gh9w3ZduMdyefkrJy9iKwTnuXVHhfbYCSOA k6NZxuEpDSVuxwxi+FEX8pYMIYOd3Eins1HgvDvCyVUPDhO2B5NXGWlsBOKjfNxcqPg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796165123; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=NMWQgIZZcbzCWanaLRqb3yye9wbVKfn4IfTtTs+IxSM=; b=THRrOkh3jgD6KIgjj4rKtd2AV60sD1Q4nrumR5Wzs6LZzP9Jli5oiTM0RWSrff1FT32M mMs5WdwHE/uHRQkiZNycESvHn6Q9zUGBNTQ8lPnoBYaKvKs7kWQeYiiNkxxe1AwjYi24p jTaf2DISboV/nrMMaBzlZYPWYlVBodLS0ByWaOt4SEOkhsJ9GZl5Qxzfnjmuvs1c/cvn1 vOkNnTOdn06dLxWO20XuLFIzisetkNPStrBgs4HU0jiDnpjsT8pAOSWmo7/9X8/a3gXrp LmGJhKmogVn2pwwOfwClIo/XMGggVwcBWyKZFa4Hc+hsBjAqA2EJk2vBPBtkF+ftZPQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EV2bFCBI; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6491D606A337; Tue, 1 Dec 2026 22:45:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EV2bFCBI Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94FD41F000C1; Tue, 1 Dec 2026 22:45:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796165123; bh=NMWQgIZZcbzCWanaLRqb3yye9wbVKfn4IfTtTs+IxSM=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=EV2bFCBIo0ToJm9bErx8pzXgRYtEdkpY4lQB0bK66VMDNSDI44uHghcHPgaZ9Ii7A nydx98mgOAEegim0kvRs3rMHRNySe0jgd70yyGN+jgZY7i1wC8hDK/msu42DofNJSq tXiaYfLfqT2JZ+jcwZse0xaR/FPhJwkDLq6QAqC4G8vbTN4G2PW3buZ8mvAmsiBe3K NTkpqIad88UHYYPq4HGFNIR/ixP6AW1zatj1SzdfSt1kXXEO1tmH01pPsBSGvttZKY A0Rl9ENP2Lb6RrerLzTpMn9h/Yhz4YWkJELWTdSwVEeJaakdasNUmRfAtVNQ6O3bKk wtwKizB0bTpyQ== Subject: Re: [PATCH net 06/10] netfilter: conntrack: limit master chain depth From: netdev-bot+sashiko@kernel.org To: pablo@netfilter.org Cc: netfilter-devel@vger.kernel.org, davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com, edumazet@kernel.org, horms@kernel.org, fw@strlen.de, ja@ssi.bg Date: Tue, 01 Dec 2026 22:45:22 +0000 Message-ID: <179616512219.3146.18170714509207765392@kernel.org> In-Reply-To: <20261130215141.1009148-7-pablo@netfilter.org> References: <20261130215141.1009148-7-pablo@netfilter.org> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin. Low priority / nit picks for your consideration: - [Low] This patch makes nf_ct_expect_alloc() return NULL for a permanent reason: nf_ct_master_acceptable(me) fails when the conntrack already… -- netfilter: conntrack: limit master chain depth This commit caps the ct->master chain depth at 8 levels. nf_ct_expect_alloc() now refuses to allocate an expectation once the master chain is too deep. A ctnetlink_find_get_master() helper performs the same check for ctnetlink conntrack and expectation creation, and returns -EMLINK. > diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c > index 06242c86e1dc8..62e434cd57c9f 100644 > --- a/net/netfilter/nf_conntrack_expect.c > +++ b/net/netfilter/nf_conntrack_expect.c > @@ -299,13 +299,22 @@ void nf_ct_unexpect_related(struct nf_conntrack_expect *exp) > } > EXPORT_SYMBOL_GPL(nf_ct_unexpect_related); > > -/* We don't increase the master conntrack refcount for non-fulfilled > - * conntracks. During the conntrack destruction, the expectations are > - * always killed before the conntrack itself */ > +/** > + * nf_ct_expect_alloc - allocate a new conntrack expectation > + * @me: The conntrack to be used as master. > + * > + * The master conntrack refcount is not incremented; expectations > + * are always killed before the master conntrack is destroyed. > + * > + * Return: a new expectation on success or NULL on failure. > + */ > struct nf_conntrack_expect *nf_ct_expect_alloc(struct nf_conn *me) > { > struct nf_conntrack_expect *new; > > + if (!nf_ct_master_acceptable(me)) > + return NULL; > + [Severity: Low] With this change, nf_ct_expect_alloc() also returns NULL for a permanent condition: the master already has 8 or more ancestors. Callers can't tell this apart from a transient GFP_ATOMIC failure, and the kernel-doc above still only says "NULL on failure". Every in-tree caller treats NULL as out of memory, and most of them drop the packet. For example, help() in nf_conntrack_ftp.c does this: exp = nf_ct_expect_alloc(ct); if (exp == NULL) { nf_ct_helper_log(skb, ct, "cannot alloc expectation"); ret = NF_DROP; Other callers follow the same pattern: - irc, tftp, amanda, sane and sip process_register_request() do the same thing. - sip set_expected_rtp_rtcp() jumps to err1 while ret is still NF_DROP. - The h323 expect_*() helpers, including expect_callforwarding(), return -1. That turns into goto drop / NF_DROP in q931_help(), h245_help() and ras_help(). nft_ct_expect_obj_eval() also drops here: exp = nf_ct_expect_alloc(ct); if (!exp) return NF_DROP; That function returns NF_ACCEPT when nf_ct_expect_related() fails. ct->master is fixed when the conntrack is created. Once a conntrack hits the depth limit, won't every packet that tries to create an expectation be dropped, retransmissions included? The commit message says this "restricts the number of call forward/redirects that h323 and sip helpers will follow". It looks like the 8th h323 call forward, or SIP SDP on a deeply nested ct, would break the session rather than the helper just not following it. The helper log would also report "cannot alloc expectation" as the reason. Separately, the commit message says: For too long chains, ctnetlink returns -ENOMEM when creating long master chains through expectations, ... Is that still accurate? ctnetlink_create_expect() now calls ctnetlink_find_get_master() first and returns -EMLINK in this case. Only the nfqueue glue path, ctnetlink_glue_attach_expect() -> ctnetlink_alloc_expect(), would still return -ENOMEM. > new = kmem_cache_zalloc(nf_ct_expect_cachep, GFP_ATOMIC); > if (!new) > return NULL; [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130215141.1009148-2-pablo%40netfilter.org