bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free()
authorHengqi Chen <hengqi.chen@gmail.com>
Tue, 16 Sep 2025 23:26:53 +0000 (23:26 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 17 Sep 2025 18:20:32 +0000 (11:20 -0700)
The current implementation seems incorrect and does NOT match the
comment above, use bpf_jit_binary_pack_finalize() instead.

Fixes: 1dad391daef1 ("bpf, arm64: use bpf_prog_pack for memory management")
Acked-by: Puranjay Mohan <puranjay@kernel.org>
Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
Acked-by: Song Liu <song@kernel.org>
Acked-by: Puranjay Mohan <puranjay@kernel.org>
Link: https://lore.kernel.org/r/20250916232653.101004-1-hengqi.chen@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
arch/arm64/net/bpf_jit_comp.c

index 008273a..e36261c 100644 (file)
@@ -3115,8 +3115,7 @@ void bpf_jit_free(struct bpf_prog *prog)
                 * before freeing it.
                 */
                if (jit_data) {
-                       bpf_arch_text_copy(&jit_data->ro_header->size, &jit_data->header->size,
-                                          sizeof(jit_data->header->size));
+                       bpf_jit_binary_pack_finalize(jit_data->ro_header, jit_data->header);
                        kfree(jit_data);
                }
                prog->bpf_func -= cfi_get_offset();