]> www.infradead.org Git - users/jedix/linux-maple.git/commit
fscrypt: check for NULL keyring in fscrypt_put_master_key_activeref()
authorEric Biggers <ebiggers@google.com>
Mon, 13 Mar 2023 22:12:31 +0000 (15:12 -0700)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 24 Mar 2023 14:25:31 +0000 (10:25 -0400)
commit1e4a6682bc67a72f949d93021b82217b797dfc69
tree36035ee7277b7f9b83f9c2885f5493a7cc14b2c7
parentdd6772dc0a7ae195695dfb1cb5ca624e71c421c6
fscrypt: check for NULL keyring in fscrypt_put_master_key_activeref()

It is a bug for fscrypt_put_master_key_activeref() to see a NULL
keyring.  But it used to be possible due to the bug, now fixed, where
fscrypt_destroy_keyring() was called before security_sb_delete().  To be
consistent with how fscrypt_destroy_keyring() uses WARN_ON for the same
issue, WARN and leak the fscrypt_master_key if the keyring is NULL
instead of dereferencing the NULL pointer.

This is a robustness improvement, not a fix.

Link: https://lore.kernel.org/r/20230313221231.272498-4-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
fs/crypto/keyring.c