# CVE-2022-49899: fscrypt: stop using keyrings subsystem for fscrypt\_master\_key

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** HIGH 7.8
- **CVSS:** 7.8 (v3.1, CNA) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: High; Integrity impact: High; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.30% (percentile 15, 2026-11-26)
- **Published:** 2025-05-01T14:10:45.537Z
- **Modified:** 2026-08-05T08:56:37.385Z

## Who should check

- Anyone running Linux \>= 22d94f493bfb408fdd764f7b1d0363af2122fba5, \< 391cceee6d435e616f68631e68f5b32d480b1e67; \>= 22d94f493bfb408fdd764f7b1d0363af2122fba5, \< e6f4fd85ef1ee6ab356bfbd64df28c1cb73aee7e; \>= 22d94f493bfb408fdd764f7b1d0363af2122fba5, \< 68d15d6558a386f46d815a6ac39edecad713a1bf; \>= 22d94f493bfb408fdd764f7b1d0363af2122fba5, \< d7e7b9af104c7b389a0c21eb26532511bce4b510
- Anyone running Linux 5.4

## Description

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.

## Affected and fixed versions

- Linux: \>= 22d94f493bfb408fdd764f7b1d0363af2122fba5, \< 391cceee6d435e616f68631e68f5b32d480b1e67; \>= 22d94f493bfb408fdd764f7b1d0363af2122fba5, \< e6f4fd85ef1ee6ab356bfbd64df28c1cb73aee7e; \>= 22d94f493bfb408fdd764f7b1d0363af2122fba5, \< 68d15d6558a386f46d815a6ac39edecad713a1bf; \>= 22d94f493bfb408fdd764f7b1d0363af2122fba5, \< d7e7b9af104c7b389a0c21eb26532511bce4b510 (cvelist)
- Linux: 5.4 (cvelist)

## Mitigation

- No fix listed yet: follow the vendor advisory.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2022-49899. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2022-49899.md
Affected: Linux >= 22d94f493bfb408fdd764f7b1d0363af2122fba5, < 391cceee6d435e616f68631e68f5b32d480b1e67; >= 22d94f493bfb408fdd764f7b1d0363af2122fba5, < e6f4fd85ef1ee6ab356bfbd64df28c1cb73aee7e; >= 22d94f493bfb408fdd764f7b1d0363af2122fba5, < 68d15d6558a386f46d815a6ac39edecad713a1bf; >= 22d94f493bfb408fdd764f7…
Fixed in: Linux 391cceee6d435e616f68631e68f5b32d480b1e67, Linux 68d15d6558a386f46d815a6ac39edecad713a1bf

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2022-49899 being exploited?

There is no confirmed exploitation: CVE-2022-49899 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.30% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2022-49899?

High: CVSS 7.8 (v3.1, scored by CNA). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2022-49899?

Linux \>= 22d94f493bfb408fdd764f7b1d0363af2122fba5, \< 391cceee6d435e616f68631e68f5b32d480b1e67; \>= 22d94f493bfb408fdd764f7b1d0363af2122fba5, \< e6f4fd85ef1ee6ab356bfbd64df28c1cb73aee7e; \>= 22d94f493bfb408fdd764f7b1d0363af2122fba5, \< 68d15d6558a386f46d815a6ac39edecad713a1bf; \>= 22d94f493bfb408fdd764f7b1d0363af2122fba5, \< d7e7b9af104c7b389a0c21eb26532511bce4b510; Linux 5.4.

### Is there a fix for CVE-2022-49899?

Yes. Fixed in Linux 391cceee6d435e616f68631e68f5b32d480b1e67, Linux 68d15d6558a386f46d815a6ac39edecad713a1bf. No fix listed yet: follow the vendor advisory.

### How do I check if I'm affected by CVE-2022-49899?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/391cceee6d435e616f68631e68f5b32d480b1e67>
- patch: <https://git.kernel.org/stable/c/e6f4fd85ef1ee6ab356bfbd64df28c1cb73aee7e>
- patch: <https://git.kernel.org/stable/c/68d15d6558a386f46d815a6ac39edecad713a1bf>
- patch: <https://git.kernel.org/stable/c/d7e7b9af104c7b389a0c21eb26532511bce4b510>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2022-49899>

HTML: <https://flawdb.com/CVE-2022-49899> · JSON: <https://flawdb.com/api/v1/entries/CVE-2022-49899>
