CVE-2022-49899: fscrypt: stop using keyrings subsystem for fscrypt_master_key
In the Linux kernel, the following vulnerability has been resolved:
fscrypt: stop using keyrings subsystem for fscrypt_master_key
The approach of fs/crypto/ internally managing the fscrypt_master_key
structs as the payloads of "struct key" objects contained in a
"struct key" keyring has outlived its usefulness. The original idea was
to simplify the code by reusing code from the keyrings subsystem.
However, several issues have arisen that can't easily be resolved:
- When a master key struct is destroyed, blk_crypto_evict_key() must be
called on any per-mode keys embedded in it. (This started being the
case when inline encryption support was added.) Yet, the keyrings
subsystem can arbitrarily delay the destruction of keys, even past the
time the filesystem was unmounted. Therefore, currently there is no
easy way to call blk_crypto_evict_key() when a master key is
destroyed. Currently, this is worked around by holding an extra
reference to the filesystem's request_queue(s). But it was overlooked
that the request_queue reference is *not* guaranteed to pin the
corresponding blk_crypto_profile too; for device-mapper devices that
support inline crypto, it doesn't. This can cause a use-after-free.
- When the last inode that was using an incompletely-removed master key
is evicted, the master key removal is completed by removing the key
struct from the keyring. Currently this is done via key_invalidate().
Yet, key_invalidate() takes the key semaphore. This can deadlock when
called from the shrinker, since in fscrypt_ioctl_add_key(), memory is
allocated with GFP_KERNEL under the same semaphore.
- More generally, the fact that the keyrings subsystem can arbitrarily
delay the destruction of keys (via garbage collection delay, or via
random processes getting temporary key references) is undesirable, as
it means we can't strictly guarantee that all secrets are ever wiped.
- Doing the master key lookups via the keyrings subsystem results in the
key_permission LSM hook being called. fscrypt doesn't want this, as
all access control for encrypted files is designed to happen via the
files themselves, like any other files. The workaround which SELinux
users are using is to change their SELinux policy to grant key search
access to all domains. This works, but it is an odd extra step that
shouldn't really have to be done.
The fix for all these issues is to change the implementation to what I
should have done originally: don't use the keyrings subsystem to keep
track of the filesystem's fscrypt_master_key structs. Instead, just
store them in a regular kernel data structure, and rework the reference
counting, locking, and lifetime accordingly. Retain support for
RCU-mode key lookups by using a hash table. Replace fscrypt_sb_free()
with fscrypt_sb_delete(), which releases the keys synchronously and runs
a bit earlier during unmount, so that block devices are still available.
A side effect of this patch is that neither the master keys themselves
nor the filesystem keyrings will be listed in /proc/keys anymore.
("Master key users" and the master key users keyrings will still be
listed.) However, this was mostly an implementation detail, and it was
intended just for debugging purposes. I don't know of anyone using it.
This patch does *not* change how "master key users" (->mk_users) works;
that still uses the keyrings subsystem. That is still needed for key
quotas, and changing that isn't necessary to solve the issues listed
above. If we decide to change that too, it would be a separate patch.
I've marked this as fixing the original commit that added the fscrypt
keyring, but as noted above the most important issue that this patch
fixes wasn't introduced until the addition of inline encryption support.
Security readout for executives and security teams
Plain-English summary
CVE-2022-49899 is a Linux kernel fscrypt flaw where encrypted-filesystem master keys were managed through the keyrings subsystem. That could delay cleanup, create deadlock risk, and in some inline-encryption paths cause use-after-free conditions. The business impact is mainly local availability risk, not remote compromise.
Executive priority
Treat this as a moderate kernel maintenance item. It is not presented as remotely exploitable, but it can affect availability on systems using Linux filesystem encryption. Patch through normal kernel update channels, prioritizing encrypted storage hosts.
Technical view
fscrypt stored fscrypt_master_key objects as struct key payloads in keyrings. Keyring garbage collection and temporary references could outlive filesystem unmount, conflicting with blk_crypto_evict_key() and device-mapper inline crypto lifetime. The fix moves master-key tracking to regular kernel data structures with revised locking, refcounting, hash lookup, and synchronous key release during unmount.
Likely exposure
Exposure is limited to Linux systems with affected kernel versions and fscrypt usage, especially environments using inline encryption or device-mapper inline crypto. The CVSS vector is local, low complexity, and requires low privileges. Exact exposure depends on distribution backports and whether the relevant kernel fix is present.
Exploitation context
The source bundle does not identify active exploitation, and KEV status is false. The vulnerability is local and availability-focused, with no cited confidentiality or integrity impact. Public sources provided describe the fix and root cause, not exploitation in the wild.
Researcher notes
The key evidence is the kernel fix rationale: delayed keyring destruction prevented reliable synchronous cleanup of fscrypt master keys. The most important stated issue is a possible use-after-free involving blk_crypto_profile lifetime with device-mapper inline crypto. Evidence is incomplete for exploitability beyond local availability impact.
Mitigation direction
Update to a vendor kernel containing the fscrypt master-key keyring removal fix.
Prioritize hosts using fscrypt, inline encryption, or device-mapper inline crypto.
Check distribution advisories because kernel fixes may be backported without version changes.
Avoid direct deploy assumptions; follow the operating-system vendor’s kernel guidance.
Validation and detection
Inventory Linux kernel versions and identify systems using fscrypt encrypted filesystems.
Verify the running kernel includes one of the referenced stable commits or a vendor backport.
Confirm affected fleets using device-mapper inline crypto are patched first.
Review operational monitoring for local kernel crashes or deadlocks around fscrypt key removal.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cve · low confidence lookup
CVE-2022-49899 mapping review
Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.