[DTrace-devel] [PATCH] bpf: improve BPF feature check

Eugene Loh eugene.loh at oracle.com
Tue Nov 26 21:12:58 UTC 2024


Seems reasonable/safe:
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>

On 11/26/24 14:57, Kris Van Hees via DTrace-devel wrote:
> The check for BPF attach types was trying to attach to bpf_check, but
> attaching to that function is rejected by the BPF verifier on some
> kernel versions.  Use bpf_get_btf_vmlinux because that function does
> not take any arguments and therefore should always succeed.
>
> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
>   libdtrace/dt_bpf.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libdtrace/dt_bpf.c b/libdtrace/dt_bpf.c
> index 2a946f0d..662fd81a 100644
> --- a/libdtrace/dt_bpf.c
> +++ b/libdtrace/dt_bpf.c
> @@ -488,8 +488,8 @@ dt_bpf_init_features(dtrace_hdl_t *dtp)
>   {
>   	uint32_t	btf_id;
>   
> -	btf_id = dt_btf_lookup_name_kind(dtp, dtp->dt_shared_btf, "bpf_check",
> -					 BTF_KIND_FUNC);
> +	btf_id = dt_btf_lookup_name_kind(dtp, dtp->dt_shared_btf,
> +					 "bpf_get_btf_vmlinux", BTF_KIND_FUNC);
>   	if (btf_id >= 0 &&
>   	    have_attach_type(BPF_PROG_TYPE_TRACING, BPF_TRACE_FENTRY, btf_id))
>   		BPF_SET_FEATURE(dtp, BPF_FEAT_FENTRY);



More information about the DTrace-devel mailing list