Subject: Re: [PATCH] bpf: lwtunnel: Check skb->_skb_refdst in bpf_lwt_push_ip_encap

From: Jakub Kicinski <[email-masked]>
Date: Tue, 27 Jan 2026 16:00:52 -0800

On Tue, 27 Jan 2026 16:45:20 +0800 Yun Lu wrote:
> The bpf_lwt_xmit_push_encap helper needs to access skb_dst(skb)->dev to
> calculate the needed headroom:
> 
> 	err = skb_cow_head(skb,
> 			   len + LL_RESERVED_SPACE(skb_dst(skb)->dev));
> 
> But skb->_skb_refdst may not be initialized when the skb is set up by
> bpf_prog_test_run_skb function. Executing bpf_lwt_push_ip_encap function
> in this scenario will trigger null pointer dereference, causing a kernel
> crash as Yinhao reported:

Seems a bit backwards to be adding datapath checks to make
bpf_prog_test_run_skb() happy. Also - please run checkpatch.
-- 
pw-bot: cr