{"id":"CVE-2026-138941","summary":"powerpc/bpf: fix buffer overflow in JIT for large BPF programs","details":"In the Linux kernel, the following vulnerability has been resolved:\n\npowerpc/bpf: fix buffer overflow in JIT for large BPF programs\n\nDuring size calculation in pass-0, exit_addr is 0 since addrs[fp-\u003elen]\nis not yet populated. bpf_jit_emit_exit_insn() treats a zero exit_addr\nas in-range and skips bpf_jit_build_epilogue(), so the alternate inline\nepilogue instructions are not counted in alloclen.\n\nIn later passes, if the real exit_addr falls outside the 32MB branch\nrange, the full inline epilogue is emitted into the already-allocated\nbuffer, writing past its end and corrupting adjacent memory.\n\nFix by ensuring exit_addr is non-zero before treating it as in-range,\nso pass-0 always falls through to bpf_jit_build_epilogue() and\nconservatively accounts for all epilogue instructions in alloclen.\nAlso range check alt_exit_addr directly in the else-if condition.\n\nSince exit_addr handling now falls through to the epilogue, two\nrelated issues in bpf_int_jit_compile() must also be addressed:\n\n1. Reset cgctx.alt_exit_addr before the second size-calculation pass.\n   Without this, a stale alt_exit_addr from the first pass causes the\n   second pass to emit a single jump instead of the full epilogue,\n   undercounting alloclen and reintroducing the overflow.\n\n2. Recompute addrs[fp-\u003elen] at the end of each code-generation pass.\n   The larger pass-0 body can shrink in later passes as out-of-range\n   exits settle into in-range jumps; a stale addrs[fp-\u003elen] would\n   leave exit branches targeting past the real (shrunken) epilogue.\n\nBecause shrinkage in a later pass can move the epilogue offset, the\nfixed two-pass loop is no longer sufficient: an exit that was out of\nrange in an earlier pass may fall in range once the epilogue offset\nshrinks, shrinking the body further and overwriting the start of the\nepilogue. Convert the code-generation loop to iterate until the\nprogram size converges, bounded by CODEGEN_MAX_PASSES, and fail the\nJIT if it does not converge.","modified":"2026-11-30T15:01:35.320462865Z","published":"2026-11-30T13:26:24.359Z","database_specific":{"osv_generated_from":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/138xxx/CVE-2026-138941.json","cna_assigner":"Linux"},"references":[{"type":"PACKAGE","url":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"},{"type":"WEB","url":"https://git.kernel.org/stable/c/033a1e4f56c29b4244d4f504f4b7704dfefa7afd"},{"type":"WEB","url":"https://git.kernel.org/stable/c/0e7ec5fe2fc914e611cd0f9cfeb76a17ffbf5d6f"},{"type":"WEB","url":"https://git.kernel.org/stable/c/3b9710e1d312bf0c3b48e1e1f121255ff3346e25"},{"type":"WEB","url":"https://git.kernel.org/stable/c/5d79818c18172beedb9e1121496ee15bd195ff93"},{"type":"WEB","url":"https://git.kernel.org/stable/c/78ce55b7913a78e1687306668e078b86bc6508ee"},{"type":"WEB","url":"https://git.kernel.org/stable/c/b17348a6187b348bc30b74dbc207b98c72dd7b26"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/138xxx/CVE-2026-138941.json"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-138941"}],"affected":[{"ranges":[{"type":"GIT","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","events":[{"introduced":"0ffdbce6f4a89bb7c0002904d6438ec83cf05ce7"},{"fixed":"b17348a6187b348bc30b74dbc207b98c72dd7b26"},{"fixed":"033a1e4f56c29b4244d4f504f4b7704dfefa7afd"},{"fixed":"5d79818c18172beedb9e1121496ee15bd195ff93"},{"fixed":"3b9710e1d312bf0c3b48e1e1f121255ff3346e25"},{"fixed":"0e7ec5fe2fc914e611cd0f9cfeb76a17ffbf5d6f"},{"fixed":"78ce55b7913a78e1687306668e078b86bc6508ee"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-138941.json"}},{"package":{"name":"Kernel","ecosystem":"Linux"},"ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"5.18.0"},{"fixed":"6.1.193"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.2.0"},{"fixed":"6.6.163"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.7.0"},{"fixed":"6.12.118"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.13.0"},{"fixed":"6.18.64"}]},{"type":"ECOSYSTEM","events":[{"introduced":"6.19.0"},{"fixed":"7.3.4"}]}],"database_specific":{"source":"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-138941.json"}}],"schema_version":"1.9.2"}