Since commit 76cc0d3282d4 ("ip6_gre: skb_push ipv6hdr before packing the header in ip6gre_header"), ip6gre_header() pushes the outer IPv6 header and the GRE header, t->hlen + sizeof(struct ipv6hdr) bytes, but it still returns t->hlen. packet_snd() copies the user's payload at the offset dev_hard_header() returns, so an AF_PACKET SOCK_DGRAM send on an ip6gre device with header_ops (remote any) writes the payload over the outer IPv6 header and leaves the last 40 bytes of the packet uninitialized. A packet tap on the device then copies those bytes to user space: BUG: KMSAN: kernel-infoleak in _copy_to_iter (lib/iov_iter.c:197) _copy_to_iter (lib/iov_iter.c:197) __skb_datagram_iter (net/core/datagram.c:402) packet_recvmsg (net/packet/af_packet.c:3573) sock_recvmsg (net/socket.c:1176) __sys_recvfrom (net/socket.c:2333) Uninit was created at: __alloc_skb (net/core/skbuff.c:716) alloc_skb_with_frags (net/core/skbuff.c:6940) sock_alloc_send_pskb (net/core/sock.c:3096) packet_sendmsg (net/packet/af_packet.c:3023 af_packet.c:3209) Bytes 68-107 of 108 are uninitialized Return the length that was pushed, as ipgre_header() does. With the payload in place, the tap also shows that ip6gre_header() never sets payload_len, so set it as well. Fixes: 76cc0d3282d4 ("ip6_gre: skb_push ipv6hdr before packing the header in ip6gre_header") Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Kyuwon Cho --- net/ipv6/ip6_gre.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 9816c62c0c50..d824238eb598 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -1398,6 +1398,7 @@ static int ip6gre_header(struct sk_buff *skb, struct net_device *dev, ip6_flow_hdr(ipv6h, 0, ip6_make_flowlabel(dev_net(dev), skb, t->fl.u.ip6.flowlabel, true, &t->fl.u.ip6)); + ipv6h->payload_len = htons(t->hlen + len); ipv6h->hop_limit = t->parms.hop_limit; ipv6h->nexthdr = NEXTHDR_GRE; ipv6h->saddr = t->parms.laddr; @@ -1416,9 +1417,9 @@ static int ip6gre_header(struct sk_buff *skb, struct net_device *dev, if (daddr) memcpy(&ipv6h->daddr, daddr, sizeof(struct in6_addr)); if (!ipv6_addr_any(&ipv6h->daddr)) - return t->hlen; + return needed; - return -t->hlen; + return -needed; } static const struct header_ops ip6gre_header_ops = { -- 2.43.0