πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25497

Re: [PATCH net 08/10] netfilter: bridge: detach conntrack template on invalid IP frames

#25497
From: netdev-bot+sashiko
Date: Tue, 01 Dec 2026 22:45
109 lines
11673 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] In nf_ct_bridge_pre()
  (net/bridge/netfilter/nf_conntrack_bridge.c), the patch changes the…

--

netfilter: bridge: detach conntrack template on invalid IP frames

This makes nf_ct_bridge_pre() jump to a shared error path when the IPv4
or IPv6 header pull or validation checks fail. That path calls
nf_reset_ct(), so a conntrack template attached by an earlier bridge rule
is released and the frame is treated as ct state invalid. The patch also
changes a failed pskb_trim_rcsum() to return NF_DROP instead of NF_ACCEPT.

Closes: https://sashiko.dev/#/patchset/3cf187b612fd78f8835fa9dad870326ce380f82f.1785479514.git.zhilinz@nebusec.ai

> diff --git a/net/bridge/netfilter/nf_conntrack_bridge.c b/net/bridge/netfilter/nf_conntrack_bridge.c
> index 8c83dc05114ba..aa1e01213e842 100644
> --- a/net/bridge/netfilter/nf_conntrack_bridge.c
> +++ b/net/bridge/netfilter/nf_conntrack_bridge.c
> @@ -257,28 +257,28 @@ static unsigned int nf_ct_bridge_pre(void *priv, struct sk_buff *skb,
>  	switch (skb->protocol) {
>  	case htons(ETH_P_IP):
>  		if (!pskb_may_pull(skb, sizeof(struct iphdr)))
> -			return NF_ACCEPT;
> +			goto invalid;
>  
>  		len = skb_ip_totlen(skb);
>  		if (pskb_trim_rcsum(skb, len))
> -			return NF_ACCEPT;
> +			return NF_DROP;

[Severity: Low]

The commit message says:

  [ While at it, drop packet if pskb_trim_rcsum() fails, when memory is
    exhausted. --pablo ]

Is memory exhaustion the only way this call can fail? For a
CHECKSUM_PARTIAL skb, pskb_trim_rcsum_slow() can return -EINVAL without
allocating anything:

net/core/skbuff.c:pskb_trim_rcsum_slow() {
    ...
	} else if (skb->ip_summed == CHECKSUM_PARTIAL) {
		int hdlen = (len > skb_headlen(skb)) ? skb_headlen(skb) : len;
		int offset = skb_checksum_start_offset(skb) + skb->csum_offset;

		if (offset + sizeof(__sum16) > hdlen)
			return -EINVAL;
	}
    ...
}

pskb_trim_rcsum_complete() can also return -EFAULT. This happens for
CHECKSUM_COMPLETE skbs with unreadable frags when len > skb_headlen(skb).

Both failures come from packet contents and layout, not from memory
pressure.

Here, len comes straight from the unvalidated iph->tot_len, or from
payload_len on the IPv6 path. nf_ct_br_ip_check() and
nf_ct_br_ipv6_check() have not checked it yet. So can the same malformed
header now get a different verdict depending on skb->ip_summed?

Take a bridged non-GSO IPv4 frame whose tot_len is smaller than ihl * 4:

  CHECKSUM_PARTIAL:
    pskb_trim_rcsum() -> pskb_trim_rcsum_slow() returns -EINVAL
    -> NF_DROP

  CHECKSUM_NONE / CHECKSUM_UNNECESSARY:
    pskb_trim_rcsum() succeeds
    nf_ct_br_ip_check() fails -> goto invalid
    -> nf_reset_ct(), NF_ACCEPT

A tap or veth sender can produce such CHECKSUM_PARTIAL frames by using a
virtio_net_hdr with NEEDS_CSUM. The IPv6 trim path has the same ordering.

The commit body also says the shared error path covers "all IPv4 and
IPv6 header/length rejection paths". The two trim-failure paths don't
take it. With Cc: stable, frames in these cases that used to be bridged
are now dropped.

Dropping on trim failure matches ip_rcv_core() and br_validate_ipv4().
Both drop on any pskb_trim_rcsum() failure, so well-formed traffic should
not be affected.

Could the note be updated to cover these non-ENOMEM failures? Another
option would be to run the header/length checks before the trim. Then
every malformed header reaches the invalid label, and NF_DROP is kept for
real trim failures.

>  
>  		if (nf_ct_br_ip_check(skb))
> -			return NF_ACCEPT;
> +			goto invalid;

[ ... ]

-- 
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130215141.1009148-2-pablo%40netfilter.org
Technical Details
Message-ID: <179616512327.3146.16191156456927532457@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-375391-linux-kernel-netdev=dewy.ru
References: <20261130215141.1009148-9-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-375391-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 08/10] netfilter: bridge: detach conntrack template on
 invalid IP frames
