bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free()
@ 2025-08-28  1:34 Hengqi Chen
  2025-08-28 12:10 ` Puranjay Mohan
  0 siblings, 1 reply; 10+ messages in thread
From: Hengqi Chen @ 2025-08-28  1:34 UTC (permalink / raw)
  To: ast, daniel, andrii, martin.lau, puranjay, xukuohai; +Cc: bpf, 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")
Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
---
 arch/arm64/net/bpf_jit_comp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 52ffe115a8c4..4ef9b7b8fb40 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -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();
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf-next] bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free()
  2025-08-28  1:34 Hengqi Chen
@ 2025-08-28 12:10 ` Puranjay Mohan
  2025-09-15 16:43   ` Song Liu
  0 siblings, 1 reply; 10+ messages in thread
From: Puranjay Mohan @ 2025-08-28 12:10 UTC (permalink / raw)
  To: Hengqi Chen, ast, daniel, andrii, martin.lau, xukuohai, Song Liu
  Cc: bpf, Hengqi Chen

Hengqi Chen <hengqi.chen@gmail.com> writes:

> 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")
> Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
> ---
>  arch/arm64/net/bpf_jit_comp.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> index 52ffe115a8c4..4ef9b7b8fb40 100644
> --- a/arch/arm64/net/bpf_jit_comp.c
> +++ b/arch/arm64/net/bpf_jit_comp.c
> @@ -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);

Thanks for this patch!

So, this is fixing a bug because bpf_jit_binary_pack_finalize() will do
kvfree(rw_header); but without it currently, jit_data->header is never
freed.

But I think we shouldn't use bpf_jit_binary_pack_finalize() here as it
copies the whole rw_header to ro_header using  bpf_arch_text_copy()
which is an expensive operation (patch_map/unmap in loop +
flush_icache_range()) and not needed here because we are going
to free ro_header anyway.

We only need to copy jit_data->header->size to jit_data->ro_header->size
because this size is later used by bpf_jit_binary_pack_free(), see
comment above bpf_jit_binary_pack_free().

How I suggest we should fix the code and the comment:

-- >8 --

diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 5083886d6e66b..cb4c50eeada13 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -3093,12 +3093,14 @@ void bpf_jit_free(struct bpf_prog *prog)

                /*
                 * If we fail the final pass of JIT (from jit_subprogs),
-                * the program may not be finalized yet. Call finalize here
-                * before freeing it.
+                * the program may not be finalized yet. Copy the header size
+                * from rw_header to ro_header before freeing the ro_header
+                * with bpf_jit_binary_pack_free().
                 */
                if (jit_data) {
                        bpf_arch_text_copy(&jit_data->ro_header->size, &jit_data->header->size,
                                           sizeof(jit_data->header->size));
+                       kvfree(jit_data->header);
                        kfree(jit_data);
                }
                prog->bpf_func -= cfi_get_offset();

-- 8< --

Song,

Do you think this optimization is worth it or should we just call
bpf_jit_binary_pack_finalize() here like this patch is doing?

Thanks,
Puranjay

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf-next] bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free()
  2025-08-28 12:10 ` Puranjay Mohan
@ 2025-09-15 16:43   ` Song Liu
  2025-09-16 12:51     ` Puranjay Mohan
  0 siblings, 1 reply; 10+ messages in thread
From: Song Liu @ 2025-09-15 16:43 UTC (permalink / raw)
  To: Puranjay Mohan
  Cc: Hengqi Chen, ast, daniel, andrii, martin.lau, xukuohai, bpf

Sorry for the late reply.

