Re: [PATCH bpf] bpf: Handle unset mac_header in bpf_skb_adjust_room() and bpf_skb_change_proto()
From: Alexei Starovoitov
Date: Mon Nov 30 2026 - 00:28:18 EST
On Sun, Nov 29, 2026 at 09:00 PM Hu Xinyao <huxinyao@xxxxxxxxxxxxxxx> wrote:
> On L3 interfaces such as IFF_TUN and wireguard, ingress packets enter TC
> BPF programs with skb->mac_header unset (~0U) and skb->data at the
> network header.
No. Both drivers call skb_reset_mac_header() before the skb gets to tc:
driver where
--------- ------------------------------------------------
tun __virtio_net_hdr_to_skb(), from tun_get_user()
wireguard wg_reset_packet(), from wg_packet_rx_poll()
skb->data is at the network header at that point.
So skb_mac_header_len() returns 0 and both helpers work.
> Found during a GLM-5.4-assisted code audit and verified manually against
> mainline; compile-tested only (not triggered at runtime).
It cannot be triggered on tun or wireguard.
Pls don't send fixes for bugs that you didn't reproduce.
pw-bot: cr