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: 1d1e1ded13 ("selinux: make better use of the nf_hook_state passed to the NF hooks")
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Suggested-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
Paul Moore 2021-10-19 12:19:44 -04:00
parent 4d5b553974
commit 1c73213ba9

View File

@ -5778,9 +5778,9 @@ static unsigned int selinux_ip_postroute_compat(struct sk_buff *skb,
struct lsm_network_audit net = {0,}; struct lsm_network_audit net = {0,};
u8 proto; u8 proto;
if (state->sk == NULL)
return NF_ACCEPT;
sk = skb_to_full_sk(skb); sk = skb_to_full_sk(skb);
if (sk == NULL)
return NF_ACCEPT;
sksec = sk->sk_security; sksec = sk->sk_security;
ad.type = LSM_AUDIT_DATA_NET; ad.type = LSM_AUDIT_DATA_NET;