{"id":"CVE-2025-40169","state":"PUBLISHED","title":"bpf: Reject negative offsets for ALU ops","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Reject negative offsets for ALU ops\n\nWhen verifying BPF programs, the check_alu_op() function validates\ninstructions with ALU operations. The 'offset' field in these\ninstructions is a signed 16-bit integer.\n\nThe existing check 'insn->off > 1' was intended to ensure the offset is\neither 0, or 1 for BPF_MOD/BPF_DIV. However, because 'insn->off' is\nsigned, this check incorrectly accepts all negative values (e.g., -1).\n\nThis commit tightens the validation by changing the condition to\n'(insn->off != 0 && insn->off != 1)'. This ensures that any value\nother than the explicitly permitted 0 and 1 is rejected, hardening the\nverifier against malformed BPF programs.","publishedAt":"2025-11-12T10:46:51.736Z","updatedAt":"2026-10-15T22:02:39.320Z","severity":{"score":7.8,"label":"High","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"Linux"},"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"ec0e2da95f72d4a46050a4d994e4fe471474fd80","status":"affected","lessThan":"3bce44b344040e5eef3d64d38b157c15304c0aab","versionType":"git"},{"version":"ec0e2da95f72d4a46050a4d994e4fe471474fd80","status":"affected","lessThan":"5017c302ca4b2a45149ad64e058fa2d5623c068f","versionType":"git"},{"version":"ec0e2da95f72d4a46050a4d994e4fe471474fd80","status":"affected","lessThan":"21167bf70dbe400563e189ac632258d35eda38b5","versionType":"git"},{"version":"ec0e2da95f72d4a46050a4d994e4fe471474fd80","status":"affected","lessThan":"55c0ced59fe17dee34e9dfd5f7be63cbab207758","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/verifier.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.6","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.6","versionType":"semver"},{"version":"6.6.112","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.12.53","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.17.3","status":"unaffected","lessThanOrEqual":"6.17.*","versionType":"semver"},{"version":"6.18","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/verifier.c"]}],"references":["https://git.kernel.org/stable/c/3bce44b344040e5eef3d64d38b157c15304c0aab","https://git.kernel.org/stable/c/5017c302ca4b2a45149ad64e058fa2d5623c068f","https://git.kernel.org/stable/c/21167bf70dbe400563e189ac632258d35eda38b5","https://git.kernel.org/stable/c/55c0ced59fe17dee34e9dfd5f7be63cbab207758"],"weaknesses":[],"ingestedAt":"2026-10-29T20:09:09.358Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2025/40xxx/CVE-2025-40169.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2025-40169","state":"PUBLISHED","datePublished":"2025-11-12T10:46:51.736Z","dateUpdated":"2026-10-15T22:02:39.320Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2025-04-16T07:20:57.176Z"},"containers":{"cna":{"title":"bpf: Reject negative offsets for ALU ops","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Reject negative offsets for ALU ops\n\nWhen verifying BPF programs, the check_alu_op() function validates\ninstructions with ALU operations. The 'offset' field in these\ninstructions is a signed 16-bit integer.\n\nThe existing check 'insn->off > 1' was intended to ensure the offset is\neither 0, or 1 for BPF_MOD/BPF_DIV. However, because 'insn->off' is\nsigned, this check incorrectly accepts all negative values (e.g., -1).\n\nThis commit tightens the validation by changing the condition to\n'(insn->off != 0 && insn->off != 1)'. This ensures that any value\nother than the explicitly permitted 0 and 1 is rejected, hardening the\nverifier against malformed BPF programs."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"ec0e2da95f72d4a46050a4d994e4fe471474fd80","status":"affected","lessThan":"3bce44b344040e5eef3d64d38b157c15304c0aab","versionType":"git"},{"version":"ec0e2da95f72d4a46050a4d994e4fe471474fd80","status":"affected","lessThan":"5017c302ca4b2a45149ad64e058fa2d5623c068f","versionType":"git"},{"version":"ec0e2da95f72d4a46050a4d994e4fe471474fd80","status":"affected","lessThan":"21167bf70dbe400563e189ac632258d35eda38b5","versionType":"git"},{"version":"ec0e2da95f72d4a46050a4d994e4fe471474fd80","status":"affected","lessThan":"55c0ced59fe17dee34e9dfd5f7be63cbab207758","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/verifier.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.6","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.6","versionType":"semver"},{"version":"6.6.112","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.12.53","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.17.3","status":"unaffected","lessThanOrEqual":"6.17.*","versionType":"semver"},{"version":"6.18","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["kernel/bpf/verifier.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/3bce44b344040e5eef3d64d38b157c15304c0aab"},{"url":"https://git.kernel.org/stable/c/5017c302ca4b2a45149ad64e058fa2d5623c068f"},{"url":"https://git.kernel.org/stable/c/21167bf70dbe400563e189ac632258d35eda38b5"},{"url":"https://git.kernel.org/stable/c/55c0ced59fe17dee34e9dfd5f7be63cbab207758"}],"metrics":[{"cvssV3_1":{"version":"3.1","vectorString":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","baseScore":7.8,"baseSeverity":"HIGH"},"scenarios":[{"lang":"en","value":"AV:L - The vulnerable code is reached through the local `bpf(BPF_PROG_LOAD)` syscall, which invokes `bpf_check()` → `do_check()` → `check_alu_op()`. Although the resulting program later executes on packet receive, loading the malformed instruction requires local system access.\nAC:L - Exploitation is fully deterministic: emit a `BPF_DIV`/`BPF_MOD` instruction with `off = -1`, set the dividend to `LLONG_MIN` and the divisor to `-1`, and run it. There is no race, no timing window, and no dependence on memory layout or system state the attacker cannot control.\nPR:L - `sysctl_unprivileged_bpf_disabled` defaults to 0 unless `CONFIG_BPF_UNPRIV_DEFAULT_OFF` is built in (Android and many embedded/distro configs leave it enabled), and `kernel/bpf/syscall.c:2941` explicitly permits `BPF_PROG_TYPE_SOCKET_FILTER` and `BPF_PROG_TYPE_CGROUP_SKB` loads with no `bpf_cap`; the program is then triggered via `SO_ATTACH_BPF` on the attacker's own socket. Where unprivileged BPF is disabled, `bpf_token_capable()` grants `ns_capable()`-level CAP_BPF inside a delegated user namespace, so real root is never required.\nUI:N - The attacker loads and triggers the BPF program entirely on their own, by attaching it to a socket they own and sending themselves a packet. No victim action of any kind is involved.\nS:U - The verifier bypass, the JIT'd signed division, and the resulting fault all occur within the kernel's own security authority. No VM, IOMMU, or hypervisor boundary is crossed.\nC:H - On the s390 JIT the `switch (off)` in the DIV/MOD handlers has no default, so no divide instruction is emitted while the trailing `lgr %dst,%rc` still executes, copying the uninitialized kernel scratch register `%r0`/`%r1` — potentially a kernel pointer — into a BPF register that the program can write to a map and read from userspace, repeatably and at attacker-chosen program points. The x86 divide-error oops additionally dumps full register and stack state, defeating KASLR.\nI:H - The verifier accepts an instruction whose runtime semantics it never models — the JIT executes a signed division while the fixup layer applies only the unsigned guards, and on s390 uncontrolled kernel register contents are injected into verified program state. This is a verifier validation bypass in which JIT-emitted code and the verifier's model of that code diverge, so integrity of the sandbox's guarantees is not preserved.\nA:H - Because `is_sdiv`/`is_smod` in `do_misc_fixups()` test `insn->off == 1`, the `LLONG_MIN sdiv -1` overflow guards are skipped while the x86-64 JIT still emits `cqo; idiv`, producing a #DE with no exception-table entry — `do_trap()` reaches `die(\"divide error\")`, oopsing the kernel. Triggered from a socket-filter/tc/XDP program this fires in softirq context, yielding \"Fatal exception in interrupt\" and a full system panic."}]}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-08-05T12:08:14.652Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.6","versionEndExcluding":"6.6.112"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.6","versionEndExcluding":"6.12.53"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.6","versionEndExcluding":"6.17.3"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.6","versionEndExcluding":"6.18"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}},"adp":[{"title":"CISA ADP Vulnrichment","metrics":[{"other":{"type":"ssvc","content":{"id":"CVE-2025-40169","role":"CISA Coordinator","options":[{"Exploitation":"none"},{"Automatable":"no"},{"Technical Impact":"total"}],"version":"2.0.3","timestamp":"2026-10-15T21:57:30.151635Z"}}}],"providerMetadata":{"shortName":"CISA-ADP","orgId":"134c704f-9b21-4f2e-91b3-4a467353bcc0","dateUpdated":"2026-10-15T22:02:39.320Z"}}]}}}