btrfs: fix race between direct IO write and fsync when using same fd
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
| No fix yet |
| Linux Linux |
| No fix yet |
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;
From the CVE record · Linux
A race in btrfs can occur when two threads in a local program use the same O_DIRECT file descriptor for direct I/O writes and fsync. It can cause an assertion failure or an invalid memory access in the kernel. Exploitation requires the ability to run a program that performs these operations; no separate user interaction is described.
Engineers running Linux systems that use btrfs should check their kernel versions; the affected versions are not specified.