Skip to contentSkip to conversation

bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free()

PATCH Applied Hengqi Chen 4 participants 4 messages Sep 17, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free()

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")
---
 arch/arm64/net/bpf_jit_comp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/net/bpf_jit_comp.c +1 -2
index 52ffe115a8c4..4ef9b7b8fb40 100644
@@ -3064,8 +3064,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();
Signature · 1 line
2.27.0
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Hengqi Chen
Quoted 26 lines · Hengqi Chen

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")
---
 arch/arm64/net/bpf_jit_comp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/net/bpf_jit_comp.c +1 -2
index 52ffe115a8c4..4ef9b7b8fb40 100644
@@ -3064,8 +3064,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();
Signature · 1 line
2.27.0

Thanks,
Puranjay

#3 lore raw
In reply to Hengqi Chen
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Quoted 8 lines · On Tue, 16 Sep 2025 23:26:53 +0000 you wrote:

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")

[...]

Here is the summary with links:
- [bpf-next] bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free()

    https://git.kernel.org/bpf/bpf-next/c/6ff4a0fa3e1b

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html