# CVE-2022-50067: btrfs: unset reloc control if transaction commit fails in prepare\_to\_relocate()

> 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, NVD) `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.33% (percentile 19, 2026-11-26)
- **CWE:** CWE-416
- **Published:** 2025-06-18T11:02:13.127Z
- **Modified:** 2026-06-17T05:22:41.310Z

## Who should check

- Anyone running Linux \>= 1a5353475df8fcaf200fecc9e961a3900d15e891, \< ff0e8ed8dfb584575cffc1561f17a1d094e8565b; \>= 499d29bf151951399367ba83645abfdb429a3af9, \< dcb11fe0a0a9cca2b7425191b9bf30dc29f2ad0f; \>= 4223d91ca1b5bf3928e5722c3c6b3fdb49250ab3, \< 8e546674031fc1576da501e27a8fd165222e5a37; \>= 6f371623f315c26100e603c2e8837cdbe130f9e0, \< b60e862e133f646f19023ece1d476d630a660de1; \>= fb686c6824dd6294ca772b92424b8fba666e7d00, \< 78f8c2370e3d33e35f23bdc648653d779aeacb6e; \>= fb686c6824dd6294ca772b92424b8fba666e7d00, \< 5d741afed0bac206640cc64d77b97853283cf719; \>= fb686c6824dd6294ca772b92424b8fba666e7d00, \< 85f02d6c856b9f3a0acf5219de6e32f58b9778eb
- Anyone running Linux 5.13

## Description

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

btrfs: unset reloc control if transaction commit fails in prepare\_to\_relocate()

In btrfs\_relocate\_block\_group(), the rc is allocated.  Then
btrfs\_relocate\_block\_group() calls

relocate\_block\_group()
  prepare\_to\_relocate()
    set\_reloc\_control()

that assigns rc to the variable fs\_info-\>reloc\_ctl. When
prepare\_to\_relocate() returns, it calls

btrfs\_commit\_transaction()
  btrfs\_start\_dirty\_block\_groups()
    btrfs\_alloc\_path()
      kmem\_cache\_zalloc()

which may fail for example (or other errors could happen). When the
failure occurs, btrfs\_relocate\_block\_group() detects the error and frees
rc and doesn't set fs\_info-\>reloc\_ctl to NULL. After that, in
btrfs\_init\_reloc\_root(), rc is retrieved from fs\_info-\>reloc\_ctl and
then used, which may cause a use-after-free bug.

This possible bug can be triggered by calling btrfs\_ioctl\_balance()
before calling btrfs\_ioctl\_defrag().

To fix this possible bug, in prepare\_to\_relocate(), check if
btrfs\_commit\_transaction() fails. If the failure occurs,
unset\_reloc\_control() is called to set fs\_info-\>reloc\_ctl to NULL.

The error log in our fault-injection testing is shown as follows:

  \[   58.751070\] BUG: KASAN: use-after-free in btrfs\_init\_reloc\_root+0x7ca/0x920 \[btrfs\]
  ...
  \[   58.753577\] Call Trace:
  ...
  \[   58.755800\]  kasan\_report+0x45/0x60
  \[   58.756066\]  btrfs\_init\_reloc\_root+0x7ca/0x920 \[btrfs\]
  \[   58.757304\]  record\_root\_in\_trans+0x792/0xa10 \[btrfs\]
  \[   58.757748\]  btrfs\_record\_root\_in\_trans+0x463/0x4f0 \[btrfs\]
  \[   58.758231\]  start\_transaction+0x896/0x2950 \[btrfs\]
  \[   58.758661\]  btrfs\_defrag\_root+0x250/0xc00 \[btrfs\]
  \[   58.759083\]  btrfs\_ioctl\_defrag+0x467/0xa00 \[btrfs\]
  \[   58.759513\]  btrfs\_ioctl+0x3c95/0x114e0 \[btrfs\]
  ...
  \[   58.768510\] Allocated by task 23683:
  \[   58.768777\]  \_\_\_\_kasan\_kmalloc+0xb5/0xf0
  \[   58.769069\]  \_\_kmalloc+0x227/0x3d0
  \[   58.769325\]  alloc\_reloc\_control+0x10a/0x3d0 \[btrfs\]
  \[   58.769755\]  btrfs\_relocate\_block\_group+0x7aa/0x1e20 \[btrfs\]
  \[   58.770228\]  btrfs\_relocate\_chunk+0xf1/0x760 \[btrfs\]
  \[   58.770655\]  \_\_btrfs\_balance+0x1326/0x1f10 \[btrfs\]
  \[   58.771071\]  btrfs\_balance+0x3150/0x3d30 \[btrfs\]
  \[   58.771472\]  btrfs\_ioctl\_balance+0xd84/0x1410 \[btrfs\]
  \[   58.771902\]  btrfs\_ioctl+0x4caa/0x114e0 \[btrfs\]
  ...
  \[   58.773337\] Freed by task 23683:
  ...
  \[   58.774815\]  kfree+0xda/0x2b0
  \[   58.775038\]  free\_reloc\_control+0x1d6/0x220 \[btrfs\]
  \[   58.775465\]  btrfs\_relocate\_block\_group+0x115c/0x1e20 \[btrfs\]
  \[   58.775944\]  btrfs\_relocate\_chunk+0xf1/0x760 \[btrfs\]
  \[   58.776369\]  \_\_btrfs\_balance+0x1326/0x1f10 \[btrfs\]
  \[   58.776784\]  btrfs\_balance+0x3150/0x3d30 \[btrfs\]
  \[   58.777185\]  btrfs\_ioctl\_balance+0xd84/0x1410 \[btrfs\]
  \[   58.777621\]  btrfs\_ioctl+0x4caa/0x114e0 \[btrfs\]
  ...

## Affected and fixed versions

- Linux: \>= 1a5353475df8fcaf200fecc9e961a3900d15e891, \< ff0e8ed8dfb584575cffc1561f17a1d094e8565b; \>= 499d29bf151951399367ba83645abfdb429a3af9, \< dcb11fe0a0a9cca2b7425191b9bf30dc29f2ad0f; \>= 4223d91ca1b5bf3928e5722c3c6b3fdb49250ab3, \< 8e546674031fc1576da501e27a8fd165222e5a37; \>= 6f371623f315c26100e603c2e8837cdbe130f9e0, \< b60e862e133f646f19023ece1d476d630a660de1; \>= fb686c6824dd6294ca772b92424b8fba666e7d00, \< 78f8c2370e3d33e35f23bdc648653d779aeacb6e; \>= fb686c6824dd6294ca772b92424b8fba666e7d00, \< 5d741afed0bac206640cc64d77b97853283cf719; \>= fb686c6824dd6294ca772b92424b8fba666e7d00, \< 85f02d6c856b9f3a0acf5219de6e32f58b9778eb (cvelist)
- Linux: 5.13 (cvelist)

## Mitigation

- Upgrade Linux to 85f02d6c856b9f3a0acf5219de6e32f58b9778eb or later.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2022-50067.md
Affected: Linux >= 1a5353475df8fcaf200fecc9e961a3900d15e891, < ff0e8ed8dfb584575cffc1561f17a1d094e8565b; >= 499d29bf151951399367ba83645abfdb429a3af9, < dcb11fe0a0a9cca2b7425191b9bf30dc29f2ad0f; >= 4223d91ca1b5bf3928e5722c3c6b3fdb49250ab3, < 8e546674031fc1576da501e27a8fd165222e5a37; >= 6f371623f315c26100e603c…
Fixed in: Linux 8e546674031fc1576da501e27a8fd165222e5a37, Linux 78f8c2370e3d33e35f23bdc648653d779aeacb6e, Linux 5d741afed0bac206640cc64d77b97853283cf719, Linux 85f02d6c856b9f3a0acf5219de6e32f58b9778eb

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

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

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

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

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

Linux \>= 1a5353475df8fcaf200fecc9e961a3900d15e891, \< ff0e8ed8dfb584575cffc1561f17a1d094e8565b; \>= 499d29bf151951399367ba83645abfdb429a3af9, \< dcb11fe0a0a9cca2b7425191b9bf30dc29f2ad0f; \>= 4223d91ca1b5bf3928e5722c3c6b3fdb49250ab3, \< 8e546674031fc1576da501e27a8fd165222e5a37; \>= 6f371623f315c26100e603c2e8837cdbe130f9e0, \< b60e862e133f646f19023ece1d476d630a660de1; \>= fb686c6824dd6294ca772b92424b8fba666e7d00, \< 78f8c2370e3d33e35f23bdc648653d779aeacb6e; \>= fb686c6824dd6294ca772b92424b8fba666e7d00, \< 5d741afed0bac206640cc64d77b97853283cf719; \>= fb686c6824dd6294ca772b92424b8fba666e7d00, \< 85f02d6c856b9f3a0acf5219de6e32f58b9778eb; Linux 5.13.

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

Yes. Fixed in Linux 8e546674031fc1576da501e27a8fd165222e5a37, Linux 78f8c2370e3d33e35f23bdc648653d779aeacb6e, Linux 5d741afed0bac206640cc64d77b97853283cf719, Linux 85f02d6c856b9f3a0acf5219de6e32f58b9778eb. Upgrade Linux to 85f02d6c856b9f3a0acf5219de6e32f58b9778eb or later.

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

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/ff0e8ed8dfb584575cffc1561f17a1d094e8565b>
- patch: <https://git.kernel.org/stable/c/dcb11fe0a0a9cca2b7425191b9bf30dc29f2ad0f>
- patch: <https://git.kernel.org/stable/c/8e546674031fc1576da501e27a8fd165222e5a37>
- patch: <https://git.kernel.org/stable/c/b60e862e133f646f19023ece1d476d630a660de1>
- patch: <https://git.kernel.org/stable/c/78f8c2370e3d33e35f23bdc648653d779aeacb6e>
- patch: <https://git.kernel.org/stable/c/5d741afed0bac206640cc64d77b97853283cf719>
- patch: <https://git.kernel.org/stable/c/85f02d6c856b9f3a0acf5219de6e32f58b9778eb>

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

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