Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bpf: Make bpf_skb_vlan_push helper metadata-safe

Use the metadata-aware helper to move packet bytes after skb_push(),
ensuring metadata remains valid after calling the BPF helper.

Also, take care to reserve sufficient headroom for metadata to fit.

Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/20251105-skb-meta-rx-path-v4-6-5ceb08a9b37b@cloudflare.com

authored by

Jakub Sitnicki and committed by
Martin KaFai Lau
55ffc98b efd35c26

+3 -2
+3 -2
include/linux/if_vlan.h
··· 355 355 __be16 vlan_proto, u16 vlan_tci, 356 356 unsigned int mac_len) 357 357 { 358 + const u8 meta_len = mac_len > ETH_TLEN ? skb_metadata_len(skb) : 0; 358 359 struct vlan_ethhdr *veth; 359 360 360 - if (skb_cow_head(skb, VLAN_HLEN) < 0) 361 + if (skb_cow_head(skb, meta_len + VLAN_HLEN) < 0) 361 362 return -ENOMEM; 362 363 363 364 skb_push(skb, VLAN_HLEN); 364 365 365 366 /* Move the mac header sans proto to the beginning of the new header. */ 366 367 if (likely(mac_len > ETH_TLEN)) 367 - memmove(skb->data, skb->data + VLAN_HLEN, mac_len - ETH_TLEN); 368 + skb_postpush_data_move(skb, VLAN_HLEN, mac_len - ETH_TLEN); 368 369 if (skb_mac_header_was_set(skb)) 369 370 skb->mac_header -= VLAN_HLEN; 370 371