All of lore.kernel.org
 help / color / mirror / Atom feed
From: Theodor Arsenij Larionov Trichkine <theodorlarionov@gmail.com>
To: "David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Florian Westphal <fw@strlen.de>, Phil Sutter <phil@nwl.cc>,
	netdev@vger.kernel.org, netfilter-devel@vger.kernel.org,
	coreteam@netfilter.org,
	Theodor Arsenij Larionov Trichkine <theodorlarionov@gmail.com>
Subject: [PATCH net v3 2/2] net: unset the mac header of a pskb copy that points into headroom
Date: Tue, 24 Nov 2026 19:33:58 +0300	[thread overview]
Message-ID: <20261124163358.755345-3-theodorlarionov@gmail.com> (raw)
In-Reply-To: <20261124163358.755345-1-theodorlarionov@gmail.com>

__pskb_copy_fclone() copies the data from skb->data onwards but keeps
the mac_header offset, so if the link-layer header was pulled, the
copy's mac header points into uninitialised headroom. With nft dup, a
link-layer payload load on the copy at LOCAL_OUT or POST_ROUTING reads
those bytes, and a set element hands them to userspace:

  BUG: KMSAN: kernel-infoleak in _copy_to_iter

Unset the mac header in that case. Callers that use the copy's mac
header push the link-layer header before copying, as
maybe_deliver_addr() in the bridge does, so the header is copied and
stays valid.

Depends on "netfilter: nf_dup: do not duplicate packets from
br_netfilter"; without it, a tcp reset reject of a bridged dup copy
reads out of bounds.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Suggested-by: Florian Westphal <fw@strlen.de>
Cc: stable@vger.kernel.org
Signed-off-by: Theodor Arsenij Larionov Trichkine <theodorlarionov@gmail.com>
---
 net/core/skbuff.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 85d5caa08887..e38d0de59e06 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2278,6 +2278,8 @@ struct sk_buff *__pskb_copy_fclone(struct sk_buff *skb, int headroom,
 	}
 
 	skb_copy_header(n, skb);
+	if (skb_mac_header_was_set(n) && skb_mac_offset(n) < 0)
+		skb_unset_mac_header(n);
 out:
 	return n;
 }
-- 
2.34.1


  parent reply	other threads:[~2026-11-24 16:34 UTC|newest]

Thread overview: 9+ 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
2026-11-26  7:47     ` Florian Westphal
2026-12-01  2:25       ` willemb
2026-12-01  9:27         ` Paolo Abeni
2026-12-01  9:33           ` Florian Westphal
2026-11-24 16:33 ` Theodor Arsenij Larionov Trichkine [this message]
2026-12-01  2:32   ` [PATCH net v3 2/2] net: unset the mac header of a pskb copy that points into headroom willemb

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=20261124163358.755345-3-theodorlarionov@gmail.com \
    --to=theodorlarionov@gmail.com \
    --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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.