__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