On Thu, Aug 28, 2025 at 5:10 AM Puranjay Mohan <puranjay@kernel.org> wrote:
[...]
> Thanks for this patch!
>
> So, this is fixing a bug because bpf_jit_binary_pack_finalize() will do
> kvfree(rw_header); but without it currently, jit_data->header is never
> freed.
>
> But I think we shouldn't use bpf_jit_binary_pack_finalize() here as it
> copies the whole rw_header to ro_header using  bpf_arch_text_copy()
> which is an expensive operation (patch_map/unmap in loop +
> flush_icache_range()) and not needed here because we are going
> to free ro_header anyway.
>
> We only need to copy jit_data->header->size to jit_data->ro_header->size
> because this size is later used by bpf_jit_binary_pack_free(), see
> comment above bpf_jit_binary_pack_free().
>
> How I suggest we should fix the code and the comment:
>
> -- >8 --
>
> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> index 5083886d6e66b..cb4c50eeada13 100644
> --- a/arch/arm64/net/bpf_jit_comp.c
> +++ b/arch/arm64/net/bpf_jit_comp.c
> @@ -3093,12 +3093,14 @@ void bpf_jit_free(struct bpf_prog *prog)
>
>                 /*
>                  * If we fail the final pass of JIT (from jit_subprogs),
> -                * the program may not be finalized yet. Call finalize here
> -                * before freeing it.
> +                * the program may not be finalized yet. Copy the header size
> +                * from rw_header to ro_header before freeing the ro_header
> +                * with bpf_jit_binary_pack_free().
>                  */
>                 if (jit_data) {
>                         bpf_arch_text_copy(&jit_data->ro_header->size, &jit_data->header->size,
>                                            sizeof(jit_data->header->size));
> +                       kvfree(jit_data->header);
>                         kfree(jit_data);
>                 }
>                 prog->bpf_func -= cfi_get_offset();
>
> -- 8< --
>
> Song,
>
> Do you think this optimization is worth it or should we just call
> bpf_jit_binary_pack_finalize() here like this patch is doing?

This is a good optimization. However, given this is not a hot path,
I don't have a strong preference either way. At the moment, most
other architectures use bpf_jit_binary_pack_finalize(), so it is good
to just use bpf_jit_binary_pack_finalize and keep the logic
consistent.

In the longer term, we can consider refactoring bpf_jit_free so that
multiple architectures can share code. After this patch, bpf_jit_free
for x86_64 and arm64 are very similar to each other. There are
likely some opportunities to reduce code duplications.

Thanks,
Song

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf-next] bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free()
  2025-09-15 16:43   ` Song Liu
@ 2025-09-16 12:51     ` Puranjay Mohan
  2025-09-16 14:58       ` Alexei Starovoitov
  0 siblings, 1 reply; 10+ messages in thread
From: Puranjay Mohan @ 2025-09-16 12:51 UTC (permalink / raw)
  To: Song Liu; +Cc: Hengqi Chen, ast, daniel, andrii, martin.lau, xukuohai, bpf

Song Liu <song@kernel.org> writes:

> Sorry for the late reply.
>
> On Thu, Aug 28, 2025 at 5:10 AM Puranjay Mohan <puranjay@kernel.org> wrote:
> [...]
>> Thanks for this patch!
>>
>> So, this is fixing a bug because bpf_jit_binary_pack_finalize() will do
>> kvfree(rw_header); but without it currently, jit_data->header is never
>> freed.
>>
>> But I think we shouldn't use bpf_jit_binary_pack_finalize() here as it
>> copies the whole rw_header to ro_header using  bpf_arch_text_copy()
>> which is an expensive operation (patch_map/unmap in loop +
>> flush_icache_range()) and not needed here because we are going
>> to free ro_header anyway.
>>
>> We only need to copy jit_data->header->size to jit_data->ro_header->size
>> because this size is later used by bpf_jit_binary_pack_free(), see
>> comment above bpf_jit_binary_pack_free().
>>
>> How I suggest we should fix the code and the comment:
>>
>> -- >8 --
>>
>> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
>> index 5083886d6e66b..cb4c50eeada13 100644
>> --- a/arch/arm64/net/bpf_jit_comp.c
>> +++ b/arch/arm64/net/bpf_jit_comp.c
>> @@ -3093,12 +3093,14 @@ void bpf_jit_free(struct bpf_prog *prog)
>>
>>                 /*
>>                  * If we fail the final pass of JIT (from jit_subprogs),
>> -                * the program may not be finalized yet. Call finalize here
>> -                * before freeing it.
>> +                * the program may not be finalized yet. Copy the header size
>> +                * from rw_header to ro_header before freeing the ro_header
>> +                * with bpf_jit_binary_pack_free().
>>                  */
>>                 if (jit_data) {
>>                         bpf_arch_text_copy(&jit_data->ro_header->size, &jit_data->header->size,
>>                                            sizeof(jit_data->header->size));
>> +                       kvfree(jit_data->header);
>>                         kfree(jit_data);
>>                 }
>>                 prog->bpf_func -= cfi_get_offset();
>>
>> -- 8< --
>>
>> Song,
>>
>> Do you think this optimization is worth it or should we just call
>> bpf_jit_binary_pack_finalize() here like this patch is doing?
>
> This is a good optimization. However, given this is not a hot path,
> I don't have a strong preference either way. At the moment, most
> other architectures use bpf_jit_binary_pack_finalize(), so it is good
> to just use bpf_jit_binary_pack_finalize and keep the logic
> consistent.

So, in that case we can merge this patch.

Acked-by: Puranjay Mohan <puranjay@kernel.org>

Thanks,
Puranjay

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf-next] bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free()
  2025-09-16 12:51     ` Puranjay Mohan
