๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #21857

Re: [PATCH net-next 04/15] netfilter: conntrack: verify L4 protocol before calling helper

#21857
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 14:39
183 lines
14987 bytes
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.

Critical: 0 ยท High: 2 ยท Medium: 0 ยท Low: 1

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] This patch breaks the H.245 helper on the normal netfilter path,
  which breaks H.323 media tracking and NAT.
- [High] nft_ct_expect_helper_alloc() now sets the internal helper's
  l4proto to `priv->l4proto` (NFTA_CT_EXPECT_L4PROTO).
- [Low] The commit message does not fully describe the behaviour change.

--

netfilter: conntrack: verify L4 protocol before calling helper

This commit makes nf_ct_call_helper() skip the assigned conntrack helper
when the packet's L4 protocol does not match helper->l4proto. It also
skips IPv4 fragments and packets with no L4 payload. It sets l4proto on
the internal helper that nft_ct expectation objects allocate.

> diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
> index 32f900c155de8..18125aa29e0d0 100644
> --- a/net/netfilter/nf_conntrack_proto.c
> +++ b/net/netfilter/nf_conntrack_proto.c
> @@ -134,21 +134,23 @@ static bool in_vrf_postrouting(const struct nf_hook_state *state)

[ ... ]

>  	case NFPROTO_IPV6:
> -		pnum = ipv6_hdr(skb)->nexthdr;
> -		start = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &pnum, &frag_off);
> -		if (start < 0 || (frag_off & htons(~0x7)) != 0)
> +		*pnum = ipv6_hdr(skb)->nexthdr;
> +		start = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), pnum, &frag_off);
> +		if (start < 0 || frag_off)
>  			return false;

[Severity: Low]
This isn't a bug, but the commit message only mentions IPv4:

  Also change ipv4 to explicitly skip frasgments, this shouldn't happen
  for normal netfilter-only code path, ...

The IPv6 check in nf_confirm_get_protoff() changes too. ipv6_skip_exthdr()
returns the raw frag_off field, including the M bit and the reserved
bits. So the new check also rejects first fragments (offset 0, M=1) and
atomic fragments with reserved bits set. Before, both of those still
went through the helper and seqadj.

The new check also no longer matches the unchanged IPv6 check in
nf_ct_helper() in nf_conntrack_ovs.c.

Could the commit message mention the IPv6 change as well?

The commit message also says:

  or when conntrack got attached via TC/act_ct, then was later munged via
  act_pipe to alter the ip protocol.

There doesn't seem to be an act_pipe tc action. Should this say
pedit/bpf, like the new comment above nf_ct_call_helper()? Also, there's
a typo (frasgments).

[ ... ]

