Since the interpreter does not support the arena-related insns,
interpreter fallback should not be allowed for these insns in
core.c::__bpf_prog_select_runtime().

Currently, when the interpreter executes the arena ST/LDX/STX insns,
it would hit the BUG_ON() in ___bpf_prog_run() at run time.

[    2.579196] BPF interpreter: unknown opcode a2 (imm: 0x0)
[    2.579998] ------------[ cut here ]------------
[    2.580652] kernel BUG at kernel/bpf/core.c:2349!
[    2.581314] Oops: invalid opcode: 0000 [#1] SMP PTI

Set jit_required as true when arena map is used in the prog to disallow
interpreter fallback for arena-related insns.

Fixes: 6082b6c328b5 ("bpf: Recognize addr_space_cast instruction in the 
verifier.")
Signed-off-by: Leon Hwang <[email protected]>
---
 kernel/bpf/verifier.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index de816063ae63..3849d3d00e15 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -17873,6 +17873,7 @@ static int check_map_prog_compatibility(struct 
bpf_verifier_env *env,
                        return -EOPNOTSUPP;
                }
                env->prog->aux->arena = (void *)map;
+               env->prog->jit_required = true;
                if (!bpf_arena_get_user_vm_start(env->prog->aux->arena)) {
                        verbose(env, "arena's user address must be set via 
map_extra or mmap()\n");
                        return -EINVAL;
-- 
2.55.0


Reply via email to