linux/fs/crypto
Eric Biggers 696c030e1e fscrypt: Replace mk_users keyring with simple list
Change mk_users (the set of user claims to an fscrypt master key) from a
'struct key' keyring to a simple linked list.

It's still a collection of 'struct key' for quota tracking.  It was
originally thought to be natural that a collection of 'struct key'
should be held in a 'struct key' keyring.  In reality, it's just been
causing problems, similar to how using 'struct key' for the filesystem
keyring caused problems and was removed in commit d7e7b9af10
("fscrypt: stop using keyrings subsystem for fscrypt_master_key").

Commit d3a7bd4200 ("fscrypt: clear keyring before calling key_put()")
fixed mk_users cleanup to be synchronous.  But that apparently wasn't
enough: the keyring subsystem's redundant locking is still generating
lockdep false positives due to the interaction with filesystem reclaim.

With the simple list, the redundant locking and lockdep issue goes away.

Of course, searching a linked list is linear-time whereas the
'struct key' keyring used a fancy constant-time associative array.  But
that's fine here, since in practice there's just one entry in the list.
In fact the new code is much faster in practice, since it's much smaller
and doesn't have to convert the kuid_t into a string to search for it.

Reported-by: syzbot+f55b043dacf43776b50c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=f55b043dacf43776b50c
Reported-by: Mohammed EL Kadiri <med08elkadiri@gmail.com>
Closes: https://lore.kernel.org/keyrings/20260614150041.21172-1-med08elkadiri@gmail.com/
Fixes: 23c688b540 ("fscrypt: allow unprivileged users to add/remove keys for v2 policies")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260618221921.87896-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
2026-06-22 12:12:11 -07:00
..
bio.c fscrypt: pass a real sector_t to fscrypt_zeroout_range 2026-03-09 13:34:21 -07:00
crypto.c treewide: change inode->i_ino from unsigned long to u64 2026-03-06 14:31:28 +01:00
fname.c fs: add helpers name_is_dot{,dot,_dotdot} 2026-01-29 10:06:59 +01:00
fscrypt_private.h fscrypt: Replace mk_users keyring with simple list 2026-06-22 12:12:11 -07:00
hkdf.c fscrypt: use HMAC-SHA512 library for HKDF 2025-09-05 21:01:51 -07:00
hooks.c treewide: change inode->i_ino from unsigned long to u64 2026-03-06 14:31:28 +01:00
inline_crypt.c fscrypt: Fix key setup in edge case with multiple data unit sizes 2026-06-22 12:12:11 -07:00
Kconfig fscrypt: use AES library for v1 key derivation 2026-03-25 12:06:33 -07:00
keyring.c fscrypt: Replace mk_users keyring with simple list 2026-06-22 12:12:11 -07:00
keysetup_v1.c fscrypt: use AES library for v1 key derivation 2026-03-25 12:06:33 -07:00
keysetup.c fscrypt: Fix key setup in edge case with multiple data unit sizes 2026-06-22 12:12:11 -07:00
Makefile fscrypt: add inline encryption support 2020-07-08 10:29:30 -07:00
policy.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00