From: James Morris Date: Wed, 16 Jan 2019 23:41:11 +0000 (-0800) Subject: LSM: Check for NULL cred-security on free X-Git-Tag: v4.14.95~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b9f9379336425ebd0c07d454857ddbc6fe750b36;p=thirdparty%2Fkernel%2Fstable.git LSM: Check for NULL cred-security on free commit a5795fd38ee8194451ba3f281f075301a3696ce2 upstream. From: Casey Schaufler 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 Acked-by: John Johansen Signed-off-by: James Morris Reported-by: syzbot+69ca07954461f189e808@syzkaller.appspotmail.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/security/security.c b/security/security.c index 95a1a0f52880c..4fbe4e495c021 100644 --- a/security/security.c +++ b/security/security.c @@ -993,6 +993,13 @@ int security_cred_alloc_blank(struct cred *cred, gfp_t gfp) void security_cred_free(struct cred *cred) { + /* + * There is a failure case in prepare_creds() that + * may result in a call here with ->security being NULL. + */ + if (unlikely(cred->security == NULL)) + return; + call_void_hook(cred_free, cred); }