Re: [PATCH] KEYS: avoid filesystem reclaim while holding keyring->sem
Eric Biggers <[email protected]> Thu, 18 Jun 2026 15:32:24 -0700
| Newsgroups | org.kernel.vger.keyrings,org.kernel.vger.linux-kernel,org.kernel.vger.linux-security-module,org.kernel.vger.stable |
|---|---|
| Message-ID | <20260618223224.GA23294@sol> |
On Sun, Jun 14, 2026 at 04:00:41PM +0100, Mohammed EL Kadiri wrote: > __key_link_begin() runs with keyring->sem held and calls > assoc_array_insert(), which does GFP_KERNEL allocations. Those > allocations may enter filesystem reclaim, evict an fscrypt-protected > inode, and reach keyring_clear() via fscrypt_put_master_key() -- > taking a keyring semaphore of the same lockdep class and closing a > keyring->sem -> fs_reclaim -> keyring->sem cycle reported by syzbot. > > Wrap the assoc_array_insert() call with memalloc_nofs_save() / > memalloc_nofs_restore() so reclaim cannot recurse into the keys > subsystem while keyring->sem is held. > > Reported-by: [email protected] > Closes: https://syzkaller.appspot.com/bug?extid=f55b043dacf43776b50c > Fixes: d7e7b9af104c ("fscrypt: stop using keyrings subsystem for fscrypt_master_key") > Cc: [email protected] > Signed-off-by: Mohammed EL Kadiri <[email protected]> My patch "fscrypt: Replace mk_users keyring with simple list" (https://lore.kernel.org/linux-fscrypt/[email protected]/) fixes this lockdep false positive by making fscrypt no longer use 'struct key' keyrings to keep track of user claims to fscrypt master keys. That eliminates the need to clear such keyrings during filesystem reclaim. So this patch to security/keys/keyring.c isn't needed, unless there's another reason for it. - Eric