From mboxrd@z Thu Jan 1 00:00:00 1970 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=1796165124; b=WyXaHRrbIDeVC4LBn46qfEAsLdl+DP7ZiFP9+1KgeDPpKSQIe1CzyHW1p+VZrWvcMH26 eBldPrzIn2a6LcytHdpQzcARrUVm63/aDNkbb2XNM/+1t5Ax8fCpNLyflbMnYW6zmcurH /M5VscNiPHtOdm1u+R8dCw02UZkSkuQDfUVCcCXQcA2G/ODO91bIVUHY3F5zjfrC12T1z DgznHBC1BVnyqN97xVZKZ2711FdF1Y+kQWIi5CXeeP+0HyrIaHBNmrFF0+kFMEDfDANED AbO6H7aP2kfKX8kCyA9CRMOFjhbSg4NlYY9X8KaOTTiU/pJ4k9qhWGzucPpdds83c3Q== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7FB41F00893; Tue, 1 Dec 2026 22:45:23 +0000 (UTC) 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== Subject: Re: [PATCH net 08/10] netfilter: bridge: detach conntrack template on invalid IP frames 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:23 +0000 Message-ID: <179616512327.3146.16191156456927532457@kernel.org> In-Reply-To: <20261130215141.1009148-9-pablo@netfilter.org> References: <20261130215141.1009148-9-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] 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