All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stanislav Fomichev <stfomichev@gmail.com>
To: Daniel Xu <dxu@dxuuu.xyz>
Cc: andrii@kernel.org, ast@kernel.org, daniel@iogearbox.net,
	john.fastabend@gmail.com, martin.lau@linux.dev,
	eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev,
	kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com,
	jolsa@kernel.org, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC bpf-next 10/13] bpf: verifier: Add indirection to kallsyms_lookup_name()
Date: Wed, 9 Apr 2025 07:25:14 -0700	[thread overview]
Message-ID: <Z_aDSipnuvNAhHbE@mini-arch> (raw)
In-Reply-To: <7540678e9a46c13f680f2aacab28bb88446583f5.1744169424.git.dxu@dxuuu.xyz>

On 04/08, Daniel Xu wrote:
> kallsyms_lookup_name() cannot be exported from the kernel for policy
> reasons, so add this layer of indirection to allow the verifier to still
> do kfunc and global variable relocations.
> 
> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
> ---
>  include/linux/bpf.h   |  2 ++
>  kernel/bpf/core.c     | 14 ++++++++++++++
>  kernel/bpf/verifier.c | 13 +++++--------
>  3 files changed, 21 insertions(+), 8 deletions(-)
> 
> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
> index 44133727820d..a5806a7b31d3 100644
> --- a/include/linux/bpf.h
> +++ b/include/linux/bpf.h
> @@ -2797,6 +2797,8 @@ static inline int kfunc_desc_cmp_by_id_off(const void *a, const void *b)
>  }
>  const struct bpf_kfunc_desc *
>  find_kfunc_desc(const struct bpf_prog *prog, u32 func_id, u16 offset);
> +unsigned long bpf_lookup_type_addr(struct btf *btf, const struct btf_type *func,
> +				   const char **name);
>  int bpf_get_kfunc_addr(const struct bpf_prog *prog, u32 func_id,
>  		       u16 btf_fd_idx, u8 **func_addr);
>  
> diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
> index e892e469061e..13301a668fe0 100644
> --- a/kernel/bpf/core.c
> +++ b/kernel/bpf/core.c
> @@ -1639,6 +1639,20 @@ find_kfunc_desc(const struct bpf_prog *prog, u32 func_id, u16 offset)
>  }
>  EXPORT_SYMBOL_GPL(find_kfunc_desc);
>  
> +unsigned long bpf_lookup_type_addr(struct btf *btf, const struct btf_type *t,
> +				   const char **name)
> +{
> +	unsigned long addr;
> +
> +	*name = btf_name_by_offset(btf, t->name_off);
> +	addr = kallsyms_lookup_name(*name);
> +	if (!addr)
> +		return -ENOENT;
> +
> +	return addr;
> +}
> +EXPORT_SYMBOL_GPL(bpf_lookup_type_addr);

Let's namespecify all these new exports? EXPORT_SYMBOL_NS_GPL

  reply	other threads:[~2025-04-09 14:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09  3:33 [RFC bpf-next 00/13] bpf: Introduce modular verifier Daniel Xu
2025-04-09  3:33 ` [RFC bpf-next 01/13] bpf: Move bpf_prog_ctx_arg_info_init() body into header Daniel Xu
2025-04-09  3:33 ` [RFC bpf-next 02/13] bpf: Move BTF related globals out of verifier.c Daniel Xu
2025-04-09  3:33 ` [RFC bpf-next 03/13] bpf: Move percpu memory allocator definition into core Daniel Xu
2025-04-09  3:33 ` [RFC bpf-next 04/13] bpf: Move bpf_check_attach_target() to core Daniel Xu
2025-04-10  4:33   ` kernel test robot
2025-04-10  5:26   ` kernel test robot
2025-04-09  3:34 ` [RFC bpf-next 05/13] bpf: Remove map_set_for_each_callback_args callback for maps Daniel Xu
2025-04-09  3:34 ` [RFC bpf-next 06/13] bpf: Move kfunc definitions out of verifier.c Daniel Xu
2025-04-10  5:37   ` kernel test robot
2025-04-09  3:34 ` [RFC bpf-next 07/13] bpf: Make bpf_free_kfunc_btf_tab() static in core Daniel Xu
2025-04-09  3:34 ` [RFC bpf-next 08/13] selftests: bpf: Avoid attaching to bpf_check() Daniel Xu
2025-04-09  3:34 ` [RFC bpf-next 09/13] perf: Export perf_snapshot_branch_stack static key Daniel Xu
2025-04-09  3:34 ` [RFC bpf-next 10/13] bpf: verifier: Add indirection to kallsyms_lookup_name() Daniel Xu
2025-04-09 14:25   ` Stanislav Fomichev [this message]
2025-04-15  4:28     ` Daniel Xu
2025-04-09  3:34 ` [RFC bpf-next 11/13] treewide: bpf: Export symbols used by verifier Daniel Xu
2025-04-21 16:13   ` Alexei Starovoitov
2025-04-09  3:34 ` [RFC bpf-next 12/13] bpf: verifier: Make verifier loadable Daniel Xu
2025-04-09  3:34 ` [RFC bpf-next 13/13] bpf: Supporting building verifier.ko out-of-tree Daniel Xu

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=Z_aDSipnuvNAhHbE@mini-arch \
    --to=stfomichev@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dxu@dxuuu.xyz \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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 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.