bpf: Check the helper function is valid in get_helper_proto
Jiri Olsa
reviewerPATCH v3 1/1 bpf: Check the helper function is valid in get_helper_proto
From: Jiri Olsa <[email protected]>
kernel test robot reported verifier bug [1] where the helper func pointer could be NULL due to disabled config option.
As Alexei suggested we could check on that in get_helper_proto directly. Marking tail_call helper func with BPF_PTR_POISON, because it is unused by design.
[1] https://lore.kernel.org/oe-lkp/[email protected]
---
v3 changes:
- use BPF_PTR_POISON instead of number 1 [Andrii]
- fixed reported info and ack [Paul]
kernel/bpf/core.c | 5 ++++- kernel/bpf/verifier.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-)
kernel/bpf/core.c +4 -1
@@ -3024,7 +3024,10 @@ EXPORT_SYMBOL_GPL(bpf_event_output);/* Always built-in helper functions. */ const struct bpf_func_proto bpf_tail_call_proto = { - .func =NULL , +/* func is unused for tail_call, we set it to pass the +* get_helper_proto check +*/ + .func =BPF_PTR_POISON , .gpl_only = false, .ret_type =RET_VOID , .arg1_type =ARG_PTR_TO_CTX ,
kernel/bpf/verifier.c +1 -1
@@ -11354,7 +11354,7 @@ static int get_helper_proto(struct bpf_verifier_env *env, int func_id,return -EINVAL ; *ptr = env->ops->get_func_proto (func_id, env->prog); -return *ptr ?0 : -EINVAL ; +return *ptr && (*ptr)->func ?0 : -EINVAL ; } static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
Signature · 1 line
2.50.1
This patch was applied to bpf/bpf.git (master) by Daniel Borkmann <[email protected]>:
Hello:
This patch was applied to bpf/bpf.git (master)
by Daniel Borkmann <[email protected]>:
Quoted 10 lines · On Thu, 14 Aug 2025 22:06:55 +0200 you wrote:
From: Jiri Olsa <[email protected]>
kernel test robot reported verifier bug [1] where the helper func pointer could be NULL due to disabled config option.
As Alexei suggested we could check on that in
get_helper_protodirectly. Markingtail_callhelper func withBPF_PTR_POISON, because it is unused by design.[...]
Here is the summary with links:
- [PATCHv3,bpf] bpf: Check the helper function is valid in get_helper_proto
https://git.kernel.org/bpf/bpf/c/e4414b01c1cd
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html