diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index b28b7eb3ca4..c868a7454c7 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -3816,6 +3816,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;