Skip to content

Commit

Permalink
selinux: fix a sock regression in selinux_ip_postroute_compat()
Browse files Browse the repository at this point in the history
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: 1d1e1de ("selinux: make better use of the nf_hook_state passed to the NF hooks")
Reported-by: Linux Kernel Functional Testing <[email protected]>
Suggested-by: Florian Westphal <[email protected]>
Signed-off-by: Paul Moore <[email protected]>
  • Loading branch information
pcmoore committed Oct 19, 2021
1 parent 4d5b553 commit 1c73213
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1c73213

Please sign in to comment.