net: do not point a pskb copy's mac header into uninitialised headroom

Started by Theodor Arsenij Larionov Trichkine on Nov 17, 2026 · 4 messages from 2 authors · Last reply Nov 17, 2026

Series

2 patches, 2 files

+4 −2

Subsystems (3)

Maintainers (7)

Show 3 more
WARM1d

open the first message on its own page

  1. [PATCH net v2 1/2] netfilter: nfnetlink_queue: only adjust bridged skbs that have a mac header
    Related patches
  2. [PATCH net v2 2/2] net: unset the mac header of a pskb copy that points into headroom
    Related patches
Message details and related content
A pskb copy keeps the mac_header offset but not the headroom, so a copy
of a received packet has its mac header in uninitialised bytes, which
nft dup can return to userspace. Patch 2 unsets the mac header of such a
copy, as Florian suggested on v1. Patch 1 makes the nfnetlink_queue
bridge adjustment check the mac header first; without it, patch 2 turns
a queued GSO copy of a bridged packet into an out-of-bounds push.

v2: fix in __pskb_copy_fclone() instead of nf_dup; add patch 1.
v1: https://lore.kernel.org/netfilter-devel/20261116105113.128791-1-theodorlarionov@gmail.com/

Theodor Arsenij Larionov Trichkine (2):
  netfilter: nfnetlink_queue: only adjust bridged skbs that have a mac
    header
  net: unset the mac header of a pskb copy that points into headroom

 net/core/skbuff.c               | 2 ++
 net/netfilter/nfnetlink_queue.c | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

-- 
2.34.1

[PATCH net v2 1/2] netfilter: nfnetlink_queue: only adjust bridged skbs that have a mac header

Message details and related content
nf_bridge_adjust_skb_data() and nf_bridge_adjust_segmented_data() push
and pull skb_mac_header_len() bytes for any skb with bridge netfilter
info. 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. With the mac
header unset, skb_mac_header_len() underflows and the push moves
skb->data out of the buffer before skb_gso_segment():

  BUG: KASAN: slab-out-of-bounds in inet_gso_segment+0xd5f/0x1370

Only adjust skbs that have a mac header.

Fixes: a5fedd43d5f6 ("netfilter: move skb_gso_segment into nfnetlink_queue module")
Cc: <redacted>
Signed-off-by: Theodor Arsenij Larionov Trichkine <redacted>
---
 net/netfilter/nfnetlink_queue.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index a8aa7ad832c3..fafadd9057cf 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));
 }
 #else
-- 
2.34.1

[PATCH net v2 2/2] net: unset the mac header of a pskb copy that points into headroom

Message details and related content
__pskb_copy_fclone() copies the data from skb->data onwards, while
skb_copy_header() keeps the mac_header offset. When the link-layer
header was pulled, the copy's mac header points into uninitialised
headroom. nft dup is one such caller: a link-layer payload read of the
duplicated packet on LOCAL_OUT or POST_ROUTING loads those bytes, and a
set element returns them to userspace:

  BUG: KMSAN: kernel-infoleak in _copy_to_iter

Unset the mac header of the copy in that case. Callers that need it,
such as the bridge, push the link-layer header before copying.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Suggested-by: Florian Westphal <fw@strlen.de>
Cc: <redacted>
Signed-off-by: Theodor Arsenij Larionov Trichkine <redacted>
---
 net/core/skbuff.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 1ac1e327ac4c..7f6d0344efa6 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
Message details and related content
Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - How the issue was discovered, e.g. hit in production, hit during
   development, syzbot report, manual code inspection, LLM or static
   analysis tool scan.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help