@ 2025-09-16 14:58       ` Alexei Starovoitov
  2025-09-17  1:26         ` Hengqi Chen
  0 siblings, 1 reply; 10+ messages in thread
From: Alexei Starovoitov @ 2025-09-16 14:58 UTC (permalink / raw)
  To: Puranjay Mohan
  Cc: Song Liu, Hengqi Chen, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Xu Kuohai, bpf

On Tue, Sep 16, 2025 at 5:51 AM Puranjay Mohan <puranjay@kernel.org> wrote:
>
> Song Liu <song@kernel.org> writes:
>
> > Sorry for the late reply.
> >
> > On Thu, Aug 28, 2025 at 5:10 AM Puranjay Mohan <puranjay@kernel.org> wrote:
> > [...]
> >> Thanks for this patch!
> >>
> >> So, this is fixing a bug because bpf_jit_binary_pack_finalize() will do
> >> kvfree(rw_header); but without it currently, jit_data->header is never
> >> freed.
> >>
> >> But I think we shouldn't use bpf_jit_binary_pack_finalize() here as it
> >> copies the whole rw_header to ro_header using  bpf_arch_text_copy()
> >> which is an expensive operation (patch_map/unmap in loop +
> >> flush_icache_range()) and not needed here because we are going
> >> to free ro_header anyway.
> >>
> >> We only need to copy jit_data->header->size to jit_data->ro_header->size
> >> because this size is later used by bpf_jit_binary_pack_free(), see
> >> comment above bpf_jit_binary_pack_free().
> >>
> >> How I suggest we should fix the code and the comment:
> >>
> >> -- >8 --
> >>
> >> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> >> index 5083886d6e66b..cb4c50eeada13 100644
> >> --- a/arch/arm64/net/bpf_jit_comp.c
> >> +++ b/arch/arm64/net/bpf_jit_comp.c
> >> @@ -3093,12 +3093,14 @@ void bpf_jit_free(struct bpf_prog *prog)
> >>
> >>                 /*
> >>                  * If we fail the final pass of JIT (from jit_subprogs),
> >> -                * the program may not be finalized yet. Call finalize here
> >> -                * before freeing it.
> >> +                * the program may not be finalized yet. Copy the header size
> >> +                * from rw_header to ro_header before freeing the ro_header
> >> +                * with bpf_jit_binary_pack_free().
> >>                  */
> >>                 if (jit_data) {
> >>                         bpf_arch_text_copy(&jit_data->ro_header->size, &jit_data->header->size,
> >>                                            sizeof(jit_data->header->size));
> >> +                       kvfree(jit_data->header);
> >>                         kfree(jit_data);
> >>                 }
> >>                 prog->bpf_func -= cfi_get_offset();
> >>
> >> -- 8< --
> >>
> >> Song,
> >>
> >> Do you think this optimization is worth it or should we just call
> >> bpf_jit_binary_pack_finalize() here like this patch is doing?
> >
> > This is a good optimization. However, given this is not a hot path,
> > I don't have a strong preference either way. At the moment, most
> > other architectures use bpf_jit_binary_pack_finalize(), so it is good
> > to just use bpf_jit_binary_pack_finalize and keep the logic
> > consistent.
>
> So, in that case we can merge this patch.
>
> Acked-by: Puranjay Mohan <puranjay@kernel.org>

