Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: theodorlarionov@gmail.com
Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, pablo@netfilter.org,
	fw@strlen.de, phil@nwl.cc, netdev@vger.kernel.org,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org
Subject: Re: [PATCH net v3 1/2] netfilter: nf_dup: do not duplicate packets from br_netfilter
Date: Thu, 26 Nov 2026 07:35:14 +0000	[thread overview]
Message-ID: <179567851468.3135.1445286719198754408@kernel.org> (raw)
In-Reply-To: <20261124163358.755345-2-theodorlarionov@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

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).

- [Medium] nf_dup_ipv4() and nf_dup_ipv6() now return early, doing
  nothing, for every skb that carries SKB_EXT_BRIDGE_NF.

--

netfilter: nf_dup: do not duplicate packets from br_netfilter

This commit makes nf_dup_ipv4() and nf_dup_ipv6() return early when the
skb carries bridge netfilter info. It does this to avoid a KMSAN infoleak.
The leak happens when a tcp reset reject of the pskb_copy() duplicate takes
the bridge path in nf_send_reset() or nf_send_reset6() and builds the
Ethernet header from uninitialised headroom.

> diff --git a/net/ipv4/netfilter/nf_dup_ipv4.c b/net/ipv4/netfilter/nf_dup_ipv4.c
> index 9a773502f10ac..a4ad26a564a46 100644
> --- a/net/ipv4/netfilter/nf_dup_ipv4.c
> +++ b/net/ipv4/netfilter/nf_dup_ipv4.c

[ ... ]

> @@ -53,6 +54,11 @@ void nf_dup_ipv4(struct net *net, struct sk_buff *skb, unsigned int hooknum,
>  {
>  	struct iphdr *iph;
>  
> +#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
> +	if (nf_bridge_info_exists(skb))
> +		return;
> +#endif
> +

[Severity: Medium]
Does this turn off TEE and nft dup completely for any packet that has
passed through br_netfilter?

The check runs on the original skb before pskb_copy(). With
bridge-nf-call-iptables or bridge-nf-call-ip6tables enabled, a rule like
this one no longer sends any copy:

  iptables -t mangle -A PREROUTING -m physdev --physdev-in X \
           -j TEE --gateway G

The same applies to packets that enter on a bridge port and are then routed
or delivered locally. That is common on container and VM hosts.

Nothing reports the skip. Both functions return void, and the xt_TEE
callers always continue:

net/netfilter/xt_TEE.c:tee_tg4() {
	...
	nf_dup_ipv4(xt_net(par), skb, xt_hooknum(par), &info->gw.in, oif);

	return XT_CONTINUE;
}

So the rule still matches and its counters still go up, but no copy is
sent. Because of Cc: stable, this change would also reach stable trees.

The commit message mentions the routed and local delivery side effect. It
does not say that mirroring of bridged traffic stops completely.

Would it work to remove the extension from the copy instead? For example,
call skb_ext_del() with SKB_EXT_BRIDGE_NF on the new skb right after
pskb_copy().

nf_dup_ipv4_route() gives the duplicate its own dst and dev, and
ip_local_out() sends it, so the bridge info it inherits is stale. Both
reject paths choose the bridge path only by checking for the extension:

net/ipv4/netfilter/nf_reject_ipv4.c:nf_send_reset() {
	...
	if (nf_bridge_info_exists(oldskb)) {
		struct ethhdr *oeth = eth_hdr(oldskb);
	...
}

nf_send_reset6() has the same check.

Without the extension, a reject of the copy would go down the normal
ip_local_out() or ip6_local_out() path. Physdev and other bridge info users
would also stop seeing the original's ports on the copy. Dup would keep
working for bridged traffic.

The later patch in this series, "net: unset the mac header of a pskb copy
that points into headroom", relies on this skip to avoid an out-of-bounds
eth_hdr() read in the reject bridge path. Would removing the extension from
the copy also meet that need?

The same question applies to the identical check added to nf_dup_ipv6().

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124163358.755345-1-theodorlarionov%40gmail.com

  reply	other threads:[~2026-11-26  7:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 16:33 [PATCH net v3 0/2] net: do not point a pskb copy's mac header into uninitialised headroom Theodor Arsenij Larionov Trichkine
2026-11-24 16:33 ` [PATCH net v3 1/2] netfilter: nf_dup: do not duplicate packets from br_netfilter Theodor Arsenij Larionov Trichkine
2026-11-26  7:35   ` netdev-bot+sashiko [this message]
2026-11-26  7:47     ` Florian Westphal
2026-11-24 16:33 ` [PATCH net v3 2/2] net: unset the mac header of a pskb copy that points into headroom Theodor Arsenij Larionov Trichkine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179567851468.3135.1445286719198754408@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=phil@nwl.cc \
    --cc=theodorlarionov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox