From: Paul Moore Date: Tue, 19 Oct 2021 16:19:44 +0000 (-0400) Subject: selinux: fix a sock regression in selinux_ip_postroute_compat() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=1c73213ba991d26a91282e775d1f5a60e41e5184;p=linux.git selinux: fix a sock regression in selinux_ip_postroute_compat() Unfortunately we can't rely on nf_hook_state->sk being the proper originating socket so revert to using skb_to_full_sk(skb). Fixes: 1d1e1ded1356 ("selinux: make better use of the nf_hook_state passed to the NF hooks") Reported-by: Linux Kernel Functional Testing Suggested-by: Florian Westphal Signed-off-by: Paul Moore --- diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index b4a1bde202616..6f08cd2fc6a89 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -5778,9 +5778,9 @@ static unsigned int selinux_ip_postroute_compat(struct sk_buff *skb, struct lsm_network_audit net = {0,}; u8 proto; - if (state->sk == NULL) - return NF_ACCEPT; sk = skb_to_full_sk(skb); + if (sk == NULL) + return NF_ACCEPT; sksec = sk->sk_security; ad.type = LSM_AUDIT_DATA_NET;