diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 393e59a67381dc..6956b4a9503cdf 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -3839,6 +3839,11 @@ static int sock_has_perm(struct task_struct *task, struct sock *sk, u32 perms) struct lsm_network_audit net = {0,}; u32 tsid = task_sid(task); + if (unlikely(!sksec)) { + pr_warn("SELinux: sksec is NULL, socket is already freed\n"); + return -EINVAL; + } + if (sksec->sid == SECINITSID_KERNEL) return 0;