* [PATCH bpf-next] bpf: Check for helper calls in check_subprogs()
@ 2023-02-20 16:37 Ilya Leoshkevich
2023-02-21 17:10 ` Stanislav Fomichev
2023-02-22 21:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Ilya Leoshkevich @ 2023-02-20 16:37 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko
Cc: bpf, Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Jiri Olsa,
Stanislav Fomichev, Ilya Leoshkevich
The condition src_reg != BPF_PSEUDO_CALL && imm == BPF_FUNC_tail_call
may be satisfied by a kfunc call. This would lead to unnecessarily
setting has_tail_call. Use src_reg == 0 instead.
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
kernel/bpf/verifier.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index e63af41a7e95..6d4632476c9c 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -2462,8 +2462,8 @@ static int check_subprogs(struct bpf_verifier_env *env)
u8 code = insn[i].code;
if (code == (BPF_JMP | BPF_CALL) &&
- insn[i].imm == BPF_FUNC_tail_call &&
- insn[i].src_reg != BPF_PSEUDO_CALL)
+ insn[i].src_reg == 0 &&
+ insn[i].imm == BPF_FUNC_tail_call)
subprog[cur_subprog].has_tail_call = true;
if (BPF_CLASS(code) == BPF_LD &&
(BPF_MODE(code) == BPF_ABS || BPF_MODE(code) == BPF_IND))
--
2.39.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: Check for helper calls in check_subprogs()
2023-02-20 16:37 [PATCH bpf-next] bpf: Check for helper calls in check_subprogs() Ilya Leoshkevich
@ 2023-02-21 17:10 ` Stanislav Fomichev
2023-02-22 21:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Stanislav Fomichev @ 2023-02-21 17:10 UTC (permalink / raw)
To: Ilya Leoshkevich
Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, bpf,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Jiri Olsa
On Mon, Feb 20, 2023 at 8:38 AM Ilya Leoshkevich <iii@linux.ibm.com> wrote:
>
> The condition src_reg != BPF_PSEUDO_CALL && imm == BPF_FUNC_tail_call
> may be satisfied by a kfunc call. This would lead to unnecessarily
> setting has_tail_call. Use src_reg == 0 instead.
Acked-by: Stanislav Fomichev <sdf@google.com>
(although not sure on src_reg == 0 vs !src_reg. Alexei seems to be
favoring the latter?)
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
> kernel/bpf/verifier.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index e63af41a7e95..6d4632476c9c 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -2462,8 +2462,8 @@ static int check_subprogs(struct bpf_verifier_env *env)
> u8 code = insn[i].code;
>
> if (code == (BPF_JMP | BPF_CALL) &&
> - insn[i].imm == BPF_FUNC_tail_call &&
> - insn[i].src_reg != BPF_PSEUDO_CALL)
> + insn[i].src_reg == 0 &&
> + insn[i].imm == BPF_FUNC_tail_call)
> subprog[cur_subprog].has_tail_call = true;
> if (BPF_CLASS(code) == BPF_LD &&
> (BPF_MODE(code) == BPF_ABS || BPF_MODE(code) == BPF_IND))
> --
> 2.39.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: Check for helper calls in check_subprogs()
2023-02-20 16:37 [PATCH bpf-next] bpf: Check for helper calls in check_subprogs() Ilya Leoshkevich
2023-02-21 17:10 ` Stanislav Fomichev
@ 2023-02-22 21:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-02-22 21:20 UTC (permalink / raw)
To: Ilya Leoshkevich; +Cc: ast, daniel, andrii, bpf, hca, gor, agordeev, jolsa, sdf
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Alexei Starovoitov <ast@kernel.org>:
On Mon, 20 Feb 2023 17:37:56 +0100 you wrote:
> The condition src_reg != BPF_PSEUDO_CALL && imm == BPF_FUNC_tail_call
> may be satisfied by a kfunc call. This would lead to unnecessarily
> setting has_tail_call. Use src_reg == 0 instead.
>
> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
> ---
> kernel/bpf/verifier.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Here is the summary with links:
- [bpf-next] bpf: Check for helper calls in check_subprogs()
https://git.kernel.org/bpf/bpf-next/c/df2ccc180a2e
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-22 21:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-20 16:37 [PATCH bpf-next] bpf: Check for helper calls in check_subprogs() Ilya Leoshkevich
2023-02-21 17:10 ` Stanislav Fomichev
2023-02-22 21:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox