Skip to content

Conversation

kernel-patches-daemon-bpf[bot]
Copy link

Pull request for series with
subject: bpf: test_run: fix ctx leak in bpf_prog_test_run_xdp error path
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1011265

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 3a86608
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1011265
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 3a86608
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1011265
version: 1

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: fe9544e ("bpf: Support specifying linear xdp packet data size for BPF_PROG_TEST_RUN")
Reported-by: BPF Runtime Fuzzer (BRF)
Signed-off-by: Shardul Bankar <shardulsb08@gmail.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 3a86608
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1011265
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1011265 irrelevant now. Closing PR.

@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot deleted the series/1011265=>bpf branch October 14, 2025 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant