Skip to content

Commit 1f6735a

Browse files
puranjaymohanKernel Patches Daemon
authored andcommitted
bpf: verifier: initialize imm in kfunc_tab in add_kfunc_call()
Metadata about a kfunc call is added to the kfunc_tab in add_kfunc_call() but the call instruction itself could get removed by opt_remove_dead_code() later if it is not reachable. If the call instruction is removed, specialize_kfunc() is never called for it and the desc->imm in the kfunc_tab is never initialized for this kfunc call. In this case, sort_kfunc_descs_by_imm_off(env->prog); in do_misc_fixups() doesn't sort the table correctly. This is a problem from s390 as its JIT uses this table to find the addresses for kfuncs, and if this table is not sorted properly, JIT can fail to find addresses for valid kfunc calls. This was exposed by: commit d869d56 ("bpf: verifier: refactor kfunc specialization") as before this commit, desc->imm was initialised in add_kfunc_call(). Initialize desc->imm to func_id, it will be overwritten in specialize_kfunc() if the instruction is not removed. Fixes: d869d56 ("bpf: verifier: refactor kfunc specialization") Signed-off-by: Puranjay Mohan <[email protected]>
1 parent 4eb9670 commit 1f6735a

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

kernel/bpf/verifier.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3371,6 +3371,7 @@ static int add_kfunc_call(struct bpf_verifier_env *env, u32 func_id, s16 offset)
33713371

33723372
desc = &tab->descs[tab->nr_descs++];
33733373
desc->func_id = func_id;
3374+
desc->imm = func_id;
33743375
desc->offset = offset;
33753376
desc->addr = addr;
33763377
desc->func_model = func_model;

0 commit comments

Comments
 (0)