Re: [next] BUG: kernel NULL pointer dereference, address:: selinux_ip_postroute_compat

From: Florian Westphal
Date: Tue Oct 19 2021 - 09:10:57 EST


Naresh Kamboju <naresh.kamboju@xxxxxxxxxx> wrote:
> Following kernel crash noticed on linux next 20211019 tag.
> on x86, i386 and other architectures.

Paul, this might be caused by
1d1e1ded13568be81a0e19d228e310a48997bec8
("selinux: make better use of the nf_hook_state passed to the NF
hooks"), in particular this hunk here:

- if (sk == NULL)
+ if (state->sk == NULL)
return NF_ACCEPT;
+ sk = skb_to_full_sk(skb);
sksec = sk->sk_security;

state->sk might not be related to skb->sk.
I suspect that this should instead be:

+ sk = skb_to_full_sk(skb);
if (sk == NULL)

See 7026b1ddb6b8d4e6ee33dc2bd06c0ca8746fa7ab for the origin of this
additional socket pointer.