bpf: Fix overrunning reservations in ringbuf
Published Jul 17, 2024
7.8
HIGHCVSS 3.1
EPSS 0.27%
Description
The BPF ring buffer internally is implemented as a power-of-2 sized circular buffer, with two logical and ever-increasing counters: consumer_pos is the consumer counter to show which logical position the consumer consumed the data, and producer_pos which is the producer counter denoting the amount of data reserved by all producers.
Each time a record is reserved, the producer that "owns" the record will successfully advance producer counter. In user space each time a record is read, the consumer of the data advanced the consumer counter once it finished processing. Both counters are stored in separate pages so that from user space, the producer counter is read-only and the consumer counter is read-write.
One aspect that simplifies and thus speeds up the implementation of both producers and consumers is how the data area is mapped twice contiguously back-to-back in the virtual memory, allowing to not take any special measures for samples that have to wrap around at the end of the circular buffer data area, because the next page after the last data page would be first data page again, and thus the sample will still appear completely contiguous in virtual memory.
Each record has a struct bpf_ringbuf_hdr { u32 len; u32 pg_off; } header for book-keeping the length and offset, and is inaccessible to the BPF program. Helpers like bpf_ringbuf_reserve() return `(void *)hdr + BPF_RINGBUF_HDR_SZ` for the BPF program to use. Bing-Jhong and Muhammad reported that it is however possible to make a second allocated memory chunk overlapping with the first chunk and as a result, the BPF program is now able to edit first chunk's header.
For example, consider the creation of a BPF_MAP_TYPE_RINGBUF map with size of 0x4000. Next, the consumer_pos is modified to 0x3000 /before/ a call to bpf_ringbuf_reserve() is made. This will allocate a chunk A, which is in [0x0,0x3008], and the BPF program is able to edit [0x8,0x3008]. Now, lets allocate a chunk B with size 0x3000. This will succeed because consumer_pos was edited ahead of time to pass the `new_prod_pos - cons_pos > rb->mask` check. Chunk B will be in range [0x3008,0x6010], and the BPF program is able to edit [0x3010,0x6010]. Due to the ring buffer memory layout mentioned earlier, the ranges [0x0,0x4000] and [0x4000,0x8000] point to the same data pages. This means that chunk B at [0x4000,0x4008] is chunk A's header. bpf_ringbuf_submit() / bpf_ringbuf_discard() use the header's pg_off to then locate the bpf_ringbuf itself via bpf_ringbuf_restore_from_rec(). Once chunk B modified chunk A's header, then bpf_ringbuf_commit() refers to the wrong page and could cause a crash.
Fix it by calculating the oldest pending_pos and check whether the range from the oldest outstanding record to the newest would span beyond the ring buffer size. If that is the case, then reject the request. We've tested with the ring buffer benchmark in BPF selftests (./benchs/run_bench_ringbufs.sh) before/after the fix and while it seems a bit slower on some benchmarks, it is still not significantly enough to matter.
Affected products
-
- Version 457f44363a88StatusaffectedConstraints<0f98f40eb1ed
- Version 457f44363a88StatusaffectedConstraints<47416c852f2a
- Version 457f44363a88StatusaffectedConstraints<511804ab701c
- Version 457f44363a88StatusaffectedConstraints<be35504b959f
- Version 457f44363a88StatusaffectedConstraints<cfa1a2329a69
- Version 457f44363a88StatusaffectedConstraints<d1b9df0435bc
- Version
-
- Version 5.8StatusaffectedConstraints-
- Version 0StatusunaffectedConstraints<5.8
- Version 5.10.223StatusunaffectedConstraints<=5.10.*
- Version 5.15.164StatusunaffectedConstraints<=5.15.*
- Version 6.1.97StatusunaffectedConstraints<=6.1.*
- Version 6.10StatusunaffectedConstraints<=*
- Version 6.6.37StatusunaffectedConstraints<=6.6.*
- Version 6.9.8StatusunaffectedConstraints<=6.9.*
- Version
Default status is the baseline for the product, each version can override it (e.g. patched versions marked unaffected).
| Vendor | Product | Default status | Versions | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Linux | Linux | unaffected |
| |||||||||||||||||||||||||||
| Linux | Linux | affected |
|
- ≥ 5.8 · < 6.1.97
- ≥ 6.2 · < 6.6.37
- ≥ 6.7 · < 6.9.8
No data.
Red Hat Enterprise Linux 8
kernel-0:4.18.0-553.27.1.el8_10
Fixed · RHSA-2024:8856
Red Hat Enterprise Linux 8
kernel-rt-0:4.18.0-553.27.1.rt7.368.el8_10
Fixed · RHSA-2024:8870
Red Hat Enterprise Linux 8.6 Advanced Mission Critical Update Support
kernel-0:4.18.0-372.123.1.el8_6
Fixed · RHSA-2024:6753
Red Hat Enterprise Linux 8.6 Telecommunications Update Service
kernel-0:4.18.0-372.123.1.el8_6
Fixed · RHSA-2024:6753
Red Hat Enterprise Linux 8.6 Update Services for SAP Solutions
kernel-0:4.18.0-372.123.1.el8_6
Fixed · RHSA-2024:6753
Red Hat Enterprise Linux 8.8 Extended Update Support
kernel-0:4.18.0-477.81.1.el8_8
Fixed · RHSA-2024:10262
Red Hat Enterprise Linux 9
kernel-0:5.14.0-503.15.1.el9_5
Fixed · RHSA-2024:10274
Red Hat Enterprise Linux 9
kernel-0:5.14.0-503.15.1.el9_5
Fixed · RHSA-2024:10274
Red Hat Enterprise Linux 9.2 Extended Update Support
kernel-0:5.14.0-284.95.1.el9_2
Fixed · RHSA-2024:10772
Red Hat Enterprise Linux 9.2 Extended Update Support
kernel-rt-0:5.14.0-284.95.1.rt14.380.el9_2
Fixed · RHSA-2024:10773
Red Hat Enterprise Linux 9.4 Extended Update Support
kernel-0:5.14.0-427.47.1.el9_4
Fixed · RHSA-2024:10771
Red Hat Enterprise Linux 6
kernel
Not affected
Red Hat Enterprise Linux 7
kernel
Out of support scope
Red Hat Enterprise Linux 7
kernel-rt
Out of support scope
Red Hat Enterprise Linux 9
kernel-rt
Will not fix
| Product | Package | State | Advisory |
|---|---|---|---|
| Red Hat Enterprise Linux 8 | kernel-0:4.18.0-553.27.1.el8_10 | Fixed | RHSA-2024:8856 |
| Red Hat Enterprise Linux 8 | kernel-rt-0:4.18.0-553.27.1.rt7.368.el8_10 | Fixed | RHSA-2024:8870 |
| Red Hat Enterprise Linux 8.6 Advanced Mission Critical Update Support | kernel-0:4.18.0-372.123.1.el8_6 | Fixed | RHSA-2024:6753 |
| Red Hat Enterprise Linux 8.6 Telecommunications Update Service | kernel-0:4.18.0-372.123.1.el8_6 | Fixed | RHSA-2024:6753 |
| Red Hat Enterprise Linux 8.6 Update Services for SAP Solutions | kernel-0:4.18.0-372.123.1.el8_6 | Fixed | RHSA-2024:6753 |
| Red Hat Enterprise Linux 8.8 Extended Update Support | kernel-0:4.18.0-477.81.1.el8_8 | Fixed | RHSA-2024:10262 |
| Red Hat Enterprise Linux 9 | kernel-0:5.14.0-503.15.1.el9_5 | Fixed | RHSA-2024:10274 |
| Red Hat Enterprise Linux 9 | kernel-0:5.14.0-503.15.1.el9_5 | Fixed | RHSA-2024:10274 |
| Red Hat Enterprise Linux 9.2 Extended Update Support | kernel-0:5.14.0-284.95.1.el9_2 | Fixed | RHSA-2024:10772 |
| Red Hat Enterprise Linux 9.2 Extended Update Support | kernel-rt-0:5.14.0-284.95.1.rt14.380.el9_2 | Fixed | RHSA-2024:10773 |
| Red Hat Enterprise Linux 9.4 Extended Update Support | kernel-0:5.14.0-427.47.1.el9_4 | Fixed | RHSA-2024:10771 |
| Red Hat Enterprise Linux 6 | kernel | Not affected | n/a |
| Red Hat Enterprise Linux 7 | kernel | Out of support scope | n/a |
| Red Hat Enterprise Linux 7 | kernel-rt | Out of support scope | n/a |
| Red Hat Enterprise Linux 9 | kernel-rt | Will not fix | n/a |
No package ranges for this CVE.
Remediation
Red Hat mitigation
Mitigation for this issue is either not available or the currently available options don't meet the Red Hat Product Security criteria comprising ease of use and deployment, applicability to widespread installation base or stability.
Metrics
No CVSS v4.0 score for this CVE.
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H
2 other sources (CVE.org, Red Hat) ▾
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:U/C:N/I:N/A:H
No CVSS v3.0 score for this CVE.
No CVSS v2.0 score for this CVE.
This CVE is not in the KEV list.
CISA SSVC (Vulnrichment)
Stakeholder-Specific Vulnerability Categorization from CISA ADP.
Exploitation
NoneAutomatable
NoTechnical Impact
PartialDecision
n/aAssessed Sep 10, 2024 · SSVC 2.0.3
Estimated probability of exploitation in the wild in the next 30 days (FIRST EPSS). As of Oct 3, 2026.
Score over time
2024–2026- EPSS v3
- EPSS v4
- EPSS v5
Percentile over time
- EPSS v3
- EPSS v4
- EPSS v5
Table of values (5 key points)
Flat stretches are collapsed; showing up to 120 newest points.
| Date | Score | Percentile | Model |
|---|---|---|---|
| Oct 3, 2026 | 0.27% (0.00272) | 17.75th | v5 (v2026.06.15) |
| Jun 15, 2026 | 0.26% (0.00261) | 17.22th | v5 (v2026.06.15) |
| Mar 17, 2025 | 0.09% (0.00093) | 24.16th | v4 (v2025.03.14) |
| Dec 12, 2024 | 0.04% (0.00042) | 5.07th | v3 (v2023.03.01) |
| Jul 17, 2024 | 0.04% (0.00045) | 16.00th | v3 (v2023.03.01) |
References (12)
- https://access.redhat.com/security/cve/CVE-2024-41009 Vendor Advisory
- https://bugzilla.redhat.com/show_bug.cgi?id=2298412 Issue Tracking
- https://git.kernel.org/stable/c/0f98f40eb1ed52af8b81f61901b6c0289ff59de4
- https://git.kernel.org/stable/c/47416c852f2a04d348ea66ee451cbdcf8119f225 Mailing ListPatch
- https://git.kernel.org/stable/c/511804ab701c0503b72eac08217eabfd366ba069 Mailing ListPatch
- https://git.kernel.org/stable/c/be35504b959f2749bab280f4671e8df96dcf836f
- https://git.kernel.org/stable/c/cfa1a2329a691ffd991fcf7248a57d752e712881 Mailing ListPatch
- https://git.kernel.org/stable/c/d1b9df0435bc61e0b44f578846516df8ef476686 Mailing ListPatch
- https://lists.debian.org/debian-lts-announce/2025/01/msg00001.html
- https://lore.kernel.org/linux-cve-announce/2024071715-CVE-2024-41009-cac5@gregkh/T
- https://nvd.nist.gov/vuln/detail/CVE-2024-41009
- https://www.cve.org/CVERecord?id=CVE-2024-41009
Change history (0)
No recorded changes yet.