Re: [PATCH bpf-next v3 2/9] module: Add module_kallsyms_find_name()
From: Andrii Nakryiko
Date: Wed Nov 25 2026 - 15:25:23 EST
On Fri, Nov 13, 2026 at 2:14 PM Samuel Wu <wusamuel@xxxxxxxxxx> wrote:
>
> KALLSYMS_QUERY_BY_NAME, added later in this series, needs to find a
> symbol name or prefix across module symbols in one pass.
> module_get_kallsym() walks the module list from the head and runs an
> export bsearch() for every symbol index.
>
> Add module_kallsyms_find_name(), and put the shared query struct in
> linux/kallsyms.h, so we have a more efficient linear walk.
>
> Signed-off-by: Samuel Wu <wusamuel@xxxxxxxxxx>
> ---
> include/linux/kallsyms.h | 7 +++++
> include/linux/module.h | 13 +++++++++
> kernel/module/kallsyms.c | 57 ++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 77 insertions(+)
>
> diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
> index d5dd54c53ace..d31f2f436159 100644
> --- a/include/linux/kallsyms.h
> +++ b/include/linux/kallsyms.h
> @@ -24,6 +24,13 @@
> struct cred;
> struct module;
>
> +/* Exact or prefix name query, optionally in one module. */
> +struct kallsyms_name_query {
> + const char *name;
> + size_t cmp_len; /* bytes to compare; includes NUL if exact */
> + const char *modname; /* NULL matches any module */
will "vmlinux" match just vmlinux? or how can one express "I only need
symbols from vmlinux image" with this?
> +};
> +
> static inline int is_kernel_text(unsigned long addr)
> {
> if (__is_kernel_text(addr))
[...]