* [PATCH bpf-next] bpf: Enforce 'return 0' in BTF-enabled raw_tp programs
@ 2019-10-29 3:24 Alexei Starovoitov
2019-10-29 4:32 ` Andrii Nakryiko
2019-10-30 15:53 ` Daniel Borkmann
0 siblings, 2 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2019-10-29 3:24 UTC (permalink / raw)
To: davem; +Cc: daniel, netdev, bpf, kernel-team
The return value of raw_tp programs is ignored by __bpf_trace_run()
that calls them. The verifier also allows any value to be returned.
For BTF-enabled raw_tp lets enforce 'return 0', so that return value
can be used for something in the future.
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
kernel/bpf/verifier.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index c59778c0fc4d..6b0de04f8b91 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -6279,6 +6279,11 @@ static int check_return_code(struct bpf_verifier_env *env)
case BPF_PROG_TYPE_CGROUP_SYSCTL:
case BPF_PROG_TYPE_CGROUP_SOCKOPT:
break;
+ case BPF_PROG_TYPE_RAW_TRACEPOINT:
+ if (!env->prog->aux->attach_btf_id)
+ return 0;
+ range = tnum_const(0);
+ break;
default:
return 0;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: Enforce 'return 0' in BTF-enabled raw_tp programs
2019-10-29 3:24 [PATCH bpf-next] bpf: Enforce 'return 0' in BTF-enabled raw_tp programs Alexei Starovoitov
@ 2019-10-29 4:32 ` Andrii Nakryiko
2019-10-30 15:53 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2019-10-29 4:32 UTC (permalink / raw)
To: Alexei Starovoitov, davem; +Cc: daniel, netdev, bpf, Kernel Team
On 10/28/19 8:24 PM, Alexei Starovoitov wrote:
> The return value of raw_tp programs is ignored by __bpf_trace_run()
> that calls them. The verifier also allows any value to be returned.
> For BTF-enabled raw_tp lets enforce 'return 0', so that return value
> can be used for something in the future.
>
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
> ---
Looks good, if the return value is ignored, no need to specify anything
but 0 for now.
Acked-by: Andrii Nakryiko <andriin@fb.com>
> kernel/bpf/verifier.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index c59778c0fc4d..6b0de04f8b91 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -6279,6 +6279,11 @@ static int check_return_code(struct bpf_verifier_env *env)
> case BPF_PROG_TYPE_CGROUP_SYSCTL:
> case BPF_PROG_TYPE_CGROUP_SOCKOPT:
> break;
> + case BPF_PROG_TYPE_RAW_TRACEPOINT:
> + if (!env->prog->aux->attach_btf_id)
> + return 0;
> + range = tnum_const(0);
> + break;
> default:
> return 0;
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: Enforce 'return 0' in BTF-enabled raw_tp programs
2019-10-29 3:24 [PATCH bpf-next] bpf: Enforce 'return 0' in BTF-enabled raw_tp programs Alexei Starovoitov
2019-10-29 4:32 ` Andrii Nakryiko
@ 2019-10-30 15:53 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2019-10-30 15:53 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: davem, netdev, bpf, kernel-team
On Mon, Oct 28, 2019 at 08:24:26PM -0700, Alexei Starovoitov wrote:
> The return value of raw_tp programs is ignored by __bpf_trace_run()
> that calls them. The verifier also allows any value to be returned.
> For BTF-enabled raw_tp lets enforce 'return 0', so that return value
> can be used for something in the future.
>
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-10-30 15:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-29 3:24 [PATCH bpf-next] bpf: Enforce 'return 0' in BTF-enabled raw_tp programs Alexei Starovoitov
2019-10-29 4:32 ` Andrii Nakryiko
2019-10-30 15:53 ` Daniel Borkmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.