[PATCH bpf-next v3 1/9] bpf: Extract the bpf_jit_binary_hdr helper

From: Pu Lehui

Date: Sat Jul 25 2026 - 11:45:43 EST


From: Pu Lehui <pulehui@xxxxxxxxxx>

Extract the bpf_jit_binary_hdr helper, and wire it up to
bpf_jit_free function in JITs.

Signed-off-by: Pu Lehui <pulehui@xxxxxxxxxx>
---
include/linux/filter.h | 2 ++
kernel/bpf/core.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/filter.h b/include/linux/filter.h
index 32d5297c557e..5d7fc70bd332 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -1338,6 +1338,8 @@ void bpf_jit_free_exec(void *addr);
void bpf_jit_free(struct bpf_prog *fp);
struct bpf_binary_header *
bpf_jit_binary_pack_hdr(const struct bpf_prog *fp);
+struct bpf_binary_header *
+bpf_jit_binary_hdr(const struct bpf_prog *fp);

void *bpf_prog_pack_alloc(u32 size, bpf_jit_fill_hole_t bpf_fill_ill_insns, bool was_classic);
void bpf_prog_pack_free(void *ptr, u32 size);
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index e2076667b245..27993ae1ac54 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -1286,7 +1286,7 @@ bpf_jit_binary_pack_hdr(const struct bpf_prog *fp)
return (void *)addr;
}

-static inline struct bpf_binary_header *
+struct bpf_binary_header *
bpf_jit_binary_hdr(const struct bpf_prog *fp)
{
unsigned long real_start = (unsigned long)fp->bpf_func;
--
2.34.1