# CVE-2022-49049: mm/secretmem: fix panic when growing a memfd\_secret

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

- **Severity:** MEDIUM 5.5
- **CVSS:** 5.5 (v3.1, NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; 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.28% (percentile 13, 2026-11-26)
- **Published:** 2025-02-26T01:54:24.783Z
- **Modified:** 2026-06-17T05:16:56.187Z

## Who should check

- Anyone running Linux \>= 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49, \< b6d17c67885a5624e96eb30c4178c65eea8374bf; \>= 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49, \< 9d3b877daf805fed29be8f61aa3d0ea37df82c7b; \>= 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49, \< f9b141f93659e09a52e28791ccbaf69c273b8e92
- Anyone running Linux 5.14

## Description

In the Linux kernel, the following vulnerability has been resolved:

mm/secretmem: fix panic when growing a memfd\_secret

When one tries to grow an existing memfd\_secret with ftruncate, one gets
a panic \[1\].  For example, doing the following reliably induces the
panic:

    fd = memfd\_secret();

    ftruncate(fd, 10);
    ptr = mmap(NULL, 10, PROT\_READ \| PROT\_WRITE, MAP\_SHARED, fd, 0);
    strcpy(ptr, "123456789");

    munmap(ptr, 10);
    ftruncate(fd, 20);

The basic reason for this is, when we grow with ftruncate, we call down
into simple\_setattr, and then truncate\_inode\_pages\_range, and eventually
we try to zero part of the memory.  The normal truncation code does this
via the direct map (i.e., it calls page\_address() and hands that to
memset()).

For memfd\_secret though, we specifically don't map our pages via the
direct map (i.e.  we call set\_direct\_map\_invalid\_noflush() on every
fault).  So the address returned by page\_address() isn't useful, and
when we try to memset() with it we panic.

This patch avoids the panic by implementing a custom setattr for
memfd\_secret, which detects resizes specifically (setting the size for
the first time works just fine, since there are no existing pages to try
to zero), and rejects them with EINVAL.

One could argue growing should be supported, but I think that will
require a significantly more lengthy change.  So, I propose a minimal
fix for the benefit of stable kernels, and then perhaps to extend
memfd\_secret to support growing in a separate patch.

\[1\]:

  BUG: unable to handle page fault for address: ffffa0a889277028
  \#PF: supervisor write access in kernel mode
  \#PF: error\_code(0x0002) - not-present page
  PGD afa01067 P4D afa01067 PUD 83f909067 PMD 83f8bf067 PTE 800ffffef6d88060
  Oops: 0002 \[\#1\] PREEMPT SMP DEBUG\_PAGEALLOC PTI
  CPU: 0 PID: 281 Comm: repro Not tainted 5.17.0-dbg-DEV \#1
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
  RIP: 0010:memset\_erms+0x9/0x10
  Code: c1 e9 03 40 0f b6 f6 48 b8 01 01 01 01 01 01 01 01 48 0f af c6 f3 48 ab 89 d1 f3 aa 4c 89 c8 c3 90 49 89 f9 40 88 f0 48 89 d1 \<f3\> aa 4c 89 c8 c3 90 49 89 fa 40 0f b6 ce 48 b8 01 01 01 01 01 01
  RSP: 0018:ffffb932c09afbf0 EFLAGS: 00010246
  RAX: 0000000000000000 RBX: ffffda63c4249dc0 RCX: 0000000000000fd8
  RDX: 0000000000000fd8 RSI: 0000000000000000 RDI: ffffa0a889277028
  RBP: ffffb932c09afc00 R08: 0000000000001000 R09: ffffa0a889277028
  R10: 0000000000020023 R11: 0000000000000000 R12: ffffda63c4249dc0
  R13: ffffa0a890d70d98 R14: 0000000000000028 R15: 0000000000000fd8
  FS:  00007f7294899580(0000) GS:ffffa0af9bc00000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
  CR2: ffffa0a889277028 CR3: 0000000107ef6006 CR4: 0000000000370ef0
  DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
  DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
  Call Trace:
   ? zero\_user\_segments+0x82/0x190
   truncate\_inode\_partial\_folio+0xd4/0x2a0
   truncate\_inode\_pages\_range+0x380/0x830
   truncate\_setsize+0x63/0x80
   simple\_setattr+0x37/0x60
   notify\_change+0x3d8/0x4d0
   do\_sys\_ftruncate+0x162/0x1d0
   \_\_x64\_sys\_ftruncate+0x1c/0x20
   do\_syscall\_64+0x44/0xa0
   entry\_SYSCALL\_64\_after\_hwframe+0x44/0xae
  Modules linked in: xhci\_pci xhci\_hcd virtio\_net net\_failover failover virtio\_blk virtio\_balloon uhci\_hcd ohci\_pci ohci\_hcd evdev ehci\_pci ehci\_hcd 9pnet\_virtio 9p netfs 9pnet
  CR2: ffffa0a889277028

\[lkp@intel.com: secretmem\_iops can be static\]
\[axelrasmussen@google.com: return EINVAL\]

## Affected and fixed versions

- Linux: \>= 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49, \< b6d17c67885a5624e96eb30c4178c65eea8374bf; \>= 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49, \< 9d3b877daf805fed29be8f61aa3d0ea37df82c7b; \>= 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49, \< f9b141f93659e09a52e28791ccbaf69c273b8e92 (cvelist)
- Linux: 5.14 (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-49049. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2022-49049.md
Affected: Linux >= 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49, < b6d17c67885a5624e96eb30c4178c65eea8374bf; >= 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49, < 9d3b877daf805fed29be8f61aa3d0ea37df82c7b; >= 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49, < f9b141f93659e09a52e28791ccbaf69c273b8e92; Linux 5.14
Fixed in: Linux 9d3b877daf805fed29be8f61aa3d0ea37df82c7b

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-49049 being exploited?

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

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

Medium: CVSS 5.5 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed).

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

Linux \>= 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49, \< b6d17c67885a5624e96eb30c4178c65eea8374bf; \>= 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49, \< 9d3b877daf805fed29be8f61aa3d0ea37df82c7b; \>= 1507f51255c9ff07d75909a84e7c0d7f3c4b2f49, \< f9b141f93659e09a52e28791ccbaf69c273b8e92; Linux 5.14.

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

Yes. Fixed in Linux 9d3b877daf805fed29be8f61aa3d0ea37df82c7b. No fix listed yet: follow the vendor advisory.

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

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/b6d17c67885a5624e96eb30c4178c65eea8374bf>
- patch: <https://git.kernel.org/stable/c/9d3b877daf805fed29be8f61aa3d0ea37df82c7b>
- patch: <https://git.kernel.org/stable/c/f9b141f93659e09a52e28791ccbaf69c273b8e92>

## 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-49049>

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