Date: Tue, 01 Dec 2026 22:45:23 +0000
Organization: Usenet Network
Message-ID: <179616512327.3146.16191156456927532457@kernel.org>
References: <20261130215141.1009148-9-pablo@netfilter.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1835725"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:7Sp0dQ2J7pNvyKjyn2w2VukgQ40= sha256:2jEPg7zg3sqHtPoQLDa70Q+bVuff1SQbNr8YyerhVWs=
	sha1:xn/Hc2rAuWCilGH+M4BG2W48lyQ= sha256:Mgp/6Rp0ezwnij4Ivf9m4DilsIQaObvt0Fqf8B40A6k=
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 08B7B1174C9; Wed,  2 Dec 2026 01:45:41 +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 DsdjRf6Osc5Y;
	Wed,  2 Dec 2026 01:45:37 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-375391-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 9EA2E11747B; 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 sto.lore.kernel.org (Postfix) with ESMTP id DBF84603618; Tue,  1 Dec 2026 22:45:28 +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=1796165125;
	b=kIRS2h4wqieHRvfNe2blAnJKvFdp545vWKV2EWmb43o9mLdy5vHVBUgOjzhWe3mZWNts
	 5D1OW9mWK5MbvwtNvAx5uYkni9Vldx8ds0QYoqb0HJMqhK6SQAfssIQbNVipgI4VOZ+Hi
	 Mh2jJ+/QeCRJ9r5mP3B4zZ5RZ9N+3NHlqu0zIk7FihETSmo0fqd82NqGG2+3B3Kh/Z1HD
	 paEa409XTrOHfD6FKXQgQ4WhwzYK3I1U5AWiMv9kh8IZQ/4Ov4vxv+kMMjDW8cgLF5cyf
	 o4lzCxSJLB2h8BZQ9HxnndDZkFH/uPlysd91j7cf6fKV+Med8wIXhXQ3eckiV4oRsDw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796165125;
	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=zOlu+XhqF9s8OUDtVtxg5E3OqDWeITGELmAdRGqDlC4=;
	b=jRMN2oA9oYwRi0TbMbYX9adHHGdzvEk38hSb5bTXp0J/S3XjSf2O35tf8aD+4SW/dpgM
	 BZ5bxIm/0bT1zKARFyVN6/9xC/GhBvE5GOruXAutzw4S6rO77OgCOrovj5e5zlpfCVLUT
	 T14l/5j3ENTPqt7plMjuHL/m35+uyHkTzu+BmwcrZA98xbA1YLoJaIIgeztkiWOkJpX1J
	 TIzzi0Hz5A0cwCye4F46wYsD+f+GQk+VEcHKe+9KmPmRr0bFIVBMnBvdMFzqkALS0h5oW
	 oR0Eumjab6JuBzNJvr0g0bjqTxYr22Z0EadPZ1OxnqV3aIa890yLg9UhK93rvznXyFQ==
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=hsf+DAg9;
	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 2E9C2606A338;
	Tue,  1 Dec 2026 22:45:25 +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=hsf+DAg9
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=1796165124;
	b=WyXaHRrbIDeVC4LBn46qfEAsLdl+DP7ZiFP9+1KgeDPpKSQIe1CzyHW1p+VZrWvcMH26
	 eBldPrzIn2a6LcytHdpQzcARrUVm63/aDNkbb2XNM/+1t5Ax8fCpNLyflbMnYW6zmcurH
	 /M5VscNiPHtOdm1u+R8dCw02UZkSkuQDfUVCcCXQcA2G/ODO91bIVUHY3F5zjfrC12T1z
	 DgznHBC1BVnyqN97xVZKZ2711FdF1Y+kQWIi5CXeeP+0HyrIaHBNmrFF0+kFMEDfDANED
	 AbO6H7aP2kfKX8kCyA9CRMOFjhbSg4NlYY9X8KaOTTiU/pJ4k9qhWGzucPpdds83c3Q==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796165124;
	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=zOlu+XhqF9s8OUDtVtxg5E3OqDWeITGELmAdRGqDlC4=;
	b=swJWnCelzIySYYw5Mae6wQbdbjcnW1m36V8ovy9GJs94qyE3fLfE0mA35VtjoVWz67In
	 UZMrlB4oO6SQkXfuYdzCxia0skQ6wwFAE0yONcmmgSoo+h2ylveJ8Uf0VXGnFHQfu26zV
	 IY6e1wvah8AokwM/4fwOid1piZmTmPEGjjLHPM7O6C+CSWTwaRJAnSkBQ6jfddktK9Vcz
	 FIY19c8jpguRNBnXqncaRxI4m8MzooDGLCCoeuu/S/m58PYRp3MkSPhbNGX9p1ktPI6kH
	 DEFwB9T/FVX+ViQe2HIZ1Yt6CdiMRWt/Lu85U/CkJPYAT5nSt9UgWLGFwDeDXUCldWA==
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=hsf+DAg9;
	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 4F21B606A320;
	Tue,  1 Dec 2026 22:45:24 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7FB41F00893;
	Tue,  1 Dec 2026 22:45:23 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796165124;
	bh=zOlu+XhqF9s8OUDtVtxg5E3OqDWeITGELmAdRGqDlC4=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=hsf+DAg9WPTXjAL0g2E39IK3+MXt0KyrB0MnqYZVfh4pWK+HfkyXLa7wh1rPWFloA
	 aKpoY/KZVEUM39s/dtYuho+WcQXp0nk9SjUCfUpdMOz9dH5685wtOH8rHZ6BD00+KQ
	 CLpKrvFFxfLAPVThACO2fzN+qbqssVGpg19W1Qc9YT4SnZsMxjSSXctWs3ZrpkkeDK
	 IiXPCoyLLfNVhiYQDkSgudXBMjQetV1wk+LlgpzupQhsG7EaBaTJ3Jo0j4P5g0gcCQ
	 ML/nRlvIUvXxf8eli6yu1BZ4vBB37qp5ujGIu462pR3t6RxHe8hf2nL5UQc2x2DnAV
	 ld00MdBYScoBQ==
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-9-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