Skip to content

Commit 261ed16

Browse files
jsitnickiKernel Patches Daemon
authored andcommitted
bpf: Make bpf_skb_change_proto helper metadata-safe
bpf_skb_change_proto reuses the same headroom operations as bpf_skb_adjust_room, already updated to handle metadata safely. The remaining step is to ensure that there is sufficient headroom to accommodate metadata on skb_push(). Signed-off-by: Jakub Sitnicki <[email protected]>
1 parent 761e852 commit 261ed16

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/core/filter.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3333,10 +3333,11 @@ static int bpf_skb_net_hdr_pop(struct sk_buff *skb, u32 off, u32 len)
33333333
static int bpf_skb_proto_4_to_6(struct sk_buff *skb)
33343334
{
33353335
const u32 len_diff = sizeof(struct ipv6hdr) - sizeof(struct iphdr);
3336+
const u8 meta_len = skb_metadata_len(skb);
33363337
u32 off = skb_mac_header_len(skb);
33373338
int ret;
33383339

3339-
ret = skb_cow(skb, len_diff);
3340+
ret = skb_cow(skb, meta_len + len_diff);
33403341
if (unlikely(ret < 0))
33413342
return ret;
33423343

0 commit comments

Comments
 (0)