{"id":"CVE-2022-50168","state":"PUBLISHED","title":"bpf, x86: fix freeing of not-finalized bpf_prog_pack","description":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf, x86: fix freeing of not-finalized bpf_prog_pack\n\nsyzbot reported a few issues with bpf_prog_pack [1], [2]. This only happens\nwith multiple subprogs. In jit_subprogs(), we first call bpf_int_jit_compile()\non each sub program. And then, we call it on each sub program again. jit_data\nis not freed in the first call of bpf_int_jit_compile(). Similarly we don't\ncall bpf_jit_binary_pack_finalize() in the first call of bpf_int_jit_compile().\n\nIf bpf_int_jit_compile() failed for one sub program, we will call\nbpf_jit_binary_pack_finalize() for this sub program. However, we don't have a\nchance to call it for other sub programs. Then we will hit \"goto out_free\" in\njit_subprogs(), and call bpf_jit_free on some subprograms that haven't got\nbpf_jit_binary_pack_finalize() yet.\n\nAt this point, bpf_jit_binary_pack_free() is called and the whole 2MB page is\nfreed erroneously.\n\nFix this with a custom bpf_jit_free() for x86_64, which calls\nbpf_jit_binary_pack_finalize() if necessary. Also, with custom\nbpf_jit_free(), bpf_prog_aux->use_bpf_prog_pack is not needed any more,\nremove it.\n\n[1] https://syzkaller.appspot.com/bug?extid=2f649ec6d2eea1495a8f\n[2] https://syzkaller.appspot.com/bug?extid=87f65c75f4a72db05445","publishedAt":"2025-06-18T11:03:21.593Z","updatedAt":"2026-10-15T21:31:18.723Z","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":"1022a5498f6f745c3b5fd3f050a5e11e7ca354f0","status":"affected","lessThan":"f91ce608a79c0db3e72bd63c23e011a9ebc31505","versionType":"git"},{"version":"1022a5498f6f745c3b5fd3f050a5e11e7ca354f0","status":"affected","lessThan":"60e66074812dde9cde3d99cdd3caa9e40f1a4516","versionType":"git"},{"version":"1022a5498f6f745c3b5fd3f050a5e11e7ca354f0","status":"affected","lessThan":"1d5f82d9dd477d5c66e0214a68c3e4f308eadd6d","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["arch/x86/net/bpf_jit_comp.c","include/linux/bpf.h","include/linux/filter.h","kernel/bpf/core.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"5.18","status":"affected"},{"version":"0","status":"unaffected","lessThan":"5.18","versionType":"semver"},{"version":"5.18.18","status":"unaffected","lessThanOrEqual":"5.18.*","versionType":"semver"},{"version":"5.19.2","status":"unaffected","lessThanOrEqual":"5.19.*","versionType":"semver"},{"version":"6.0","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["arch/x86/net/bpf_jit_comp.c","include/linux/bpf.h","include/linux/filter.h","kernel/bpf/core.c"]}],"references":["https://git.kernel.org/stable/c/f91ce608a79c0db3e72bd63c23e011a9ebc31505","https://git.kernel.org/stable/c/60e66074812dde9cde3d99cdd3caa9e40f1a4516","https://git.kernel.org/stable/c/1d5f82d9dd477d5c66e0214a68c3e4f308eadd6d"],"weaknesses":[],"ingestedAt":"2026-10-29T20:05:26.763Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2022/50xxx/CVE-2022-50168.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2022-50168","state":"PUBLISHED","datePublished":"2025-06-18T11:03:21.593Z","dateUpdated":"2026-10-15T21:31:18.723Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2025-06-18T10:57:27.426Z"},"containers":{"cna":{"title":"bpf, x86: fix freeing of not-finalized bpf_prog_pack","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf, x86: fix freeing of not-finalized bpf_prog_pack\n\nsyzbot reported a few issues with bpf_prog_pack [1], [2]. This only happens\nwith multiple subprogs. In jit_subprogs(), we first call bpf_int_jit_compile()\non each sub program. And then, we call it on each sub program again. jit_data\nis not freed in the first call of bpf_int_jit_compile(). Similarly we don't\ncall bpf_jit_binary_pack_finalize() in the first call of bpf_int_jit_compile().\n\nIf bpf_int_jit_compile() failed for one sub program, we will call\nbpf_jit_binary_pack_finalize() for this sub program. However, we don't have a\nchance to call it for other sub programs. Then we will hit \"goto out_free\" in\njit_subprogs(), and call bpf_jit_free on some subprograms that haven't got\nbpf_jit_binary_pack_finalize() yet.\n\nAt this point, bpf_jit_binary_pack_free() is called and the whole 2MB page is\nfreed erroneously.\n\nFix this with a custom bpf_jit_free() for x86_64, which calls\nbpf_jit_binary_pack_finalize() if necessary. Also, with custom\nbpf_jit_free(), bpf_prog_aux->use_bpf_prog_pack is not needed any more,\nremove it.\n\n[1] https://syzkaller.appspot.com/bug?extid=2f649ec6d2eea1495a8f\n[2] https://syzkaller.appspot.com/bug?extid=87f65c75f4a72db05445"}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"1022a5498f6f745c3b5fd3f050a5e11e7ca354f0","status":"affected","lessThan":"f91ce608a79c0db3e72bd63c23e011a9ebc31505","versionType":"git"},{"version":"1022a5498f6f745c3b5fd3f050a5e11e7ca354f0","status":"affected","lessThan":"60e66074812dde9cde3d99cdd3caa9e40f1a4516","versionType":"git"},{"version":"1022a5498f6f745c3b5fd3f050a5e11e7ca354f0","status":"affected","lessThan":"1d5f82d9dd477d5c66e0214a68c3e4f308eadd6d","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["arch/x86/net/bpf_jit_comp.c","include/linux/bpf.h","include/linux/filter.h","kernel/bpf/core.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"5.18","status":"affected"},{"version":"0","status":"unaffected","lessThan":"5.18","versionType":"semver"},{"version":"5.18.18","status":"unaffected","lessThanOrEqual":"5.18.*","versionType":"semver"},{"version":"5.19.2","status":"unaffected","lessThanOrEqual":"5.19.*","versionType":"semver"},{"version":"6.0","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["arch/x86/net/bpf_jit_comp.c","include/linux/bpf.h","include/linux/filter.h","kernel/bpf/core.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/f91ce608a79c0db3e72bd63c23e011a9ebc31505"},{"url":"https://git.kernel.org/stable/c/60e66074812dde9cde3d99cdd3caa9e40f1a4516"},{"url":"https://git.kernel.org/stable/c/1d5f82d9dd477d5c66e0214a68c3e4f308eadd6d"}],"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 bug is reached only through the local bpf() syscall (BPF_PROG_LOAD → bpf_check → jit_subprogs → bpf_jit_free) while JIT-compiling a multi-subprog eBPF program on x86_64; BPF is a local syscall path, not a network or adjacent-protocol entry.\nAC:L - The attacker fully controls program shape and can force the multi-subprog JIT failure path (failed second pass / alloc failure after earlier subprogs succeeded), as syzbot did repeatedly; no race or attacker-uncontrollable layout is required.\nPR:L - Multi-subprog programs require bpf_capable() (CAP_BPF or CAP_SYS_ADMIN), but CAP_BPF is a delegatable non-root capability routinely granted to containers, agents, and Android services, so only low privileges are needed in the worst reasonable deployment.\nUI:N - The attacker loads the crafted multi-subprog BPF program themselves via bpf(); no separate victim action is required.\nS:U - Impact is host-kernel memory corruption / privilege escalation within the same OS security authority; this is not a VM escape, IOMMU bypass, or other cross-boundary compromise.\nC:H - Freeing a not-finalized bpf_prog_pack slice via the wrong path can release the shared 2MB JIT pack while other programs still use it (explicit UAF of pack contents), enabling reclaim and arbitrary kernel/JIT memory disclosure.\nI:H - The same erroneous pack free / module_memfree of shared RX JIT memory is a use-after-free of executable BPF images and allocator state, sprayable into arbitrary write and control-flow hijack primitives.\nA:H - syzbot observed KASAN vmalloc-OOB in bpf_jit_free escalating to a page-fault oops, and a kernel BUG in __text_poke when later JIT touches corrupted pack memory, so availability impact is High."}]}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-08-05T08:57:37.473Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.18","versionEndExcluding":"5.18.18"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.18","versionEndExcluding":"5.19.2"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"5.18","versionEndExcluding":"6.0"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}},"adp":[{"title":"CISA ADP Vulnrichment","metrics":[{"other":{"type":"ssvc","content":{"id":"CVE-2022-50168","role":"CISA Coordinator","options":[{"Exploitation":"none"},{"Automatable":"no"},{"Technical Impact":"total"}],"version":"2.0.3","timestamp":"2026-10-15T21:30:21.051809Z"}}}],"providerMetadata":{"shortName":"CISA-ADP","orgId":"134c704f-9b21-4f2e-91b3-4a467353bcc0","dateUpdated":"2026-10-15T21:31:18.723Z"}}]}}}