-
Uninitialized Network Header in Generic XSK Transmission:
When an AF_XDP socket transmits in generic mode via xsk_generic_xmit() / __xsk_generic_xmit(), it builds an sk_buff using xsk_build_skb() (or xsk_build_skb_zerocopy()).
In xsk_build_skb() (net/xdp/xsk.c:1133-1140):
hr = max(NET_SKB_PAD, L1_CACHE_ALIGN(dev->needed_headroom));
tr = dev->needed_tailroom;
skb = sock_alloc_send_skb(&xs->sk, hr + len + tr, 1, &err);
...
skb_reserve(skb, hr);
skb_put(skb, len);
skb_store_bits(skb, 0, buffer, len);
sock_alloc_send_skb() initializes skb->network_header to 0. skb_reserve(skb, hr) shifts skb->data forward by hr (64 bytes on x86_64, where NET_SKB_PAD == 64). Unlike raw packet socket paths (such as tpacket_fill_skb() or packet_snd() in net/packet/af_packet.c), which explicitly call skb_reset_network_header(skb) after skb_reserve(), xsk_build_skb() and xsk_build_skb_zerocopy() do not reset skb->network_header.
Consequently, skb->network_header remains 0, meaning skb_network_header(skb) points to skb->head, while skb->data points to skb->head + hr.
-
Negative Network Header Offset:
__xsk_generic_xmit() passes the newly built skb to __dev_direct_xmit(), which directly invokes the destination netdev's dev->netdev_ops->ndo_start_xmit(skb, dev).
When AF_XDP is bound to an L3/tunnel device (such as xfrm0 whose ndo_start_xmit is xfrmi_xmit()), xfrmi_xmit() expects an L3 payload and immediately verifies the packet headers using:
if (!pskb_inet_may_pull(skb))
goto tx_err;
pskb_inet_may_pull() calls pskb_inet_may_pull_reason(skb) (include/net/ip_tunnels.h:466):
switch (skb->protocol) {
case htons(ETH_P_IPV6):
nhlen = sizeof(struct ipv6hdr);
break;
case htons(ETH_P_IP):
nhlen = sizeof(struct iphdr);
break;
default:
nhlen = 0;
}
return pskb_network_may_pull_reason(skb, nhlen);
Because AF_XDP does not initialize skb->protocol, skb->protocol is 0, leading to nhlen = 0.
-
Integer Underflow and Warning Trigger:
pskb_network_may_pull_reason() (include/linux/skbuff.h:3284) computes the pull length:
static inline enum skb_drop_reason
pskb_network_may_pull_reason(struct sk_buff *skb, unsigned int len)
{
return pskb_may_pull_reason(skb, skb_network_offset(skb) + len);
}
Here, skb_network_offset(skb) is defined as skb_network_header(skb) - skb->data. Because skb->network_header was never reset:
$$\text{skb_network_offset} = \text{skb}\to\text{head} - (\text{skb}\to\text{head} + 64) = -64 \text{ (as a signed int)}.$$
When evaluated in skb_network_offset(skb) + len where len is unsigned int (0), standard C integer conversion rules convert -64 to (unsigned int)0xffffffc0 (4,294,967,232).
Inside pskb_may_pull_reason() (include/linux/skbuff.h:2854):
DEBUG_NET_WARN_ON_ONCE(len > INT_MAX);
Because len == 0xffffffc0 > 0x7fffffff (INT_MAX), the assertion fires, triggering the warning splat reported by syzkaller.