Thread (52 messages) flat view 52 messages, 4 authors, 2021-04-28

Re: [PATCH v2 bpf-next 10/16] bpf: Add bpf_btf_find_by_name_kind() helper.

From: Alexei Starovoitov <hidden>
Date: 2021-04-28 02:10:26
Also in: bpf

On Tue, Apr 27, 2021 at 02:00:43PM -0700, John Fastabend wrote:
Alexei Starovoitov wrote:
quoted
From: Alexei Starovoitov <ast@kernel.org>

Add new helper:

long bpf_btf_find_by_name_kind(u32 btf_fd, char *name, u32 kind, int flags)
	Description
		Find given name with given type in BTF pointed to by btf_fd.
		If btf_fd is zero look for the name in vmlinux BTF and in module's BTFs.
	Return
		Returns btf_id and btf_obj_fd in lower and upper 32 bits.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
I'm missing some high-level concept on how this would be used? Where does btf_fd come
from and how is it used so that it doesn't break sig-check?
you mean that one that is being returned or the one passed in?
The one that is passed in I only tested locally. No patches use that. Sorry.
It's to support PROG_EXT. That btf_fd points to BTF of the prog that is being extended.
The signed extension prog will have the name of subprog covered by the signature,
but target btf_fd of the prog won't be known at signing time.
It will be supplied via struct bpf_prog_desc. That's what attach_prog_fd is there for.
I can remove all that stuff for now.
The name of target prog doesn't have to be part of the signature.
All of these details are to be discussed.
We can make signature as tight as we want or more flexible.
A use-case I'm trying to fit into this series is how to pass down a BTF fd/object
with the program. 
I'm not sure I follow.
struct bpf_prog_desc will have more fields that can be populated to tweak
particular prog before running the loader.
I know its not doing CO-RE yet but we would want it to use the
BTF object being passed down for CO-RE eventually. Will there be someway to do
that here? That looks like the btf_fd here.
I've started hacking on CO-RE. So far I'm thinking to pass spec string to
the kernel in another section of btf.ext. Similar to line_info and func_info.
As an orthogonal discussion I think CO-RE should be able to relocate
against already loaded bpf progs too (and not only kernel and modules).
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help