# CVE-2024-46734: btrfs: fix race between direct IO write and fsync when using same fd

> 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.24% (percentile 9, 2026-11-26)
- **CWE:** CWE-362
- **Published:** 2024-09-18T07:11:56.361Z
- **Modified:** 2026-08-05T11:38:11.716Z

## Who should check

- Anyone running Linux \>= 4e17707035a65f6e5b2a4d987a308cf8ed8c5ad1, \< d116a0b0e02f395cedfb8c725bd67480aa7c428c; \>= 6cae8d04d8b3d1ecfadcaa989e673f6f73349ed5, \< cd3087582e4fa36e89be4e6f859e75a4400292b4; \>= 0a108bde616a7017653385b5a12111015051a294, \< 7b5595f33c3c273613b590892a578d78186bb400; \>= 3831170f740685fddc8f6aa57a83ad0fef4711bf, \< 01681aa609b5f110502f56c4e3b2938efcf4a5bc; \>= 939b656bc8ab203fdbde26ccac22bcb7f0985be5, \< cd9253c23aedd61eb5ff11f37a36247cd46faf86
- Anyone running Linux \>= 5.15.165, \< 5.15.167; \>= 6.1.105, \< 6.1.110; \>= 6.6.46, \< 6.6.51; \>= 6.10.5, \< 6.10.10

## Description

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

btrfs: fix race between direct IO write and fsync when using same fd

If we have 2 threads that are using the same file descriptor and one of
them is doing direct IO writes while the other is doing fsync, we have a
race where we can end up either:

1) Attempt a fsync without holding the inode's lock, triggering an
   assertion failures when assertions are enabled;

2) Do an invalid memory access from the fsync task because the file private
   points to memory allocated on stack by the direct IO task and it may be
   used by the fsync task after the stack was destroyed.

The race happens like this:

1) A user space program opens a file descriptor with O\_DIRECT;

2) The program spawns 2 threads using libpthread for example;

3) One of the threads uses the file descriptor to do direct IO writes,
   while the other calls fsync using the same file descriptor.

4) Call task A the thread doing direct IO writes and task B the thread
   doing fsyncs;

5) Task A does a direct IO write, and at btrfs\_direct\_write() sets the
   file's private to an on stack allocated private with the member
   'fsync\_skip\_inode\_lock' set to true;

6) Task B enters btrfs\_sync\_file() and sees that there's a private
   structure associated to the file which has 'fsync\_skip\_inode\_lock' set
   to true, so it skips locking the inode's VFS lock;

7) Task A completes the direct IO write, and resets the file's private to
   NULL since it had no prior private and our private was stack allocated.
   Then it unlocks the inode's VFS lock;

8) Task B enters btrfs\_get\_ordered\_extents\_for\_logging(), then the
   assertion that checks the inode's VFS lock is held fails, since task B
   never locked it and task A has already unlocked it.

