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>
This commit is contained in:
Родитель
43e5f1d592
Коммит
4bcf6f827a
|
@ -92,6 +92,8 @@ void fscrypt_put_master_key_activeref(struct super_block *sb,
|
|||
* destroying any subkeys embedded in it.
|
||||
*/
|
||||
|
||||
if (WARN_ON(!sb->s_master_keys))
|
||||
return;
|
||||
spin_lock(&sb->s_master_keys->lock);
|
||||
hlist_del_rcu(&mk->mk_node);
|
||||
spin_unlock(&sb->s_master_keys->lock);
|
||||
|
|
Загрузка…
Ссылка в новой задаче