Re: [PATCH net] seg6: fix NULL deref in input_action_end_dx{4,6}_finish() after nf hook
From: Xiang Mei
Date: Tue Jul 28 2026 - 17:16:39 EST
On Thu, Jul 23, 2026 at 10:10 AM Jakub Kicinski <kuba@xxxxxxxxxx> wrote:
>
> On Mon, 20 Jul 2026 20:44:29 +0000 Xiang Mei (Microsoft) wrote:
> > When nf_hooks_lwtunnel is enabled, the End.DX4/End.DX6 actions dispatch
> > the decapsulated inner packet through the NF_INET_PRE_ROUTING hook chain
> > with input_action_end_dx{4,6}_finish() as the okfn. Both functions read
> > the lwtunnel state via orig_dst = skb_dst(skb) and dereference
> > orig_dst->lwtstate.
>
> Per Sashiko's feedback - we need to validate not only that the dst
> is there but also that it is of the expected type, no?
> --
> pw-bot: cr
Thanks for the review. You are right, I'll do the following check in v2:
if (!skb_valid_dst(skb) || !dst->lwtstate ||
dst->lwtstate->type != LWTUNNEL_ENCAP_SEG6_LOCAL)
return NULL;
v2 also covers three more functions with the same problem, so it is now a
series of two patches. Details in the reply to Andrea.
Xiang