Netdev List
 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 0/2] net: do not point a pskb copy's mac header into uninitialised headroom
Date: Tue, 24 Nov 2026 19:33:56 +0300	[thread overview]
Message-ID: <20261124163358.755345-1-theodorlarionov@gmail.com> (raw)

pskb_copy() keeps the mac_header offset but not the headroom, so the mac
header of a copy of a received packet points at uninitialised memory,
which nft dup can hand to userspace. Patch 2 unsets the mac header in
that case, as Florian suggested on v1.

Patch 1 makes nf_dup skip skbs with bridge netfilter info, as Florian
suggested on v2. It fixes a second leak, where a tcp reset reject of
such a copy builds the RST's Ethernet header from the same bytes, and
it has to go in before patch 2, which would otherwise turn that reject
into an out-of-bounds read.

Patch 1 also stops dup for packets that come in on a bridge port and
are then delivered locally or routed, because br_netfilter keeps
SKB_EXT_BRIDGE_NF on the skb until the bridge transmits it. Is that
acceptable, or should nf_dup keep duplicating them and call
skb_ext_del(skb, SKB_EXT_BRIDGE_NF) on the copy?

Found with a custom syzkaller-based fuzzer.

v3: add patch 1; without it, patch 2 turns the tcp reset reject of a
bridged dup copy into an out-of-bounds read in nf_send_reset() and
nf_send_reset6(). Drop the nfnetlink_queue patch, since nothing
produces a bridged copy without a mac header anymore.
v2: fix in __pskb_copy_fclone() instead of nf_dup; add the
nfnetlink_queue patch.
Link to v2: https://lore.kernel.org/netdev/20261117175835.745796-1-theodorlarionov@gmail.com/
v1: https://lore.kernel.org/netfilter-devel/20261116105113.128791-1-theodorlarionov@gmail.com/

Theodor Arsenij Larionov Trichkine (2):
  netfilter: nf_dup: do not duplicate packets from br_netfilter
  net: unset the mac header of a pskb copy that points into headroom

 net/core/skbuff.c                | 2 ++
 net/ipv4/netfilter/nf_dup_ipv4.c | 6 ++++++
 net/ipv6/netfilter/nf_dup_ipv6.c | 6 ++++++
 3 files changed, 14 insertions(+)

-- 
2.34.1


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

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 16:33 Theodor Arsenij Larionov Trichkine [this message]
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-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=20261124163358.755345-1-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox