Re: [PATCH bpf-next v3 0/9] Fixes for bpf_jit_free

Daniel Borkmann <[email protected]> Mon, 3 Aug 2026 15:05:40 +0200
Newsgroups org.kernel.vger.bpf,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Hi Pu,

On 7/25/26 5:49 PM, Pu Lehui wrote:
> From: Pu Lehui <[email protected]>
> 
> Fixes for bpf_jit_free identified by Sashiko, as previously noted in [0].
> 
> Link: https://lore.kernel.org/bpf/[email protected]/ [0]

Given you need to introduce a bpf_jit_free multiple times in the various
JITs, could you rather look into moving this code into the core so core BPF
code can handle this? Then it would also be easier to test in CI if we can
consolidate the subprogram failure handling.

Thanks,
Daniel

> v3:
> - Add fix for private stack leak on arm64. (Sashiko)
> - Some minor fixes.
> 
> v2: https://lore.kernel.org/bpf/[email protected]
> - Fix JITs not freeing leftover jit_data when jit_subprogs() aborts. (Sashiko)
> - Drop fix for loongarch as it's applied.
> 
> v1: https://lore.kernel.org/bpf/[email protected]
> 
> 
> Pu Lehui (9):
>    bpf: Extract the bpf_jit_binary_hdr helper
>    s390/bpf: Fix memory leak in bpf_jit_free
>    parisc: Fix memory leak in bpf_jit_free
>    bpf, sparc64: Fix memory leak in bpf_jit_free
>    ARC, bpf: Fix memory leak in bpf_jit_free
>    bpf, arm64: Fix memory leak in bpf_jit_free
>    bpf, arm64: Fix private stack leak when JIT failed
>    riscv, bpf: Adjust bpf_func to account for CFI offset in bpf_jit_free
>    bpf: Fix double-free RO header in bpf_jit_free
> 
>   arch/arc/net/bpf_jit_core.c      | 19 +++++++++++++++++++
>   arch/arm64/net/bpf_jit_comp.c    |  6 +++---
>   arch/loongarch/net/bpf_jit.c     |  6 ++----
>   arch/parisc/net/bpf_jit_core.c   | 19 +++++++++++++++++++
>   arch/powerpc/net/bpf_jit_comp.c  |  5 +++--
>   arch/riscv/net/bpf_jit_core.c    |  8 +++-----
>   arch/s390/net/bpf_jit_comp.c     | 19 +++++++++++++++++++
>   arch/sparc/net/bpf_jit_comp_64.c | 19 +++++++++++++++++++
>   arch/x86/net/bpf_jit_comp.c      |  7 ++-----
>   include/linux/filter.h           |  2 ++
>   kernel/bpf/core.c                | 19 ++++++++++---------
>   11 files changed, 101 insertions(+), 28 deletions(-)
>