diff options
author | Tony Ambardar <tony.ambardar@gmail.com> | 2022-06-17 12:57:34 +0200 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2022-06-21 18:52:04 +0200 |
commit | 95acd8817e66d031d2e6ee7def3f1e1874819317 (patch) | |
tree | f42808f3e806be15132e6978a1f2501eef59372b /kernel | |
parent | b40b414ec8d971be0b2f6485c3a039b0fa7f078c (diff) | |
download | linux-stable-95acd8817e66d031d2e6ee7def3f1e1874819317.tar.gz linux-stable-95acd8817e66d031d2e6ee7def3f1e1874819317.tar.bz2 linux-stable-95acd8817e66d031d2e6ee7def3f1e1874819317.zip |
bpf, x64: Add predicate for bpf2bpf with tailcalls support in JIT
The BPF core/verifier is hard-coded to permit mixing bpf2bpf and tail
calls for only x86-64. Change the logic to instead rely on a new weak
function 'bool bpf_jit_supports_subprog_tailcalls(void)', which a capable
JIT backend can override.
Update the x86-64 eBPF JIT to reflect this.
Signed-off-by: Tony Ambardar <Tony.Ambardar@gmail.com>
[jakub: drop MIPS bits and tweak patch subject]
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220617105735.733938-2-jakub@cloudflare.com
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/bpf/core.c | 6 | ||||
-rw-r--r-- | kernel/bpf/verifier.c | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index b5ffebcce6cc..f023cb399e3f 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -2729,6 +2729,12 @@ bool __weak bpf_jit_needs_zext(void) return false; } +/* Return TRUE if the JIT backend supports mixing bpf2bpf and tailcalls. */ +bool __weak bpf_jit_supports_subprog_tailcalls(void) +{ + return false; +} + bool __weak bpf_jit_supports_kfunc_call(void) { return false; diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index bf72dc511df6..a20d7736a5b2 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -6154,7 +6154,8 @@ static bool may_update_sockmap(struct bpf_verifier_env *env, int func_id) static bool allow_tail_call_in_subprogs(struct bpf_verifier_env *env) { - return env->prog->jit_requested && IS_ENABLED(CONFIG_X86_64); + return env->prog->jit_requested && + bpf_jit_supports_subprog_tailcalls(); } static int check_map_func_compatibility(struct bpf_verifier_env *env, |