From: Blaise Boscaccy <bboscaccy@linux.microsoft.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: bpf@vger.kernel.org, nkapron@google.com, teknoraver@meta.com,
roberto.sassu@huawei.com, paul@paul-moore.com, code@tyhicks.com,
flaniel@linux.microsoft.com
Subject: Re: [PATCH 07/14] bpf: Implement BPF_LOAD_FD subcommand handler
Date: Fri, 10 Jan 2025 14:41:58 -0800 [thread overview]
Message-ID: <87ldvi47gp.fsf@microsoft.com> (raw)
In-Reply-To: <2025011010-unglue-latch-34ea@gregkh>
Hi Greg,
Greg KH <gregkh@linuxfoundation.org> writes:
> On Thu, Jan 09, 2025 at 01:43:49PM -0800, Blaise Boscaccy wrote:
>> The new LOAD_FD subcommand keys off of a sysfs entry file descriptor
>> and a file descriptor pointing to a raw elf object file.
>
> A sysfs file descriptor? That feels very odd and is not how sysfs
> should be used, as it's only for text files and binary pass-through
> stuff.
>
Yeah, libbpf has a feature where it can load multiple independent
ebpf programs from a single object file. It parses the whole object file
and then for each program, calls BPF_PROG_LOAD. I was trying to mimic that
flow here, by having a single call to BPF_LOAD_FD and allowing
userspace to repeatedly call BPF_PROG_LOAD as needed referencing that
result.
bpffs would probably be a more appropriate choice for this. The purpose
of the PoC was mostly to test whether or not kernel relocs where even doable
and if there was any support for it upstream. The interface could
definitely use some polishing.
I'm also not sure how pervasive that use case is in the wild and if it is
more of a premature optimization here than anything. Alternatively, it
may be acceptable to combine BPF_LOAD_FD and BPF_PROG_LOAD into a single
operation and reparse/relocate for each discrete program load and then
remove all this.
>> +static void bpf_loader_show_fdinfo(struct seq_file *m, struct file *filp)
>> +{
>> + int i;
>> + struct bpf_obj *obj = filp->private_data;
>> +
>> + for (i = 0; i < obj->nr_programs; i++)
>> + seq_printf(m, "program: %s\n", obj->progs[i].name);
>
> So what file is printing this out in sysfs?
There are two file descriptors passed into BPF_LOAD_FD, this uses the
first one (bpffs_fd).
> Where is the
> Documentation/ABI/ entry for it?
>
That's still a TODO and an oversight on my part.
> confused,
>
> greg k-h
Thanks for the feedback.
-blaise
next prev parent reply other threads:[~2025-01-10 22:42 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-09 21:43 [POC][RFC][PATCH] bpf: in-kernel bpf relocations on raw elf files Blaise Boscaccy
2025-01-09 21:43 ` [PATCH 01/14] bpf: Port prerequiste BTF handling functions from userspace Blaise Boscaccy
2025-01-09 21:43 ` [PATCH 02/14] bpf: Add data structures for managing in-kernel eBPF relocations Blaise Boscaccy
2025-01-09 21:43 ` [PATCH 03/14] bpf: Port .btf.ext parsing functions from userspace Blaise Boscaccy
2025-01-09 21:43 ` [PATCH 04/14] bpf: Port elf and btf utility helper " Blaise Boscaccy
2025-01-09 21:43 ` [PATCH 05/14] fs/kernel_read_file: Add an eBPF specifier to kernel_read_file Blaise Boscaccy
2025-01-09 21:43 ` [PATCH 06/14] bpf: Add BPF_LOAD_FD subcommand Blaise Boscaccy
2025-01-09 21:43 ` [PATCH 07/14] bpf: Implement BPF_LOAD_FD subcommand handler Blaise Boscaccy
2025-01-10 6:05 ` Greg KH
2025-01-10 22:41 ` Blaise Boscaccy [this message]
2025-01-11 0:41 ` kernel test robot
2025-01-09 21:43 ` [PATCH 08/14] bpf: Add elf parsing support to the BPF_LOAD_FD subcommand Blaise Boscaccy
2025-01-09 21:43 ` [PATCH 09/14] bpf: Collect extern relocations Blaise Boscaccy
2025-01-11 1:35 ` kernel test robot
2025-01-09 21:43 ` [PATCH 10/14] bpf: Implement BTF fixup functionality Blaise Boscaccy
2025-01-11 3:19 ` kernel test robot
2025-01-09 21:43 ` [PATCH 11/14] bpf: Implement relocation collection Blaise Boscaccy
2025-01-09 21:43 ` [PATCH 12/14] bpf: Resolve external relocations Blaise Boscaccy
2025-01-09 21:43 ` [PATCH 13/14] bpf: Apply in-kernel bpf instruction relocations Blaise Boscaccy
2025-01-09 21:43 ` [PATCH 14/14] bpf: Augment BPF_PROG_LOAD to use in-kernel relocations Blaise Boscaccy
2025-01-10 18:40 ` [POC][RFC][PATCH] bpf: in-kernel bpf relocations on raw elf files Alexei Starovoitov
2025-01-10 23:27 ` Blaise Boscaccy
2025-01-13 17:54 ` Alexei Starovoitov
2025-01-14 18:24 ` Blaise Boscaccy
2025-01-24 5:08 ` bpf signing. " Alexei Starovoitov
2025-01-24 7:05 ` John Fastabend
2025-01-28 22:32 ` Blaise Boscaccy
2025-01-30 1:13 ` Cong Wang
2025-01-30 19:22 ` Blaise Boscaccy
2025-02-01 22:24 ` Cong Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ldvi47gp.fsf@microsoft.com \
--to=bboscaccy@linux.microsoft.com \
--cc=bpf@vger.kernel.org \
--cc=code@tyhicks.com \
--cc=flaniel@linux.microsoft.com \
--cc=gregkh@linuxfoundation.org \
--cc=nkapron@google.com \
--cc=paul@paul-moore.com \
--cc=roberto.sassu@huawei.com \
--cc=teknoraver@meta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).