It's out of patchwork.
Hengqi,
pls repost.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH bpf-next] bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free()
@ 2025-09-16 23:26 Hengqi Chen
  2025-09-17  5:34 ` Song Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Hengqi Chen @ 2025-09-16 23:26 UTC (permalink / raw)
  To: ast, daniel, andrii, martin.lau, puranjay, xukuohai; +Cc: bpf, 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")
Acked-by: Puranjay Mohan <puranjay@kernel.org>
Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
---
 arch/arm64/net/bpf_jit_comp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 52ffe115a8c4..4ef9b7b8fb40 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -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();
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf-next] bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free()
  2025-09-16 14:58       ` Alexei Starovoitov
@ 2025-09-17  1:26         ` Hengqi Chen
  0 siblings, 0 replies; 10+ messages in thread
From: Hengqi Chen @ 2025-09-17  1:26 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Puranjay Mohan, Song Liu, Alexei Starovoitov, Daniel Borkmann,
	Andrii Nakryiko, Martin KaFai Lau, Xu Kuohai, bpf

On Tue, Sep 16, 2025 at 10:59 PM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Tue, Sep 16, 2025 at 5:51 AM Puranjay Mohan <puranjay@kernel.org> wrote:
> >
> > Song Liu <song@kernel.org> writes:
> >
> > > Sorry for the late reply.
> > >
> > > On Thu, Aug 28, 2025 at 5:10 AM Puranjay Mohan <puranjay@kernel.org> wrote:
> > > [...]
> > >> Thanks for this patch!
> > >>
> > >> So, this is fixing a bug because bpf_jit_binary_pack_finalize() will do
> > >> kvfree(rw_header); but without it currently, jit_data->header is never
> > >> freed.
> > >>
> > >> But I think we shouldn't use bpf_jit_binary_pack_finalize() here as it
> > >> copies the whole rw_header to ro_header using  bpf_arch_text_copy()
> > >> which is an expensive operation (patch_map/unmap in loop +
> > >> flush_icache_range()) and not needed here because we are going
> > >> to free ro_header anyway.
> > >>
> > >> We only need to copy jit_data->header->size to jit_data->ro_header->size
> > >> because this size is later used by bpf_jit_binary_pack_free(), see
> > >> comment above bpf_jit_binary_pack_free().
> > >>
> > >> How I suggest we should fix the code and the comment:
> > >>
> > >> -- >8 --
> > >>
> > >> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> > >> index 5083886d6e66b..cb4c50eeada13 100644
> > >> --- a/arch/arm64/net/bpf_jit_comp.c
> > >> +++ b/arch/arm64/net/bpf_jit_comp.c
> > >> @@ -3093,12 +3093,14 @@ void bpf_jit_free(struct bpf_prog *prog)
> > >>
> > >>                 /*
> > >>                  * If we fail the final pass of JIT (from jit_subprogs),
> > >> -                * the program may not be finalized yet. Call finalize here
> > >> -                * before freeing it.
> > >> +                * the program may not be finalized yet. Copy the header size
> > >> +                * from rw_header to ro_header before freeing the ro_header
> > >> +                * with bpf_jit_binary_pack_free().
> > >>                  */
> > >>                 if (jit_data) {
> > >>                         bpf_arch_text_copy(&jit_data->ro_header->size, &jit_data->header->size,
> > >>                                            sizeof(jit_data->header->size));
> > >> +                       kvfree(jit_data->header);
> > >>                         kfree(jit_data);
> > >>                 }
> > >>                 prog->bpf_func -= cfi_get_offset();
> > >>
> > >> -- 8< --
> > >>
> > >> Song,
> > >>
> > >> Do you think this optimization is worth it or should we just call
> > >> bpf_jit_binary_pack_finalize() here like this patch is doing?
> > >
> > > This is a good optimization. However, given this is not a hot path,
> > > I don't have a strong preference either way. At the moment, most
> > > other architectures use bpf_jit_binary_pack_finalize(), so it is good
> > > to just use bpf_jit_binary_pack_finalize and keep the logic
> > > consistent.
> >
> > So, in that case we can merge this patch.
> >
> > Acked-by: Puranjay Mohan <puranjay@kernel.org>
>
> It's out of patchwork.
> Hengqi,
> pls repost.

OK, just resend.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf-next] bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free()
  2025-09-16 23:26 [PATCH bpf-next] bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free() Hengqi Chen
@ 2025-09-17  5:34 ` Song Liu
  2025-09-17 14:05 ` Puranjay Mohan
  2025-09-17 18:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 10+ messages in thread
From: Song Liu @ 2025-09-17  5:34 UTC (permalink / raw)
  To: Hengqi Chen; +Cc: ast, daniel, andrii, martin.lau, puranjay, xukuohai, bpf

On Tue, Sep 16, 2025 at 6:26 PM Hengqi Chen <hengqi.chen@gmail.com> 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")
> Acked-by: Puranjay Mohan <puranjay@kernel.org>
> Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>

Acked-by: Song Liu <song@kernel.org>

Thanks for the fix!

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf-next] bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free()
  2025-09-16 23:26 [PATCH bpf-next] bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free() Hengqi Chen
  2025-09-17  5:34 ` Song Liu