> @@ -204,6 +210,9 @@ int nf_ct_call_helper(struct sk_buff *skb, struct nf_conn *ct,
>  		/* rcu_read_lock()ed by nf_hook */
>  		helper = rcu_dereference(help->helper);
>  		if (helper) {
> +			if (helper->l4proto != pnum)
> +				return NF_ACCEPT;
> +

[Severity: High]
Does this guard break the H.245 helper on the normal netfilter path?

h323_helper_init() in nf_conntrack_h323_main.c registers H.245 as a UDP
helper:

	nf_ct_helper_init(&nf_conntrack_helper_h245, AF_UNSPEC, IPPROTO_UDP,
			  "H.245",
			  &h245_exp_policy, 0, h245_help, NULL, THIS_MODULE);

However, expect_h245() creates a TCP expectation and assigns that helper
to the TCP child conntrack:

	nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, nf_ct_l3num(ct),
			  &ct->tuplehash[!dir].tuple.src.u3,
			  &ct->tuplehash[!dir].tuple.dst.u3,
			  IPPROTO_TCP, NULL, &port);
	rcu_assign_pointer(exp->assign_helper, nf_conntrack_helper_h245_ptr);

h245_help() also parses TCP: get_tpkt_data() reads a struct tcphdr at
protoff.

With this patch, every H.245 packet takes this path:

q931_help()->expect_h245()   (TCP expectation, H.245 helper)
nf_confirm()->nf_ct_call_helper()
    nf_confirm_get_protoff() sets pnum = IPPROTO_TCP
    helper->l4proto (IPPROTO_UDP) != pnum -> return NF_ACCEPT

As a result h245_help() never runs. No RTP/RTCP/T.120 expectations are
created and the H.245 NAT payload rewrite is skipped. Wouldn't H.323
calls through an iptables/nftables conntrack/NAT box lose their media?

Before this patch nf_confirm() didn't check the protocol. Only the
nf_ct_helper() path used by OVS/act_ct had this check. This still seems
to be the case at the end of the series.

Should the H.245 helper be registered with IPPROTO_TCP as part of this
change? This matters more because the Fixes: tag makes the patch a
stable candidate on its own.

>  			helper_cb = rcu_dereference(helper->help);
>  			if (helper_cb) {
>  				ret = helper_cb(skb, protoff,
> diff --git a/net/netfilter/nft_ct.c b/net/netfilter/nft_ct.c
> index 5a8db55920364..58846bc405b7e 100644
> --- a/net/netfilter/nft_ct.c
> +++ b/net/netfilter/nft_ct.c
> @@ -1307,6 +1307,7 @@ static int nft_ct_expect_helper_alloc(struct nft_ct_expect_obj *priv)
>  		 "nft_ct_expect");
>  	ct_expect_helper->me = THIS_MODULE;
>  	ct_expect_helper->expect_policy[NF_CT_EXPECT_CLASS_DEFAULT].max_expected = priv->size;
> +	ct_expect_helper->l4proto = priv->l4proto;

[Severity: High]
Is priv->l4proto the right value to store here?

In the expectation object, l4proto is the protocol of the expected child
connection. ct_expect_help() passes it as the protocol of the
expectation tuple:

	nf_ct_expect_init(exp, NF_CT_EXPECT_CLASS_DEFAULT, l3num,
			  &ct->tuplehash[!dir].tuple.src.u3,
			  &ct->tuplehash[!dir].tuple.dst.u3,
			  expect_data->obj.l4proto, NULL, &expect_data->obj.dport);

The new guard in nf_ct_call_helper() compares helper->l4proto with the
L4 protocol of the master connection that the helper is attached to.

nft_ct_expect_obj_eval() attaches the helper to any unconfirmed
conntrack. Unlike nft_ct_helper_obj_eval(), it doesn't check
nf_ct_protonum(ct) against priv->l4proto:

	if (help && refcount_inc_not_zero(&priv->helper->ct_refcnt))
		rcu_assign_pointer(help->helper, priv->helper);

The nft documentation shows a TCP control connection with a UDP
expectation:

  ct state new tcp dport 8888 ct expectation set "expect"

Here the expectation object uses "protocol udp". So pnum is IPPROTO_TCP
and helper->l4proto is IPPROTO_UDP. ct_expect_help() never runs and no
expectation is created. Nothing reports an error, either at rule load
or at runtime.

Before this patch, helper->l4proto was 0 from kzalloc and nf_confirm()
didn't check it, so expectations with a different protocol than the
master worked. The code is still unchanged at the end of the series.

Could the check use the master connection's protocol for this helper
instead? Another option is to reject the mismatch in
nft_ct_expect_obj_eval().

A smaller point: the l4proto field comment in struct
nf_conntrack_helper says IPPROTO_UDP/TCP, but this assignment can now
store DCCP or SCTP.

>  	rcu_assign_pointer(ct_expect_helper->help, ct_expect_help);
>  	refcount_set(&ct_expect_helper->ct_refcnt, 1);

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261123135726.3940688-2-pablo%40netfilter.org
Technical Details
Message-ID: <179553117201.3135.14194838592566427007@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370461-linux-kernel-netdev=dewy.ru
References: <20261123135726.3940688-5-pablo@netfilter.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-370461-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next 04/15] netfilter: conntrack: verify L4 protocol
 before calling helper
Date: Tue, 24 Nov 2026 14:39:32 +0000
Organization: Usenet Network
Message-ID: <179553117201.3135.14194838592566427007@kernel.org>
References: <20261123135726.3940688-5-pablo@netfilter.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="4159537"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:sbFEA116XE/w44RkjqdRRXFSJTY= sha256:X675zm3ID8QmSnjcNS12GXg0V3Pg6Hevw8kPrc44leo=
	sha1:eW2tyqFRvQzUDhEKR+8jIG0QxKQ= sha256:7i1lAUDW24hV+3s+xTVY44XQuyIn7nD/WLCJHGkqKrA=
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 0BED4125E1A; Tue, 24 Nov 2026 17:39:52 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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] 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 zDw81wXcO3Hb;
	Tue, 24 Nov 2026 17:39:48 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-370461-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 826ED125E1B; Tue, 24 Nov 2026 17:39:38 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id C898427E56; Tue, 24 Nov 2026 14:39:35 +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=1795531174;
	b=1iLCiMPynGM3Hdlsbjd3D30CyuxANZK8QZRujOXDJlhlhmYCC82LWyrZV0JSd1eNW/ck
	 lBkcJQzCoFRS0176LKtveovUqKExPQuxveFMo37PVjgq4KGbA2Y1x49DPrG2lsGv+udGD
	 sjPQJO/KtwojuuVkc893ymJiHD3lA+8sIigS4t+mkQFZQRwf7GzO2RiHFVQmsFtf5/Tu3
	 eQJfH1ix6vzcKswuBM6cPYekbz9CZDXn1lA4V5MuLUDBXHytGLyWZLrBrS58Y2QxA8g5p
	 +8JwJ+ysmdLfF/1hXLCE75Db+2pNdxH7Oo/S8sio68J5F1RFiBM8AuocT+o+p21jHfQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795531174;
	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=z8v4NCeWFM6qc5ofwBJn2Izk3HxJydkFDGFRVXGG0p8=;
	b=3iYyIacFX3P0q7u84v4ZkIxDxSL6IcvJ7pZ6ZlwrK3hPNZI6gjasr64YaVO/Kms69lIT
	 8hGsPz7PLZLwY1AM87G3kAKlknVplL+5Btp8foVAgT/f9UtjqZHIQWOtT2ZlL0F/h22Ey
	 AW3GjiyVffH2JXL/oMl/cJ4A7bmbC7aiX3feIGkkbYfDVhHrkUzDB0ZOIosvDpAg7Otak
	 wgQ32flEHQUKkugSuZC8g0G3CaS7LKwXO6qhHECG/sKdv7isGPSHWmD4ZsKPs7ouW7mdI
	 dXuvXJSp3ymFxT6UE8HEa8hd/msMyvP/Fabu6Xw4k3riUUBSM7vSHWkL+dhkkopk1Pw==
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=bt94r4dJ;
	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 3E4E2606A334;
	Tue, 24 Nov 2026 14:39:34 +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=bt94r4dJ
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=1795531173;
	b=LPMtVl1zovNzohFlOmLuEhj2MA2FAgEa/pmQMOn3AwjusvC+FAR6DpIZlQoLMezarFnf
	 ozqAwyTvGxrSX5IG3cIOKQnY50mivvVpxU0TZ7Vco4UqrpXOwzD65WkS2vvLGQPGGQvRH
	 rvoqvSfj5X2cR5GJ/NRJMNixl3evmNYT7ODU+jx+HsV7eSseTZHLa2oVFhzf+vHZH2kMA
	 vKh/3c+g+sd6eAQN8bRY3ou+dPMUzOZlbzrwFUhxsqiJUC07P+xKqra5m92DqZto8ELKj
	 r0GT++9sYjqCEs/+6SnMbk0Xo1hB40xeycDl1UztH83Qn3Gqr/SqhKh1oPVLpmkyxNA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1795531173;
	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=z8v4NCeWFM6qc5ofwBJn2Izk3HxJydkFDGFRVXGG0p8=;
	b=Wb7BTQJQoIpvd471MGNfsULoDixlkddiA94/4ChGBlZbXePqt7gL0LhST6kgRuYT2MSF
	 PTaPGmnaZbP9O2rqRzFHeNEe22uY2bTOCEpzJ+mHh0ZJNxbgmPsoqW+u4FFBey5yVtZ0D
	 sEr6KGK6ujKUzXaSdeP65ry1SPHce2dw1lpZY0hqKWxoCGhHQTrwRc4Qrnhugy9RzAIic
	 me1OPYckEABD8+RLzUH9u092kRUBKPd7vM8ka/izouskMxSNPi58Atw2I0IaGIqyVoSMJ
	 gSHp25xmDkWWT9F3EUO+NEP85hxjkpIjbNsJOMlOvtDlZyGseuTCI0mC3PYTaHkQkiw==
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=bt94r4dJ;
	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 5F992606A329;
	Tue, 24 Nov 2026 14:39:33 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D3061F000D2;
	Tue, 24 Nov 2026 14:39:32 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1795531172;
	bh=z8v4NCeWFM6qc5ofwBJn2Izk3HxJydkFDGFRVXGG0p8=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=bt94r4dJe9Wuy1mJTKUxz+6anRZR0AS/CjF3d4YhvOc47Y3nuq0PV1kMOUUROb+hp
	 jaoweIZP/6T6ewQzBMehUU2Iy6VwzPoKoHVMmL6++H8f19vHR3ZVRzdMCX9f+/2sjz
	 jM03k2XcIYXAYd8KHdcxmUoJbDxbOeXK9PCFvleP28yHSaV1IcrayvtiXziXGAusXf
	 4lJAuxV1BLwDLI2HjFZOIMhWOiLgjqFXwLhhmiYnfhapb4ySntFWmMQ5YlLeswhX9e
	 MMM5h8Y17T0EIBaElyxJBU6lnip64o/Z0mJ7Z15kvlFP5nshGFsngD/HqXH2/LkM8k
	 UV+oQCre94Rfw==
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: <20261123135726.3940688-5-pablo@netfilter.org>
X-sashiko-severity: High
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