lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzZdAft9HUc2MOoQqC_SwkiBQgRTPZHB8MJmwVTY8N=sWQ@mail.gmail.com>
Date: Wed, 14 May 2025 09:39:06 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Jiayuan Chen <jiayuan.chen@...ux.dev>
Cc: Alexei Starovoitov <alexei.starovoitov@...il.com>, bpf <bpf@...r.kernel.org>, 
	Quentin Monnet <qmo@...nel.org>, Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>, 
	Andrii Nakryiko <andrii@...nel.org>, Martin KaFai Lau <martin.lau@...ux.dev>, 
	Eduard Zingerman <eddyz87@...il.com>, Song Liu <song@...nel.org>, 
	Yonghong Song <yonghong.song@...ux.dev>, John Fastabend <john.fastabend@...il.com>, 
	KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>, 
	Jiri Olsa <jolsa@...nel.org>, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH bpf-next v1] bpftool: Add support for custom BTF path in
 prog load/loadall

On Tue, May 13, 2025 at 6:51 PM Jiayuan Chen <jiayuan.chen@...ux.dev> wrote:
>
> 2025/5/14 05:19, "Alexei Starovoitov" <alexei.starovoitov@...il.com> wrote:
>
> >
> > On Mon, May 12, 2025 at 8:59 PM Jiayuan Chen <jiayuan.chen@...ux.dev> wrote:
> >
> > >
> > > This patch exposes the btf_custom_path feature to bpftool, allowing users
> > >
> > >  to specify a custom BTF file when loading BPF programs using prog load or
> > >
> > >  prog loadall commands. This feature is already supported by libbpf, and
> > >
> > >  this patch makes it accessible through the bpftool command-line interface.
> > >
> > >  Signed-off-by: Jiayuan Chen <jiayuan.chen@...ux.dev>
> > >
> > >  ---
> > >
> > >  tools/bpf/bpftool/prog.c | 11 ++++++++++-
> > >
> > >  1 file changed, 10 insertions(+), 1 deletion(-)
> > >
> > >  diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
> > >
> > >  index f010295350be..63f84e765b34 100644
> > >
> > >  --- a/tools/bpf/bpftool/prog.c
> > >
> > >  +++ b/tools/bpf/bpftool/prog.c
> > >
> > >  @@ -1681,8 +1681,17 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
> > >
> > >  } else if (is_prefix(*argv, "autoattach")) {
> > >
> > >  auto_attach = true;
> > >
> > >  NEXT_ARG();
> > >
> > >  + } else if (is_prefix(*argv, "custom_btf")) {
> > >
> > >  + NEXT_ARG();
> > >
> > >  +
> > >
> > >  + if (!REQ_ARGS(1))
> > >
> > >  + goto err_free_reuse_maps;
> > >
> > >  +
> > >
> > >  + open_opts.btf_custom_path = GET_ARG();
> > >
> >
> > I don't see a use case yet.
> >
> > What exactly is the scenario where it's useful ?
> >
>
> This patch just exposes the btf_custom_path feature of libbpf to bpftool.
> The argument 'btf_custom_path' in libbpf is used for those kernes that
> don't have CONFIG_DEBUG_INFO_BTF enabled but still want to perform CO-RE
> relocations. Specifically for older kernels, separate BTF files are already
> provided: https://github.com/aquasecurity/btfhub-archive/.
> If we want load prog using bpftool on those systems, we have to hack
> btf__load_vmlinux_btf() before or write custom loader with libbpf and specify
> 'btf_custom_path'.
>
> I also found a the similar topic:
> https://lore.kernel.org/bpf/20220215225856.671072-1-mauricio@kinvolk.io/
>
> Additionally, pwru supports "--kernel-btf" which serves the same purpose as
> this patch.
>
> Therefore, using an external BTF file is a common practice.

I think it's fine to expose this to bpftool. But maybe call the option
"kernel_btf" to make it more obvious that this is BTF representing
kernel types, as opposed to program BTF itself.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