CVE-2024-43891: tracing: Have format file honor EVENT_FILE_FL_FREED

Published Aug 26, 2024
·
Updated

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

tracing: Have format file honor EVENTFILEFLFREED

When eventfs was introduced, special care had to be done to coordinate the freeing of the file meta data with the files that are exposed to user space. The file meta data would have a ref count that is set when the file is created and would be decremented and freed after the last user that opened the file closed it. When the file meta data was to be freed, it would set a flag (EVENTFILEFLFREED) to denote that the file is freed, and any new references made (like new opens or reads) would fail as it is marked freed. This allowed other meta data to be freed after this flag was set (under the eventmutex).

All the files that were dynamically created in the events directory had a pointer to the file meta data and would call eventrelease() when the last reference to the user space file was closed. This would be the time that it is safe to free the file meta data.

A shortcut was made for the "format" file. It's iprivate would point to the "call" entry directly and not point to the file's meta data. This is because all format files are the same for the same "call", so it was thought there was no reason to differentiate them. The other files maintain state (like the "enable", "trigger", etc). But this meant if the file were to disappear, the "format" file would be unaware of it.

This caused a race that could be trigger via the userevents test (that would create dynamic events and free them), and running a loop that would read the userevents format files:

In one console run:

# cd tools/testing/selftests/userevents # while true; do ./ftracetest; done

And in another console run:

# cd /sys/kernel/tracing/ # while true; do cat events/userevents/testevent/format; done 2>/dev/null

With KASAN memory checking, it would trigger a use-after-free bug report (which was a real bug). This was because the format file was not checking the file's meta data flag "EVENTFILEFLFREED", so it would access the event that the file meta data pointed to after the event was freed.

After inspection, there are other locations that were found to not check the EVENTFILEFLFREED flag when accessing the traceeventfile. Add a new helper function: eventfilefile() that will make sure that the eventmutex is held, and will return NULL if the traceeventfile has the EVENTFILEFLFREED flag set. Have the first reference of the struct file pointer use eventfilefile() and check for NULL. Later uses can still use the eventfiledata() helper function if the eventmutex is still held and was not released since the eventfilefile() call.

Affected Software

5 affected componentsFixes available
Linux Linux kernel>=6.6.33<6.6.49
Linux Linux kernel>=6.9<6.10.5
Linux Linux kernel=6.11-rc1
Linux Linux kernel=6.11-rc2
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
  2. Configuration

    Update the kernel tracing user_events “format” file implementation so that the first reference to the trace_event_file’s struct file pointer uses the new helper event_file_file(), and returns NULL if the trace_event_file has the EVENT_FILE_FL_FREED flag set; this prevents reading the event after the file meta data has been freed.

    Linux kernel tracing (eventfs/user_events) Honor EVENT_FILE_FL_FREED in tracing format file access = enabled
  3. Configuration

    In remaining locations that access the trace_event_file, ensure they check EVENT_FILE_FL_FREED when accessing trace_event_file; allow later uses of event_file_data() only if the event_mutex is still held and was not released since the event_file_file() call.

    Linux kernel tracing (eventfs/user_events) event_file_data() usage = restricted to cases where event_mutex is held

Event History

Aug 26, 2024
CVE Published
via MITRE·10:10 AM
Data Sourced
via MITRE·10:10 AM
DescriptionSeverity
Data Sourced
via NVD·11:15 AM
RemedyDescriptionSeverityWeaknessAffected Software
Jan 9, 2025
Data Sourced
via Ubuntu·06:29 PM
RemedyDescriptionSeverityAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2024-43891?

The severity of CVE-2024-43891 has not been explicitly rated in the available information.

2

How do I fix CVE-2024-43891?

To fix CVE-2024-43891, upgrade your Linux kernel to version 5.10.223-1, 5.10.234-1, 6.1.123-1, 6.1.128-1, or 6.12.17-1.

3

What versions of the Linux kernel are affected by CVE-2024-43891?

CVE-2024-43891 affects various versions of the Linux kernel between 6.6.33 and 6.6.49, 6.9 to 6.10.5, and specifically 6.11-rc1 and 6.11-rc2.

4

What type of vulnerability is CVE-2024-43891?

CVE-2024-43891 is related to the eventfs system in the Linux kernel, particularly concerning the handling of file metadata.

5

Who is responsible for addressing CVE-2024-43891?

The maintainers of the Linux kernel are responsible for addressing CVE-2024-43891 by providing updates and patches.

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