CVE-2024-43891

Source
https://nvd.nist.gov/vuln/detail/CVE-2024-43891
Import Source
https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2024-43891.json
JSON Data
https://api.osv.dev/v1/vulns/CVE-2024-43891
Downstream
Published
2024-08-26T10:10:44Z
Modified
2025-10-22T01:42:24.280610Z
Summary
tracing: Have format file honor EVENT_FILE_FL_FREED
Details

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

tracing: Have format file honor EVENTFILEFL_FREED

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 event_release() 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 i_private 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 "EVENTFILEFL_FREED", 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.

References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
14aa4f3efc6e784847e8c8543a7ef34ec9bdbb01
Fixed
4ed03758ddf0b19d69eed69386d65a92d0091e0c
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
b63db58e2fa5d6963db9c45df88e60060f0ff35f
Fixed
531dc6780d94245af037c25c2371c8caf652f0f9
Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
b63db58e2fa5d6963db9c45df88e60060f0ff35f
Fixed
b1560408692cd0ab0370cfbe9deb03ce97ab3f6d

Affected versions

v6.*

v6.10
v6.10-rc1
v6.10-rc2
v6.10-rc3
v6.10-rc4
v6.10-rc5
v6.10-rc6
v6.10-rc7
v6.10.1
v6.10.2
v6.10.3
v6.10.4
v6.11-rc1
v6.11-rc2
v6.6.33
v6.6.34
v6.6.35
v6.6.36
v6.6.37
v6.6.38
v6.6.39
v6.6.40
v6.6.41
v6.6.42
v6.6.43
v6.6.44
v6.6.45
v6.6.46
v6.6.47
v6.6.48
v6.9
v6.9-rc7

Database specific

vanir_signatures

