Skip to content

Commit d00c647

Browse files
liu-song-6Alexei Starovoitov
authored andcommitted
bpf: Use prog->jited_len in bpf_prog_ksym_set_addr()
Using prog->jited_len is simpler and more accurate than current estimation (header + header->size). Also, fix missing prog->jited_len with multi function program. This hasn't been a real issue before this. Signed-off-by: Song Liu <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent ed2d9e1 commit d00c647

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

kernel/bpf/core.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -537,13 +537,10 @@ long bpf_jit_limit_max __read_mostly;
537537
static void
538538
bpf_prog_ksym_set_addr(struct bpf_prog *prog)
539539
{
540-
const struct bpf_binary_header *hdr = bpf_jit_binary_hdr(prog);
541-
unsigned long addr = (unsigned long)hdr;
542-
543540
WARN_ON_ONCE(!bpf_prog_ebpf_jited(prog));
544541

545542
prog->aux->ksym.start = (unsigned long) prog->bpf_func;
546-
prog->aux->ksym.end = addr + hdr->size;
543+
prog->aux->ksym.end = prog->aux->ksym.start + prog->jited_len;
547544
}
548545

549546
static void

kernel/bpf/verifier.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13067,6 +13067,7 @@ static int jit_subprogs(struct bpf_verifier_env *env)
1306713067

1306813068
prog->jited = 1;
1306913069
prog->bpf_func = func[0]->bpf_func;
13070+
prog->jited_len = func[0]->jited_len;
1307013071
prog->aux->func = func;
1307113072
prog->aux->func_cnt = env->subprog_cnt;
1307213073
bpf_prog_jit_attempt_done(prog);

0 commit comments

Comments
 (0)