Re: [PATCH] kallsyms: copy constants from __KERNEL__ to user, drop the inclusion

From: Nicolas Schier

Date: Fri Oct 09 2026 - 15:18:27 EST


> commit 4fafd1165b33 replaced hardcoded values which determine marker
> array size, with new values that accelerate symbol-name lookups.
> These symbols are needed in user-space to generate the lookup tables,
> and in kernel to read the generated table.
>
> To avoid 2-defns problem, they were added to a kernel header (with
> ifdef guards) and included by scripts/kallsyms.c. But that creates
> packaging problems elsewhere, so just add the 2nd defns, with an
> explicit comment about the user-kernel coupling.
>
> Fixes: 4fafd1165b33 ("kallsyms: increase marker density to 16:1 to accelerate lookups")
>
> Signed-off-by: Jim Cromie <jim.cromie@xxxxxxxxx>
> ---

FTR: Please keep trailers in a single trailer block, otherwise that will
probably break some common tooling (cp. e.g. git-interpret-trailers).

Is the commit ID correct? In mm-nonmm-unstable I find
e2c2904abf71d0144f37844fde7dffe8b814a44f instead.

> kernel/kallsyms_internal.h | 12 +++++-------
> scripts/kallsyms.c | 9 ++++++++-
> 2 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/kernel/kallsyms_internal.h b/kernel/kallsyms_internal.h
> index 6a781e4cc77f..8311cce21128 100644
> --- a/kernel/kallsyms_internal.h
> +++ b/kernel/kallsyms_internal.h
> @@ -2,18 +2,17 @@
> #ifndef LINUX_KALLSYMS_INTERNAL_H_
> #define LINUX_KALLSYMS_INTERNAL_H_
>
> +#include <linux/types.h>
> +
> /*
> - * Provide compile-constants for scripts/kallsyms.c
> - * so it can build the corresponding kallsyms_marker[] table.
> - * and wrap the rest in __KERNEL__
> + * These constants determine the size of the kallsyms_markers array
> + * written by scripts/kallsyms.c during the build. The symbol values
> + * must be kept in sync.
> */
> #define KALLSYMS_MARKER_SHIFT 4
> #define KALLSYMS_MARKER_SIZE (1U << KALLSYMS_MARKER_SHIFT)
> #define KALLSYMS_MARKER_MASK (KALLSYMS_MARKER_SIZE - 1U)

Keeping these values in sync between kernel and kallsyms/user-space
might be simple by shifting these to some Kconfig symbols. But that
could be done in a follow-up commit as well.

Nevertheless: fixes the report and prevent usage of in-tree header in
user-space tool; thanks!

Tested-by: Nicolas Schier <nsc@xxxxxxxxxx>
Reviewed-by: Nicolas Schier <nsc@xxxxxxxxxx>

--
Nicolas