🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25498

Re: [PATCH net 06/10] netfilter: conntrack: limit master chain depth

#25498
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 22:45
108 lines
11790 bytes
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
Technical Details
Message-ID: <179616512219.3146.18170714509207765392@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375390-linux-kernel-netdev=dewy.ru
References: <20261130215141.1009148-7-pablo@netfilter.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-375390-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 06/10] netfilter: conntrack: limit master chain depth
Date: Tue, 01 Dec 2026 22:45:22 +0000
Organization: Usenet Network
Message-ID: <179616512219.3146.18170714509207765392@kernel.org>
References: <20261130215141.1009148-7-pablo@netfilter.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1835776"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:goheeRHAtHnhqd+l0SksrKaZBPc= sha256:nu3XuWmLpStyf1eyM6/77/ZjxjrQQ7YFcTOXDW9Ijk8=
	sha1:6iwWmEMXaSkhL72wbHCc0i0w198= sha256:XrLts4ISMe54NR2HtFxKVU7ub5wS/AMFFDAb9MR9HtA=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id B8B0B11747B; Wed,  2 Dec 2026 01:45:43 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id zWGSgDr1Y6SU;
	Wed,  2 Dec 2026 01:45:40 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-375390-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 2BCBA1174C5; Wed,  2 Dec 2026 01:45:29 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id B17942A741; Tue,  1 Dec 2026 22:45:26 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796165124;
	b=168uE2BdglV7IgAE1kN2uaFLxO2XxfpigYnOYE4B2n4Bf3Jem10aJhl3Ffun0zuLVpis
	 IaifkzMzw4cqp0II1DxvsbR+qkOxTC+e208KxKa8uPImQrg4K/qvt0DkPsYxTtw0pLJpy
	 ysTLNjWZbRW3lOg/Oich2VO8IR0eMnuINS535TAsaT3LkqrbXMxTwsjAR55mQAIo77N6u
	 oo+ngEpgZS2iSR2m3XAmzOGpZ1XxRlm9JXrlppt8KeSIbsWw8xIDjHVNiyvcaVIWQe8gZ
	 46tglp1a7CXuTzg7luyMRyLsyK77JMHKZIMVcp81gNfYJwNnc4W9KfDccOC817J/vGg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796165124;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=NMWQgIZZcbzCWanaLRqb3yye9wbVKfn4IfTtTs+IxSM=;
	b=UBgflQVCwBT23rO8hLapQqFEbFsaPxvWCoG/pEXxN0nQR6QvN0x92jG/Ayem60vj8zwc
	 ih8crrIaoFuPYtHwwiATGGNf+VJ5yneAEq3qeLzXI4G2vTea/ogw20r0QzE986kTNgqmx
	 buQSbm+Ag2oqR+hy+3C3enOUrjjcmEbwW4USdtXOjLmAO9ofulncSXROCUH0qKj9uP/bQ
	 BNTxbacLPVMQ5ehCeHgnKDv8k5/iZ7mNnegwhc9EaA76hpKe9eY3sDg3584xi2iLBnXvb
	 ZPMYCU3D7za2I9uw0SWV4jhB0MSC8BpNo2XLOz6LGgvlZHIjzAsLHsVuYdm0DiPPXLw==
X-ARC-Authentication-Results: i=2; 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=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 41A09606A323;
	Tue,  1 Dec 2026 22:45:24 +0000 (UTC)
X-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
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-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==
X-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==
X-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
X-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)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94FD41F000C1;
	Tue,  1 Dec 2026 22:45:22 +0000 (UTC)
X-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==
X-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
X-In-Reply-To: <20261130215141.1009148-7-pablo@netfilter.org>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list