diff options
author | Eduard Zingerman <eddyz87@gmail.com> | 2024-08-22 10:41:10 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2024-08-22 17:35:21 +0200 |
commit | 40609093247b586ee6f8ca8f2b30c7d583c6fd25 (patch) | |
tree | 5599ee1b0294b09fc2d9d886f40dd2df189f3d88 /kernel/bpf/verifier.c | |
parent | bpf: support bpf_fastcall patterns for kfuncs (diff) | |
download | linux-40609093247b586ee6f8ca8f2b30c7d583c6fd25.tar.xz linux-40609093247b586ee6f8ca8f2b30c7d583c6fd25.zip |
bpf: allow bpf_fastcall for bpf_cast_to_kern_ctx and bpf_rdonly_cast
do_misc_fixups() relaces bpf_cast_to_kern_ctx() and bpf_rdonly_cast()
by a single instruction "r0 = r1". This follows bpf_fastcall contract.
This commit allows bpf_fastcall pattern rewrite for these two
functions in order to use them in bpf_fastcall selftests.
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/r/20240822084112.3257995-5-eddyz87@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/bpf/verifier.c')
-rw-r--r-- | kernel/bpf/verifier.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 94308cc7c503..543b8c9edac7 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -16170,6 +16170,9 @@ static u32 kfunc_fastcall_clobber_mask(struct bpf_kfunc_call_arg_meta *meta) /* Same as verifier_inlines_helper_call() but for kfuncs, see comment above */ static bool is_fastcall_kfunc_call(struct bpf_kfunc_call_arg_meta *meta) { + if (meta->btf == btf_vmlinux) + return meta->func_id == special_kfunc_list[KF_bpf_cast_to_kern_ctx] || + meta->func_id == special_kfunc_list[KF_bpf_rdonly_cast]; return false; } |