Skip to content

Commit 5d8a485

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 ae82560 commit 5d8a485

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
@@ -3324,10 +3324,11 @@ static int bpf_skb_net_hdr_pop(struct sk_buff *skb, u32 off, u32 len)
33243324
static int bpf_skb_proto_4_to_6(struct sk_buff *skb)
33253325
{
33263326
const u32 len_diff = sizeof(struct ipv6hdr) - sizeof(struct iphdr);
3327+
const u8 meta_len = skb_metadata_len(skb);
33273328
u32 off = skb_mac_header_len(skb);
33283329
int ret;
33293330

3330-
ret = skb_cow(skb, len_diff);
3331+
ret = skb_cow(skb, meta_len + len_diff);
33313332
if (unlikely(ret < 0))
33323333
return ret;
33333334

0 commit comments

Comments
 (0)