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 v2 1/2] netfilter: nfnetlink_queue: only adjust bridged skbs that have a mac header
Date: Thu, 19 Nov 2026 06:00:22 +0000	[thread overview]
Message-ID: <179506802273.3136.14270280205910670302@kernel.org> (raw)
In-Reply-To: <20261117175835.745796-2-theodorlarionov@gmail.com>

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

Critical: 0 · High: 1 · 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] The series leaves an out-of-bounds read in nf_send_reset() and
  nf_send_reset6().
- [Low] The commit message and tags present this as a standalone fix for
  a live KASAN slab-out-of-bounds bug, with `Fixes: a5fedd43d5f6` and…

--

netfilter: nfnetlink_queue: only adjust bridged skbs that have a mac header

This patch makes nf_bridge_adjust_skb_data() and
nf_bridge_adjust_segmented_data() skip the push/pull of
skb_mac_header_len() bytes when the skb has no mac header set. It is
groundwork for the next patch in the series, which unsets the mac header
of a pskb copy that points into headroom.

> Fixes: a5fedd43d5f6 ("netfilter: move skb_gso_segment into nfnetlink_queue module")
> Cc: stable@vger.kernel.org

[Severity: Low]
Is this Fixes tag accurate for this patch on its own? The commit message
says the trigger only shows up once the next patch is applied:

> A pskb copy of a bridged packet, such as one made by nft dup,
> keeps that info, and the next patch unsets its mac header.

Before that patch, a pskb copy keeps the original mac_header offset. So
skb_mac_header_was_set() is true and skb_mac_header_len() does not
underflow in nf_bridge_adjust_skb_data().

The next patch ("net: unset the mac header of a pskb copy that points into
headroom") has Fixes: 1da177e4c3f4 and no dependency note. A backport of
that patch alone would bring in the KASAN splat this patch prevents.

Could the commit message say this is a prerequisite for the following
patch? Or could the stable tag on the next patch list this one as a
dependency?

> diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
> index a8aa7ad832c3f..fafadd9057cf7 100644
> --- a/net/netfilter/nfnetlink_queue.c
> +++ b/net/netfilter/nfnetlink_queue.c
> @@ -1084,13 +1084,13 @@ nf_queue_entry_dup(struct nf_queue_entry *e)
>   */
>  static void nf_bridge_adjust_skb_data(struct sk_buff *skb)
>  {
> -	if (nf_bridge_info_get(skb))
> +	if (nf_bridge_info_get(skb) && skb_mac_header_was_set(skb))
>  		__skb_push(skb, skb_mac_header_len(skb));
>  }
>
>  static void nf_bridge_adjust_segmented_data(struct sk_buff *skb)
>  {
> -	if (nf_bridge_info_get(skb))
> +	if (nf_bridge_info_get(skb) && skb_mac_header_was_set(skb))
>  		__skb_pull(skb, skb_mac_header_len(skb));
>  }

[Severity: High]
This patch only guards these two nfnetlink_queue helpers. Do other users
also trust the mac header whenever nf_bridge info is present?

nf_send_reset() in net/ipv4/netfilter/nf_reject_ipv4.c does this:

	if (nf_bridge_info_exists(oldskb)) {
		struct ethhdr *oeth = eth_hdr(oldskb);
		...
		if (dev_hard_header(nskb, nskb->dev, ntohs(nskb->protocol),
				    oeth->h_source, oeth->h_dest, nskb->len) < 0)

It never calls skb_mac_header_was_set(). nf_send_reset6() in
net/ipv6/netfilter/nf_reject_ipv6.c has the same code.

With the next patch applied, it looks like this path can be reached:

1. Bridged IPv4 or IPv6 traffic passes ip/ip6 PREROUTING or FORWARD
   through br_netfilter. At that point skb->data is at the network header,
   so skb_mac_offset() < 0.

2. A TEE or nft dup rule calls nf_dup_ipv4() or nf_dup_ipv6(), which call
   pskb_copy(). Then __copy_skb_header()->__skb_ext_copy() keeps
   SKB_EXT_BRIDGE_NF on the copy, and after the next patch the copy's
   mac_header is 0xffff.

3. The copy goes through ip_local_out() or ip6_local_out() and the
   LOCAL_OUT hook.

4. An OUTPUT rule "REJECT --reject-with tcp-reset" (or nft "reject with
   tcp reset") matches the copy. nf_reject_ip_tcphdr_get() only checks
   frag offset, protocol, RST and checksum, so the copy passes.

5. nf_bridge_info_exists() is true, so eth_hdr(oldskb) returns
   skb->head + 65535.

dev_hard_header() then copies 12 bytes from that address into the RST's
Ethernet header. The RST goes out the physical input port.

Can this read past the buffer and send those kernel bytes onto the wire?
Before the series this path read uninitialized headroom inside the buffer.
With the series applied, it reads past the end of the buffer.

Would it be more robust to drop SKB_EXT_BRIDGE_NF from the copy in the
dup path? For example, call skb_ext_del(skb, SKB_EXT_BRIDGE_NF) after
pskb_copy() in nf_dup_ipv4() and nf_dup_ipv6().

The copy is a locally routed L3 packet, so its br_netfilter state has no
meaning there. That would cover every user and make the per-user guards
unnecessary. If not, nf_send_reset() and nf_send_reset6() would need the
same skb_mac_header_was_set() check.

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

  reply	other threads:[~2026-11-19  6:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 17:58 [PATCH net v2 0/2] net: do not point a pskb copy's mac header into uninitialised headroom Theodor Arsenij Larionov Trichkine
2026-11-17 17:58 ` [PATCH net v2 1/2] netfilter: nfnetlink_queue: only adjust bridged skbs that have a mac header Theodor Arsenij Larionov Trichkine
2026-11-19  6:00   ` netdev-bot+sashiko [this message]
2026-11-17 17:58 ` [PATCH net v2 2/2] net: unset the mac header of a pskb copy that points into headroom Theodor Arsenij Larionov Trichkine
2026-11-19  6:00   ` netdev-bot+sashiko
2026-11-19  8:48     ` Florian Westphal
2026-11-17 18:03 ` [PATCH net v2 0/2] net: do not point a pskb copy's mac header into uninitialised headroom netdev-bot+sinfo

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=179506802273.3136.14270280205910670302@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