Skip to content

Commit 12113d8

Browse files
xu-langopsiff
authored andcommitted
bpf: fix null ptr access caused by bpf_prog_test_run_skb
this is a temporary fix bug-url: https://lore.kernel.org/all/de98e423-a113-4a11-853d-9706cbc07e37@hust.edu.cn/ Signed-off-by: xulang <xulang@uniontech.com>
1 parent 30ef311 commit 12113d8

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

net/core/lwt_bpf.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,12 @@ int bpf_lwt_push_ip_encap(struct sk_buff *skb, void *hdr, u32 len, bool ingress)
613613

614614
if (ingress)
615615
err = skb_cow_head(skb, len + skb->mac_len);
616-
else
616+
else {
617+
if (unlikely(!skb_dst(skb)))
618+
return -EINVAL;
617619
err = skb_cow_head(skb,
618620
len + LL_RESERVED_SPACE(skb_dst(skb)->dev));
621+
}
619622
if (unlikely(err))
620623
return err;
621624

0 commit comments

Comments
 (0)