{"id":"CVE-2025-38502","state":"PUBLISHED","title":"bpf: Fix oob access in cgroup local storage","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Fix oob access in cgroup local storage\n\nLonial reported that an out-of-bounds access in cgroup local storage\ncan be crafted via tail calls. Given two programs each utilizing a\ncgroup local storage with a different value size, and one program\ndoing a tail call into the other. The verifier will validate each of\nthe indivial programs just fine. However, in the runtime context\nthe bpf_cg_run_ctx holds an bpf_prog_array_item which contains the\nBPF program as well as any cgroup local storage flavor the program\nuses. Helpers such as bpf_get_local_storage() pick this up from the\nruntime context:\n\n  ctx = container_of(current->bpf_ctx, struct bpf_cg_run_ctx, run_ctx);\n  storage = ctx->prog_item->cgroup_storage[stype];\n\n  if (stype == BPF_CGROUP_STORAGE_SHARED)\n    ptr = &READ_ONCE(storage->buf)->data[0];\n  else\n    ptr = this_cpu_ptr(storage->percpu_buf);\n\nFor the second program which was called from the originally attached\none, this means bpf_get_local_storage() will pick up the former\nprogram's map, not its own. With mismatching sizes, this can result\nin an unintended out-of-bounds access.\n\nTo fix this issue, we need to extend bpf_map_owner with an array of\nstorage_cookie[] to match on i) the exact maps from the original\nprogram if the second program was using bpf_get_local_storage(), or\nii) allow the tail call combination if the second program was not\nusing any of the cgroup local storage maps.","publishedAt":"2025-08-16T09:34:25.135Z","updatedAt":"2026-10-15T21:52:17.683Z","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":"7d9c3427894fe70d1347b4820476bf37736d2ff0","status":"affected","lessThan":"c1c74584b9b4043c52e41fec415226e582d266a3","versionType":"git"},{"version":"7d9c3427894fe70d1347b4820476bf37736d2ff0","status":"affected","lessThan":"66da7cee78590259b400e51a70622ccd41da7bb2","versionType":"git"},{"version":"7d9c3427894fe70d1347b4820476bf37736d2ff0","status":"affected","lessThan":"7acfa07c585e3d7a64654d38f0a5c762877d0b9b","versionType":"git"},{"version":"7d9c3427894fe70d1347b4820476bf37736d2ff0","status":"affected","lessThan":"41688d1fc5d163a6c2c0e95c0419e2cb31a44648","versionType":"git"},{"version":"7d9c3427894fe70d1347b4820476bf37736d2ff0","status":"affected","lessThan":"19341d5c59e8c7e8528e40f8663e99d67810473c","versionType":"git"},{"version":"7d9c3427894fe70d1347b4820476bf37736d2ff0","status":"affected","lessThan":"abad3d0bad72a52137e0c350c59542d75ae4f513","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["include/linux/bpf.h","kernel/bpf/core.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"5.9","status":"affected"},{"version":"0","status":"unaffected","lessThan":"5.9","versionType":"semver"},{"version":"5.15.192","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"6.1.151","status":"unaffected","lessThanOrEqual":"6.1.*","versionType":"semver"},{"version":"6.6.105","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.12.46","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.16.1","status":"unaffected","lessThanOrEqual":"6.16.*","versionType":"semver"},{"version":"6.17","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["include/linux/bpf.h","kernel/bpf/core.c"]}],"references":["https://git.kernel.org/stable/c/c1c74584b9b4043c52e41fec415226e582d266a3","https://git.kernel.org/stable/c/66da7cee78590259b400e51a70622ccd41da7bb2","https://git.kernel.org/stable/c/7acfa07c585e3d7a64654d38f0a5c762877d0b9b","https://git.kernel.org/stable/c/41688d1fc5d163a6c2c0e95c0419e2cb31a44648","https://git.kernel.org/stable/c/19341d5c59e8c7e8528e40f8663e99d67810473c","https://git.kernel.org/stable/c/abad3d0bad72a52137e0c350c59542d75ae4f513","https://lists.debian.org/debian-lts-announce/2025/10/msg00008.html","https://cert-portal.siemens.com/productcert/html/ssa-032379.html"],"weaknesses":[],"ingestedAt":"2026-10-29T20:09:09.358Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2025/38xxx/CVE-2025-38502.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2025-38502","state":"PUBLISHED","datePublished":"2025-08-16T09:34:25.135Z","dateUpdated":"2026-10-15T21:52:17.683Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2025-04-16T04:51:24.022Z"},"containers":{"cna":{"title":"bpf: Fix oob access in cgroup local storage","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Fix oob access in cgroup local storage\n\nLonial reported that an out-of-bounds access in cgroup local storage\ncan be crafted via tail calls. Given two programs each utilizing a\ncgroup local storage with a different value size, and one program\ndoing a tail call into the other. The verifier will validate each of\nthe indivial programs just fine. However, in the runtime context\nthe bpf_cg_run_ctx holds an bpf_prog_array_item which contains the\nBPF program as well as any cgroup local storage flavor the program\nuses. Helpers such as bpf_get_local_storage() pick this up from the\nruntime context:\n\n  ctx = container_of(current->bpf_ctx, struct bpf_cg_run_ctx, run_ctx);\n  storage = ctx->prog_item->cgroup_storage[stype];\n\n  if (stype == BPF_CGROUP_STORAGE_SHARED)\n    ptr = &READ_ONCE(storage->buf)->data[0];\n  else\n    ptr = this_cpu_ptr(storage->percpu_buf);\n\nFor the second program which was called from the originally attached\none, this means bpf_get_local_storage() will pick up the former\nprogram's map, not its own. With mismatching sizes, this can result\nin an unintended out-of-bounds access.\n\nTo fix this issue, we need to extend bpf_map_owner with an array of\nstorage_cookie[] to match on i) the exact maps from the original\nprogram if the second program was using bpf_get_local_storage(), or\nii) allow the tail call combination if the second program was not\nusing any of the cgroup local storage maps."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"7d9c3427894fe70d1347b4820476bf37736d2ff0","status":"affected","lessThan":"c1c74584b9b4043c52e41fec415226e582d266a3","versionType":"git"},{"version":"7d9c3427894fe70d1347b4820476bf37736d2ff0","status":"affected","lessThan":"66da7cee78590259b400e51a70622ccd41da7bb2","versionType":"git"},{"version":"7d9c3427894fe70d1347b4820476bf37736d2ff0","status":"affected","lessThan":"7acfa07c585e3d7a64654d38f0a5c762877d0b9b","versionType":"git"},{"version":"7d9c3427894fe70d1347b4820476bf37736d2ff0","status":"affected","lessThan":"41688d1fc5d163a6c2c0e95c0419e2cb31a44648","versionType":"git"},{"version":"7d9c3427894fe70d1347b4820476bf37736d2ff0","status":"affected","lessThan":"19341d5c59e8c7e8528e40f8663e99d67810473c","versionType":"git"},{"version":"7d9c3427894fe70d1347b4820476bf37736d2ff0","status":"affected","lessThan":"abad3d0bad72a52137e0c350c59542d75ae4f513","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["include/linux/bpf.h","kernel/bpf/core.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"5.9","status":"affected"},{"version":"0","status":"unaffected","lessThan":"5.9","versionType":"semver"},{"version":"5.15.192","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"6.1.151","status":"unaffected","lessThanOrEqual":"6.1.*","versionType":"semver"},{"version":"6.6.105","status":"unaffected","lessThanOrEqual":"6.6.*","versionType":"semver"},{"version":"6.12.46","status":"unaffected","lessThanOrEqual":"6.12.*","versionType":"semver"},{"version":"6.16.1","status":"unaffected","lessThanOrEqual":"6.16.*","versionType":"semver"},{"version":"6.17","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["include/linux/bpf.h","kernel/bpf/core.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/c1c74584b9b4043c52e41fec415226e582d266a3"},{"url":"https://git.kernel.org/stable/c/66da7cee78590259b400e51a70622ccd41da7bb2"},{"url":"https://git.kernel.org/stable/c/7acfa07c585e3d7a64654d38f0a5c762877d0b9b"},{"url":"https://git.kernel.org/stable/c/41688d1fc5d163a6c2c0e95c0419e2cb31a44648"},{"url":"https://git.kernel.org/stable/c/19341d5c59e8c7e8528e40f8663e99d67810473c"},{"url":"https://git.kernel.org/stable/c/abad3d0bad72a52137e0c350c59542d75ae4f513"}],"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 vulnerability is reached through the bpf() syscall (loading maps/programs and invoking them via BPF_PROG_TEST_RUN or an attached hook), which requires local access to the system.\nAC:L - Exploitation is fully deterministic — the attacker crafts both programs, chooses the mismatched storage value sizes, and controls the tail-call chain; there is no race or attacker-uncontrolled condition.\nPR:L - The cgroup-storage maps, the prog-array, and the CGROUP_SKB program are all creatable/loadable without CAP_BPF, and BPF_PROG_TEST_RUN executes them with no capability check, so a basic unprivileged local user can trigger it on a kernel with unprivileged BPF enabled.\nUI:N - The attacker loads and runs the BPF programs itself; no action by any other user is required.\nS:U - The out-of-bounds access corrupts kernel heap memory within the same kernel security authority; it does not cross a VM, IOMMU, or sandbox boundary.\nC:H - The mismatched sizes yield a controllable out-of-bounds read of adjacent kernel heap memory (bpf_get_local_storage returns a map-value pointer read by the program), enabling disclosure of sensitive kernel data.\nI:H - The returned pointer is a writable RET_PTR_TO_MAP_VALUE, so program B writes past A's smaller buffer, giving a controllable heap out-of-bounds write suitable for corruption and privilege escalation.\nA:H - The out-of-bounds heap read/write readily corrupts adjacent kernel structures, causing oops/panic and denial of service."}]}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-08-05T12:02:29.487Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.9","versionEndExcluding":"5.15.192"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.9","versionEndExcluding":"6.1.151"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.9","versionEndExcluding":"6.6.105"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.9","versionEndExcluding":"6.12.46"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.9","versionEndExcluding":"6.16.1"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.9","versionEndExcluding":"6.17"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}},"adp":[{"title":"CVE Program Container","references":[{"url":"https://lists.debian.org/debian-lts-announce/2025/10/msg00008.html"}],"providerMetadata":{"shortName":"CVE","orgId":"af854a3a-2127-422b-91ae-364da2661108","dateUpdated":"2025-11-03T17:39:11.518Z"}},{"affected":[{"vendor":"Siemens","product":"SIMATIC CN 4100","defaultStatus":"unknown","versions":[{"version":"0","status":"affected","lessThan":"V5.0","versionType":"custom"}]}],"references":[{"url":"https://cert-portal.siemens.com/productcert/html/ssa-032379.html"}],"providerMetadata":{"shortName":"siemens-SADP","orgId":"0b142b55-0307-4c5a-b3c9-f314f3fb7c5e","dateUpdated":"2026-05-12T12:05:13.025Z"},"x_adpType":"supplier"},{"title":"CISA ADP Vulnrichment","metrics":[{"other":{"type":"ssvc","content":{"id":"CVE-2025-38502","role":"CISA Coordinator","options":[{"Exploitation":"none"},{"Automatable":"no"},{"Technical Impact":"total"}],"version":"2.0.3","timestamp":"2026-10-15T21:51:03.238888Z"}}}],"providerMetadata":{"shortName":"CISA-ADP","orgId":"134c704f-9b21-4f2e-91b3-4a467353bcc0","dateUpdated":"2026-10-15T21:52:17.683Z"}}]}}}