[
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b1560408692cd0ab0370cfbe9deb03ce97ab3f6d",
        "signature_version": "v1",
        "deprecated": false,
        "id": "CVE-2024-43891-026ab40d",
        "target": {
            "function": "event_filter_write",
            "file": "kernel/trace/trace_events.c"
        },
        "signature_type": "Function",
        "digest": {
            "length": 483.0,
            "function_hash": "76564836135110646279480326288939396999"
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b1560408692cd0ab0370cfbe9deb03ce97ab3f6d",
        "signature_version": "v1",
        "deprecated": false,
        "id": "CVE-2024-43891-0dddc0f8",
        "target": {
            "function": "f_start",
            "file": "kernel/trace/trace_events.c"
        },
        "signature_type": "Function",
        "digest": {
            "length": 303.0,
            "function_hash": "126509306559752479144697193181460803141"
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b1560408692cd0ab0370cfbe9deb03ce97ab3f6d",
        "signature_version": "v1",
        "deprecated": false,
        "id": "CVE-2024-43891-114652a6",
        "target": {
            "function": "event_filter_read",
            "file": "kernel/trace/trace_events.c"
        },
        "signature_type": "Function",
        "digest": {
            "length": 553.0,
            "function_hash": "87601541264734683860421396580211621406"
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b1560408692cd0ab0370cfbe9deb03ce97ab3f6d",
        "signature_version": "v1",
        "deprecated": false,
        "id": "CVE-2024-43891-1573764f",
        "target": {
            "file": "kernel/trace/trace_events_hist.c"
        },
        "signature_type": "Line",
        "digest": {
            "threshold": 0.9,
            "line_hashes": [
                "285211332221266537767872804189368678688",
                "181600986171283844544477062893546114931",
                "315750770544026149784405209213895052629",
                "105556783218564371760092063786361920591",
                "285211332221266537767872804189368678688",
                "181600986171283844544477062893546114931",
                "315750770544026149784405209213895052629",
                "105556783218564371760092063786361920591"
            ]
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b1560408692cd0ab0370cfbe9deb03ce97ab3f6d",
        "signature_version": "v1",
        "deprecated": false,
        "id": "CVE-2024-43891-19e14cad",
        "target": {
            "function": "event_enable_read",
            "file": "kernel/trace/trace_events.c"
        },
        "signature_type": "Function",
        "digest": {
            "length": 633.0,
            "function_hash": "48768789302233914269040647811491301448"
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b1560408692cd0ab0370cfbe9deb03ce97ab3f6d",
        "signature_version": "v1",
        "deprecated": false,
        "id": "CVE-2024-43891-2f8ceb86",
        "target": {
            "file": "kernel/trace/trace.h"
        },
        "signature_type": "Line",
        "digest": {
            "threshold": 0.9,
            "line_hashes": [
                "276357960718741484828913274906608393130",
                "332026751214239300819412640819187290777",
                "31396793770890110597049709207316885234"
            ]
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b1560408692cd0ab0370cfbe9deb03ce97ab3f6d",
        "signature_version": "v1",
        "deprecated": false,
        "id": "CVE-2024-43891-30b4a928",
        "target": {
            "function": "f_show",
            "file": "kernel/trace/trace_events.c"
        },
        "signature_type": "Function",
        "digest": {
            "length": 1279.0,
            "function_hash": "289187816888815864022298333716458089359"
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b1560408692cd0ab0370cfbe9deb03ce97ab3f6d",
        "signature_version": "v1",
        "deprecated": false,
        "id": "CVE-2024-43891-57e5536a",
        "target": {
            "file": "kernel/trace/trace_events_trigger.c"
        },
        "signature_type": "Line",
        "digest": {
            "threshold": 0.9,
            "line_hashes": [
                "197490478448003013655166809466377260853",
                "14264520952169696378553083869987715613",
                "89222060522971497502085385790318003458",
                "71052947828880606157240951590117530905",
                "129396422707172148659485368459235947991",
                "175976759386868039289632705295300226101",
                "32998686354954259168643735365646644962",
                "154982562133252640121965491335917001391",
                "55578540143537687126817360175698066265",
                "96965249283651581801393056960509256064",
                "15344531904699193624706671055038090962",
                "305289187333245304818201124948950055051"
            ]
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b1560408692cd0ab0370cfbe9deb03ce97ab3f6d",
        "signature_version": "v1",
        "deprecated": false,
        "id": "CVE-2024-43891-b3b2fbda",
        "target": {
            "file": "kernel/trace/trace_events_inject.c"
        },
        "signature_type": "Line",
        "digest": {
            "threshold": 0.9,
            "line_hashes": [
                "221778430250668429316940866784322833344",
                "197434482341774022391671843084610116765",
                "174027264455600451696633487845743225792",
                "241136918296841255280016143260204151201"
            ]
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b1560408692cd0ab0370cfbe9deb03ce97ab3f6d",
        "signature_version": "v1",
        "deprecated": false,
        "id": "CVE-2024-43891-bdbab38c",
        "target": {
            "function": "f_next",
            "file": "kernel/trace/trace_events.c"
        },
        "signature_type": "Function",
        "digest": {
            "length": 562.0,
            "function_hash": "87937961612932747639922361863954629961"
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b1560408692cd0ab0370cfbe9deb03ce97ab3f6d",
        "signature_version": "v1",
        "deprecated": false,
        "id": "CVE-2024-43891-f19c26c9",
        "target": {
            "function": "event_callback",
            "file": "kernel/trace/trace_events.c"
        },
        "signature_type": "Function",
        "digest": {
            "length": 1636.0,
            "function_hash": "188973446450420579298907412526954505995"
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b1560408692cd0ab0370cfbe9deb03ce97ab3f6d",
        "signature_version": "v1",
        "deprecated": false,
        "id": "CVE-2024-43891-f8cc48ab",
        "target": {
            "function": "event_enable_write",
            "file": "kernel/trace/trace_events.c"
        },
        "signature_type": "Function",
        "digest": {
            "length": 630.0,
            "function_hash": "62580893098297228016681973561544747848"
        }
    },
    {
        "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b1560408692cd0ab0370cfbe9deb03ce97ab3f6d",
        "signature_version": "v1",
        "deprecated": false,
        "id": "CVE-2024-43891-fa2abc75",
        "target": {
            "file": "kernel/trace/trace_events.c"
        },
        "signature_type": "Line",
        "digest": {
            "threshold": 0.9,
            "line_hashes": [
                "160349294691955750300824397219433847945",
                "154840112899979802987020254759410868568",
                "189877542397753933536558666114178307982",
                "338636832579485006972294661988963008010",
                "133979670607294772972791429600776236792",
                "7827825186192834617852743311683199095",
                "272827992535410401672998345938872751708",
                "121423964067433268747510694554463781764",
                "36370427033761773060231913595912144214",
                "247484220050874101610074114088105101604",
                "10504488378810473457152456154746916968",
                "18570689164128204303229670734485309774",
                "165328663909161493296522531110739106708",
                "111628175792333494904266123102326895450",
                "78637074207990623348848541183600260196",
                "207981671239376260499079054032876952863",
                "76225912389270835201739180389930389912",
                "115076105269622970363695113789477271485",
                "37120433535467972388129917480222931151",
                "85104410174878253446295466703251695284",
                "49870449815883165130629344284483480538",
                "186774725061138386139848144713795775149",
                "17318422622923814637161291017247937350",
                "198045736236485764503431855086651066281",
                "136977268592076655790108024446715704223",
                "85487617729169438850970403117552701672",
                "240182804256202753873177097435667826879",
                "280813749720867028899962473874564509491",
                "120729554295348838919655233601012933781",
                "128560190435444931233567559517468047995",
                "8525922451288646478316383257452881007",
                "4116636387427008366980284688988045230",
                "161656670448394184070652003663944464329",
                "329188139134952981617269532906834208814",
                "89915134345099810384066929212754559558",
                "228968667583992214238025134613985357843",
                "152532925960897596242503642001217870691",
                "209100007482116373631121000437001354974",
                "88129839790407448383511616177391309782",
                "90487075729801621310073436557623288437",
                "233572466233674540482122716916817086901",
                "141941836735919902723055840362367958571",
                "269099274492925120779325501325912233281",
                "247705119021808586960526513674881456596"
            ]
        }
    }
]

Linux / Kernel

Package

Name
Kernel

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
6.6.49
Type
ECOSYSTEM
Events
Introduced
6.7.0
Fixed
6.10.5