aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Morris <james.morris@microsoft.com>2019-01-16 18:41:11 -0500
committerJames Morris <james.morris@microsoft.com>2019-01-16 18:41:11 -0500
commita5795fd38ee8194451ba3f281f075301a3696ce2 (patch)
treee1081bd211b1ea0857073db96b05d65e896012ac
parent9474f4e7cd71a633fa1ef93b7daefd44bbdfd482 (diff)
LSM: Check for NULL cred-security on free
From: Casey Schaufler <casey@schaufler-ca.com> Check that the cred security blob has been set before trying to clean it up. There is a case during credential initialization that could result in this. Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> Acked-by: John Johansen <john.johansen@canonical.com> Signed-off-by: James Morris <james.morris@microsoft.com> Reported-by: syzbot+69ca07954461f189e808@syzkaller.appspotmail.com
-rw-r--r--security/security.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/security/security.c b/security/security.c
index f1b8d2587639..55bc49027ba9 100644
--- a/security/security.c
+++ b/security/security.c
@@ -1027,6 +1027,13 @@ int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
1027 1027
1028void security_cred_free(struct cred *cred) 1028void security_cred_free(struct cred *cred)
1029{ 1029{
1030 /*
1031 * There is a failure case in prepare_creds() that
1032 * may result in a call here with ->security being NULL.
1033 */
1034 if (unlikely(cred->security == NULL))
1035 return;
1036
1030 call_void_hook(cred_free, cred); 1037 call_void_hook(cred_free, cred);
1031} 1038}
1032 1039