@ 2025-09-17 14:05 ` Puranjay Mohan
  2025-09-17 18:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 10+ messages in thread
From: Puranjay Mohan @ 2025-09-17 14:05 UTC (permalink / raw)
  To: Hengqi Chen, ast, daniel, andrii, martin.lau, xukuohai; +Cc: bpf, Hengqi Chen

Hengqi Chen <hengqi.chen@gmail.com> writes:

> 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>
> ---
>  arch/arm64/net/bpf_jit_comp.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> index 52ffe115a8c4..4ef9b7b8fb40 100644
> --- a/arch/arm64/net/bpf_jit_comp.c
> +++ b/arch/arm64/net/bpf_jit_comp.c
> @@ -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();
> -- 
> 2.27.0

Acked-by: Puranjay Mohan <puranjay@kernel.org>

Thanks,
Puranjay

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH bpf-next] bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free()
  2025-09-16 23:26 [PATCH bpf-next] bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free() Hengqi Chen
  2025-09-17  5:34 ` Song Liu
  2025-09-17 14:05 ` Puranjay Mohan
@ 2025-09-17 18:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 10+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-17 18:30 UTC (permalink / raw)
  To: Hengqi Chen; +Cc: ast, daniel, andrii, martin.lau, puranjay, xukuohai, bpf

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:

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")
> Acked-by: Puranjay Mohan <puranjay@kernel.org>
> Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-09-17 18:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-16 23:26 [PATCH bpf-next] bpf, arm64: Call bpf_jit_binary_pack_finalize() in bpf_jit_free() Hengqi Chen
2025-09-17  5:34 ` Song Liu
2025-09-17 14:05 ` Puranjay Mohan
2025-09-17 18:30 ` patchwork-bot+netdevbpf
  -- strict thread matches above, loose matches on Subject: below --
2025-08-28  1:34 Hengqi Chen
2025-08-28 12:10 ` Puranjay Mohan
2025-09-15 16:43   ` Song Liu
2025-09-16 12:51     ` Puranjay Mohan
2025-09-16 14:58       ` Alexei Starovoitov
2025-09-17  1:26         ` Hengqi Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).