HIGH
bpf Interpreter Integer Overflow
CVE-2026-31525
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
KernelScan AI7.8HIGH
01Description
In the Linux kernel, the following vulnerability has been resolved: bpf: Fix undefined behavior in interpreter sdiv/smod for INT_MIN The BPF interpreter's signed 32-bit division and modulo handlers use the kernel abs() macro on s32 operands. The abs() macro documentation (include/linux/math.h) explicitly states the result is undefined when the input is the type minimum. When DST contains S32_MIN (0x80000000), abs((s32)DST) triggers undefined behavior and returns S32_MIN unchanged on arm64/x86. This value is then sign-extended to u64 as 0xFFFFFFFF80000000, causing do_div() to compute the wrong result. The verifier's abstract interpretation (scalar32_min_max_sdiv) computes the mathematically correct result for range tracking, creating a verifier/interpreter mismatch that can be exploited for out-of-bounds map value access. Introduce abs_s32() which handles S32_MIN correctly by casting to u32 before negating, avoiding signed overflow entirely. Replace all 8 abs((s32)...) call sites in the interpreter's sdiv32/smod32 handlers. s32 is the only affected case -- the s64 division/modulo handlers do not use abs().
02KernelScan AI Analysis
Risk summary
A signed integer overflow in BPF's division operations can cause incorrect computation results, creating a mismatch between the verifier's expectations and actual runtime behavior. This could allow attackers with BPF program loading privileges to access memory outside intended bounds.
Vulnerability analysis
Root Cause: The BPF interpreter's signed 32-bit division and modulo handlers use the kernel abs() macro on s32 operands. When the input is S32_MIN (0x80000000), abs() triggers undefined behavior and returns S32_MIN unchanged instead of the mathematically correct absolute value. This causes incorrect sign extension to u64 (0xFFFFFFFF80000000) and wrong division results.
Attack Surface: Local attack surface requiring the ability to load and execute BPF programs. The vulnerability creates a verifier/interpreter mismatch that can be exploited for out-of-bounds map value access, potentially leading to memory corruption or information disclosure.
Fix Mechanism: The patch introduces a new abs_s32() function that handles S32_MIN correctly by casting to u32 before negating, avoiding signed integer overflow. It replaces all 8 abs((s32)...) call sites in the interpreter's sdiv32/smod32 handlers with calls to abs_s32().
03Fix Versions
| Branch | Fixed in | Patch commit |
|---|---|---|
| 6.12 | 6.12.80 | 9ab1227765c4 |
| 6.18 | 6.18.21 | f14ca604c0ff |
| 6.19 | 6.19.11 | 0d5d8c3ce45c |
| 6.6 | 6.6.131 | 694ea55f1b1c |
| mainline | 7.0 | c77b30bd1dcb |