Skip to content

Commit d3a7bd4

Browse files
Luis Henriquesebiggers
authored andcommitted
fscrypt: clear keyring before calling key_put()
Now that the key quotas are handled immediately on key_put() instead of being postponed to the key management garbage collection worker, a call to keyring_clear() is all that is required in fscrypt_put_master_key() so that the keyring clean-up is also done synchronously. This patch should fix the fstest generic/581 flakiness. Signed-off-by: Luis Henriques <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ebiggers: added comment] Signed-off-by: Eric Biggers <[email protected]>
1 parent 5befc19 commit d3a7bd4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fs/crypto/keyring.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,12 @@ void fscrypt_put_master_key(struct fscrypt_master_key *mk)
7474
* that concurrent keyring lookups can no longer find it.
7575
*/
7676
WARN_ON_ONCE(refcount_read(&mk->mk_active_refs) != 0);
77-
key_put(mk->mk_users);
78-
mk->mk_users = NULL;
77+
if (mk->mk_users) {
78+
/* Clear the keyring so the quota gets released right away. */
79+
keyring_clear(mk->mk_users);
80+
key_put(mk->mk_users);
81+
mk->mk_users = NULL;
82+
}
7983
call_rcu(&mk->mk_rcu_head, fscrypt_free_master_key);
8084
}
8185

0 commit comments

Comments
 (0)