The stack trace produced is the following:

   assertion failed: inode\_is\_locked(&inode-\>vfs\_inode), in fs/btrfs/ordered-data.c:983
   ------------\[ cut here \]------------
   kernel BUG at fs/btrfs/ordered-data.c:983!
   Oops: invalid opcode: 0000 \[\#1\] PREEMPT SMP PTI
   CPU: 9 PID: 5072 Comm: worker Tainted: G     U     OE      6.10.5-1-default \#1 openSUSE Tumbleweed 69f48d427608e1c09e60ea24c6c55e2ca1b049e8
   Hardware name: Acer Predator PH315-52/Covini\_CFS, BIOS V1.12 07/28/2020
   RIP: 0010:btrfs\_get\_ordered\_extents\_for\_logging.cold+0x1f/0x42 \[btrfs\]
   Code: 50 d6 86 c0 e8 (...)
   RSP: 0018:ffff9e4a03dcfc78 EFLAGS: 00010246
   RAX: 0000000000000054 RBX: ffff9078a9868e98 RCX: 0000000000000000
   RDX: 0000000000000000 RSI: ffff907dce4a7800 RDI: ffff907dce4a7800
   RBP: ffff907805518800 R08: 0000000000000000 R09: ffff9e4a03dcfb38
   R10: ffff9e4a03dcfb30 R11: 0000000000000003 R12: ffff907684ae7800
   R13: 0000000000000001 R14: ffff90774646b600 R15: 0000000000000000
   FS:  00007f04b96006c0(0000) GS:ffff907dce480000(0000) knlGS:0000000000000000
   CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
   CR2: 00007f32acbfc000 CR3: 00000001fd4fa005 CR4: 00000000003726f0
   Call Trace:
    \<TASK\>
    ? \_\_die\_body.cold+0x14/0x24
    ? die+0x2e/0x50
    ? do\_trap+0xca/0x110
    ? do\_error\_trap+0x6a/0x90
    ? btrfs\_get\_ordered\_extents\_for\_logging.cold+0x1f/0x42 \[btrfs bb26272d49b4cdc847cf3f7faadd459b62caee9a\]
    ? exc\_invalid\_op+0x50/0x70
    ? btrfs\_get\_ordered\_extents\_for\_logging.cold+0x1f/0x42 \[btrfs bb26272d49b4cdc847cf3f7faadd459b62caee9a\]
    ? asm\_exc\_invalid\_op+0x1a/0x20
    ? btrfs\_get\_ordered\_extents\_for\_logging.cold+0x1f/0x42 \[btrfs bb26272d49b4cdc847cf3f7faadd459b62caee9a\]
    ? btrfs\_get\_ordered\_extents\_for\_logging.cold+0x1f/0x42 \[btrfs bb26272d49b4cdc847cf3f7faadd459b62caee9a\]
    btrfs\_sync\_file+0x21a/0x4d0 \[btrfs bb26272d49b4cdc847cf3f7faadd459b62caee9a\]
    ? \_\_seccomp\_filter+0x31d/0x4f0
    \_\_x64\_sys\_fdatasync+0x4f/0x90
    do\_syscall\_64+0x82/0x160
    ? do\_futex+0xcb/0x190
    ? \_\_x64\_sys\_futex+0x10e/0x1d0
    ? switch\_fpu\_return+0x4f/0xd0
    ? syscall\_exit\_to\_user\_mode+0x72/0x220
    ? do\_syscall\_64+0x8e/0x160
    ? syscall\_exit\_to\_user\_mod
---truncated---

## Affected and fixed versions

- Linux: \>= 4e17707035a65f6e5b2a4d987a308cf8ed8c5ad1, \< d116a0b0e02f395cedfb8c725bd67480aa7c428c; \>= 6cae8d04d8b3d1ecfadcaa989e673f6f73349ed5, \< cd3087582e4fa36e89be4e6f859e75a4400292b4; \>= 0a108bde616a7017653385b5a12111015051a294, \< 7b5595f33c3c273613b590892a578d78186bb400; \>= 3831170f740685fddc8f6aa57a83ad0fef4711bf, \< 01681aa609b5f110502f56c4e3b2938efcf4a5bc; \>= 939b656bc8ab203fdbde26ccac22bcb7f0985be5, \< cd9253c23aedd61eb5ff11f37a36247cd46faf86 (cvelist)
- Linux: \>= 5.15.165, \< 5.15.167; \>= 6.1.105, \< 6.1.110; \>= 6.6.46, \< 6.6.51; \>= 6.10.5, \< 6.10.10 (cvelist)

## Mitigation

- Upgrade Linux to 6.10.10 or later.

## Check your systems with an agent

Paste this into a coding agent:

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

Details: https://flawdb.com/CVE-2024-46734.md
Affected: Linux >= 4e17707035a65f6e5b2a4d987a308cf8ed8c5ad1, < d116a0b0e02f395cedfb8c725bd67480aa7c428c; >= 6cae8d04d8b3d1ecfadcaa989e673f6f73349ed5, < cd3087582e4fa36e89be4e6f859e75a4400292b4; >= 0a108bde616a7017653385b5a12111015051a294, < 7b5595f33c3c273613b590892a578d78186bb400; >= 3831170f740685fddc8f6aa…
Fixed in: Linux 7b5595f33c3c273613b590892a578d78186bb400, Linux 01681aa609b5f110502f56c4e3b2938efcf4a5bc, Linux 5.15.167, Linux 6.1.110, Linux 6.6.51, Linux 6.10.10

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-2024-46734 being exploited?

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

### How serious is CVE-2024-46734?

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

### Which versions are affected by CVE-2024-46734?

Linux \>= 4e17707035a65f6e5b2a4d987a308cf8ed8c5ad1, \< d116a0b0e02f395cedfb8c725bd67480aa7c428c; \>= 6cae8d04d8b3d1ecfadcaa989e673f6f73349ed5, \< cd3087582e4fa36e89be4e6f859e75a4400292b4; \>= 0a108bde616a7017653385b5a12111015051a294, \< 7b5595f33c3c273613b590892a578d78186bb400; \>= 3831170f740685fddc8f6aa57a83ad0fef4711bf, \< 01681aa609b5f110502f56c4e3b2938efcf4a5bc; \>= 939b656bc8ab203fdbde26ccac22bcb7f0985be5, \< cd9253c23aedd61eb5ff11f37a36247cd46faf86; Linux \>= 5.15.165, \< 5.15.167; \>= 6.1.105, \< 6.1.110; \>= 6.6.46, \< 6.6.51; \>= 6.10.5, \< 6.10.10.

### Is there a fix for CVE-2024-46734?

Yes. Fixed in Linux 7b5595f33c3c273613b590892a578d78186bb400, Linux 01681aa609b5f110502f56c4e3b2938efcf4a5bc, Linux 5.15.167, Linux 6.1.110, Linux 6.6.51, Linux 6.10.10. Upgrade Linux to 6.10.10 or later.

### How do I check if I'm affected by CVE-2024-46734?

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/d116a0b0e02f395cedfb8c725bd67480aa7c428c>
- patch: <https://git.kernel.org/stable/c/cd3087582e4fa36e89be4e6f859e75a4400292b4>
- patch: <https://git.kernel.org/stable/c/7b5595f33c3c273613b590892a578d78186bb400>
- patch: <https://git.kernel.org/stable/c/01681aa609b5f110502f56c4e3b2938efcf4a5bc>
- patch: <https://git.kernel.org/stable/c/cd9253c23aedd61eb5ff11f37a36247cd46faf86>
- other: <https://lists.debian.org/debian-lts-announce/2025/01/msg00001.html>

## 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-2024-46734>

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