Commit 5ddb2a1
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 in add_kfunc_call(), it will be overwritten with new
imm in specialize_kfunc() if the instruction is not removed.
Signed-off-by: Puranjay Mohan <[email protected]>
Acked-by: Kumar Kartikeya Dwivedi <[email protected]>1 parent 728ac5f commit 5ddb2a1
1 file changed
+15
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3273 | 3273 | | |
3274 | 3274 | | |
3275 | 3275 | | |
3276 | | - | |
| 3276 | + | |
3277 | 3277 | | |
3278 | 3278 | | |
3279 | 3279 | | |
| |||
3369 | 3369 | | |
3370 | 3370 | | |
3371 | 3371 | | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
| 3381 | + | |
| 3382 | + | |
3372 | 3383 | | |
3373 | 3384 | | |
| 3385 | + | |
3374 | 3386 | | |
3375 | 3387 | | |
3376 | 3388 | | |
| |||
22354 | 22366 | | |
22355 | 22367 | | |
22356 | 22368 | | |
22357 | | - | |
22358 | | - | |
22359 | | - | |
| 22369 | + | |
22360 | 22370 | | |
22361 | 22371 | | |
22362 | 22372 | | |
22363 | 22373 | | |
22364 | 22374 | | |
22365 | 22375 | | |
| 22376 | + | |
22366 | 22377 | | |
22367 | | - | |
22368 | 22378 | | |
22369 | 22379 | | |
22370 | 22380 | | |
| |||
0 commit comments