[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z_aDSipnuvNAhHbE@mini-arch>
Date: Wed, 9 Apr 2025 07:25:14 -0700
From: Stanislav Fomichev <stfomichev@...il.com>
To: Daniel Xu <dxu@...uu.xyz>
Cc: andrii@...nel.org, ast@...nel.org, daniel@...earbox.net,
john.fastabend@...il.com, martin.lau@...ux.dev, eddyz87@...il.com,
song@...nel.org, yonghong.song@...ux.dev, kpsingh@...nel.org,
sdf@...ichev.me, haoluo@...gle.com, jolsa@...nel.org,
bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC bpf-next 10/13] bpf: verifier: Add indirection to
kallsyms_lookup_name()
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@...uu.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
Powered by blists - more mailing lists