check_func_callx() requires a JIT with callx support before it looks at the register operand. On an architecture whose JIT doesn't support callx, or when the JIT is disabled, every callx is thus rejected with "JIT doesn't support callx" or "JIT is required to use callx", including one whose operand is invalid. The "invalid call insn1" test_verifier test expects "R0 !read_ok" for callx of an uninitialized register and fails on s390x: #79/u invalid call insn1 FAIL Unexpected error message! EXP: R0 !read_ok RES: JIT doesn't support callx Validate the operand first and require the JIT only for a callx that is otherwise valid. An invalid callx is then rejected with the same message on every architecture. This fixes various errors when running selftests on JITs where callx is unsupported for now. Signed-off-by: Kumar Kartikeya Dwivedi --- kernel/bpf/verifier.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index c495dc9070de..76172c1e55d5 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -11211,10 +11211,6 @@ static int check_func_callx(struct bpf_verifier_env *env, struct bpf_insn *insn, const char *reason; int err, subprog; - err = require_callx_jit(env); - if (err) - return err; - err = check_reg_arg(env, insn->dst_reg, SRC_OP); if (err) return err; @@ -11240,6 +11236,11 @@ static int check_func_callx(struct bpf_verifier_env *env, struct bpf_insn *insn, if (err) return err; + /* the callx is valid, but only a JIT can execute it */ + err = require_callx_jit(env); + if (err) + return err; + /* PTR_TO_FUNC is a pointer to a static subprog */ subprog = reg->subprogno; err = btf_check_subprog_call(env, subprog, caller->regs); -- 2.53.0