{"id":"CVE-2026-138941","aliases":["CVE-2026-138941"],"related":[],"kind":"vulnerability","state":"published","title":"powerpc/bpf: fix buffer overflow in JIT for large BPF programs","summary":"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->len]\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->len] 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->len] 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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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->len]\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->len] 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->len] 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.","source":"cvelist"}],"published":"2026-11-30T13:26:24.359Z","modified":"2026-11-30T14:17:55.003Z","severities":[],"cwes":[],"affected":[{"ranges":[{"type":"git","introduced":"0ffdbce6f4a89bb7c0002904d6438ec83cf05ce7","fixed":"b17348a6187b348bc30b74dbc207b98c72dd7b26","status":"affected"},{"type":"git","introduced":"0ffdbce6f4a89bb7c0002904d6438ec83cf05ce7","fixed":"033a1e4f56c29b4244d4f504f4b7704dfefa7afd","status":"affected"},{"type":"git","introduced":"0ffdbce6f4a89bb7c0002904d6438ec83cf05ce7","fixed":"5d79818c18172beedb9e1121496ee15bd195ff93","status":"affected"},{"type":"git","introduced":"0ffdbce6f4a89bb7c0002904d6438ec83cf05ce7","fixed":"3b9710e1d312bf0c3b48e1e1f121255ff3346e25","status":"affected"},{"type":"git","introduced":"0ffdbce6f4a89bb7c0002904d6438ec83cf05ce7","fixed":"0e7ec5fe2fc914e611cd0f9cfeb76a17ffbf5d6f","status":"affected"},{"type":"git","introduced":"0ffdbce6f4a89bb7c0002904d6438ec83cf05ce7","fixed":"78ce55b7913a78e1687306668e078b86bc6508ee","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"5.18","status":"affected"},{"type":"semver","introduced":"0","fixed":"5.18","status":"unaffected"},{"type":"semver","introduced":"6.1.193","lastAffected":"6.1.*","status":"unaffected"},{"type":"semver","introduced":"6.6.163","lastAffected":"6.6.*","status":"unaffected"},{"type":"semver","introduced":"6.12.118","lastAffected":"6.12.*","status":"unaffected"},{"type":"semver","introduced":"6.18.64","lastAffected":"6.18.*","status":"unaffected"},{"type":"semver","introduced":"7.3.4","lastAffected":"7.3.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"7.4-rc1","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"}],"references":[{"url":"https://git.kernel.org/stable/c/b17348a6187b348bc30b74dbc207b98c72dd7b26","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/033a1e4f56c29b4244d4f504f4b7704dfefa7afd","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/5d79818c18172beedb9e1121496ee15bd195ff93","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/3b9710e1d312bf0c3b48e1e1f121255ff3346e25","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/0e7ec5fe2fc914e611cd0f9cfeb76a17ffbf5d6f","tags":[],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/78ce55b7913a78e1687306668e078b86bc6508ee","tags":[],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-138941","url":"https://www.cve.org/CVERecord?id=CVE-2026-138941","licence":"CVE Terms of Use","modified":"2026-11-30T13:26:24.359Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-138941","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-138941","licence":"Public domain","modified":"2026-11-30T14:17:55.003Z"}],"updatedAt":"2026-11-30T14:32:24.069Z","epss":{"score":0.00223,"percentile":0.13799,"date":"2026-12-01T12:00:22.000Z"}}