From: Greg Kroah-Hartman Date: Thu, 15 Jan 2026 15:06:08 +0000 (+0100) Subject: 6.12-stable patches X-Git-Tag: v6.6.121~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebf524f29d5f8cab86d8f754829e996acc334a78;p=thirdparty%2Fkernel%2Fstable-queue.git 6.12-stable patches added patches: bpf-test_run-fix-ctx-leak-in-bpf_prog_test_run_xdp-error-path.patch --- diff --git a/queue-6.12/bpf-test_run-fix-ctx-leak-in-bpf_prog_test_run_xdp-error-path.patch b/queue-6.12/bpf-test_run-fix-ctx-leak-in-bpf_prog_test_run_xdp-error-path.patch new file mode 100644 index 0000000000..61bbd5c5d5 --- /dev/null +++ b/queue-6.12/bpf-test_run-fix-ctx-leak-in-bpf_prog_test_run_xdp-error-path.patch @@ -0,0 +1,45 @@ +From 7f9ee5fc97e14682e36fe22ae2654c07e4998b82 Mon Sep 17 00:00:00 2001 +From: Shardul Bankar +Date: Tue, 14 Oct 2025 17:30:37 +0530 +Subject: bpf: test_run: Fix ctx leak in bpf_prog_test_run_xdp error path + +From: Shardul Bankar + +commit 7f9ee5fc97e14682e36fe22ae2654c07e4998b82 upstream. + +Fix a memory leak in bpf_prog_test_run_xdp() where the context buffer +allocated by bpf_ctx_init() is not freed when the function returns early +due to a data size check. + +On the failing path: + ctx = bpf_ctx_init(...); + if (kattr->test.data_size_in - meta_sz < ETH_HLEN) + return -EINVAL; + +The early return bypasses the cleanup label that kfree()s ctx, leading to a +leak detectable by kmemleak under fuzzing. Change the return to jump to the +existing free_ctx label. + +Fixes: fe9544ed1a2e ("bpf: Support specifying linear xdp packet data size for BPF_PROG_TEST_RUN") +Reported-by: BPF Runtime Fuzzer (BRF) +Signed-off-by: Shardul Bankar +Signed-off-by: Martin KaFai Lau +Acked-by: Jiri Olsa +Acked-by: Daniel Borkmann +Link: https://patch.msgid.link/20251014120037.1981316-1-shardulsb08@gmail.com +Signed-off-by: Greg Kroah-Hartman +--- + net/bpf/test_run.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/net/bpf/test_run.c ++++ b/net/bpf/test_run.c +@@ -1270,7 +1270,7 @@ int bpf_prog_test_run_xdp(struct bpf_pro + goto free_ctx; + + if (kattr->test.data_size_in - meta_sz < ETH_HLEN) +- return -EINVAL; ++ goto free_ctx; + + data = bpf_test_init(kattr, linear_sz, max_linear_sz, headroom, tailroom); + if (IS_ERR(data)) { diff --git a/queue-6.12/series b/queue-6.12/series index 59430ab08a..3c0675c6de 100644 --- a/queue-6.12/series +++ b/queue-6.12/series @@ -116,3 +116,4 @@ scsi-sg-fix-occasional-bogus-elapsed-time-that-excee.patch spi-cadence-quadspi-prevent-lost-complete-call-durin.patch tpm2-sessions-fix-out-of-range-indexing-in-name_size.patch alsa-hda-intel-dsp-config-prefer-legacy-driver-as-fallback.patch +bpf-test_run-fix-ctx-leak-in-bpf_prog_test_run_xdp-error-path.patch