CVE-2024-47741: btrfs: fix race setting file private on concurrent lseek using same fd

Published Oct 21, 2024
·
Updated

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

btrfs: fix race setting file private on concurrent lseek using same fd

When doing concurrent lseek(2) system calls against the same file descriptor, using multiple threads belonging to the same process, we have a short time window where a race happens and can result in a memory leak.

The race happens like this:

1) A program opens a file descriptor for a file and then spawns two threads (with the pthreads library for example), lets call them task A and task B;

2) Task A calls lseek with SEEKDATA or SEEKHOLE and ends up at file.c:finddesiredextent() while holding a read lock on the inode;

3) At the start of finddesiredextent(), it extracts the file's privatedata pointer into a local variable named 'private', which has a value of NULL;

4) Task B also calls lseek with SEEKDATA or SEEKHOLE, locks the inode in shared mode and enters file.c:finddesiredextent(), where it also extracts file->privatedata into its local variable 'private', which has a NULL value;

5) Because it saw a NULL file private, task A allocates a private structure and assigns to the file structure;

6) Task B also saw a NULL file private so it also allocates its own file private and then assigns it to the same file structure, since both tasks are using the same file descriptor.

At this point we leak the private structure allocated by task A.

Besides the memory leak, there's also the detail that both tasks end up using the same cached state record in the private structure (struct btrfsfileprivate::llseekcachedstate), which can result in a use-after-free problem since one task can free it while the other is still using it (only one task took a reference count on it). Also, sharing the cached state is not a good idea since it could result in incorrect results in the future - right now it should not be a problem because it end ups being used only in extent-io-tree.c:countrangebits() where we do range validation before using the cached state.

Fix this by protecting the private assignment and check of a file while holding the inode's spinlock and keep track of the task that allocated the private, so that it's used only by that task in order to prevent user-after-free issues with the cached state record as well as potentially using it incorrectly in the future.

Other sources

This CVE was automatically created from a reference found in an email or other text. If you are reading this, then this CVE entry is probably erroneous, since this text should be replaced by the official CVE description automatically.

Launchpad

Affected Software

4 affected componentsFixes available
Linux Linux kernel>=6.2<6.6.54
Linux Linux kernel>=6.7<6.10.13
Linux Linux kernel>=6.11<6.11.2
debian/linux
5.10.223-15.10.234-16.1.129-16.1.135-16.12.25-16.12.27-1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade debian/linux to a version that resolves this vulnerability.

    Fixed in 5.10.223-1Fixed in 5.10.234-1Fixed in 6.1.129-1Fixed in 6.1.135-1Fixed in 6.12.25-1Fixed in 6.12.27-1

Event History

Oct 21, 2024
CVE Published
via MITRE·12:14 PM
Data Sourced
via MITRE·12:14 PM
DescriptionSeverity
Data Sourced
via NVD·01:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Feb 20, 2025
Data Sourced
via Launchpad·12:47 AM
Description
Apr 5, 2025
Data Sourced
via Ubuntu·12:58 AM
RemedyDescriptionSeverityAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2024-47741?

CVE-2024-47741 is categorized as a medium severity vulnerability in the Linux kernel.

2

How do I fix CVE-2024-47741?

To fix CVE-2024-47741, update the Linux kernel to a version that includes the security fix, specifically above 6.6.54, or between 6.7 and 6.10.13, or between 6.11 and 6.11.2.

3

Which Linux kernel versions are affected by CVE-2024-47741?

CVE-2024-47741 affects Linux kernel versions between 6.2 and 6.6.54, between 6.7 and 6.10.13, and between 6.11 and 6.11.2.

4

What does CVE-2024-47741 affect in the Linux kernel?

CVE-2024-47741 affects the btrfs filesystem by introducing a race condition during concurrent lseek system calls on the same file descriptor.

5

Is CVE-2024-47741 a local or remote vulnerability?

CVE-2024-47741 is considered a local vulnerability as it requires multiple threads belonging to the same process to exploit.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203