public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2] kallsyms: Fix wrong "big" kernel symbol type read from procfs
       [not found] <20241011143853.3022643-1-zhengyejian@huaweicloud.com>
@ 2025-11-11 21:13 ` Miguel Ojeda
  0 siblings, 0 replies; only message in thread
From: Miguel Ojeda @ 2025-11-11 21:13 UTC (permalink / raw)
  To: zhengyejian
  Cc: ardb, arnd, boqun.feng, gary, gregkh, jannh, kees, linux-kernel,
	masahiroy, mcgrof, ndesaulniers, song, wedsonaf, willy, yeweihua4,
	Arnaldo Carvalho de Melo, stable

On Fri, 11 Oct 2024 22:38:53 +0800 Zheng Yejian <zhengyejian@huaweicloud.com> wrote:
>
> Currently when the length of a symbol is longer than 0x7f characters,
> its type shown in /proc/kallsyms can be incorrect.
>
> I found this issue when reading the code, but it can be reproduced by
> following steps:
>
> 1. Define a function which symbol length is 130 characters:
>
> #define X13(x) x##x##x##x##x##x##x##x##x##x##x##x##x
> static noinline void X13(x123456789)(void)
> {
> printk("hello world\n");
> }
>
> 2. The type in vmlinux is 't':
>
> $ nm vmlinux | grep x123456
> ffffffff816290f0 t x123456789x123456789x123456789x12[...]
>
> 3. Then boot the kernel, the type shown in /proc/kallsyms becomes 'g'
> instead of the expected 't':
>
> # cat /proc/kallsyms | grep x123456
> ffffffff816290f0 g x123456789x123456789x123456789x12[...]
>
> The root cause is that, after commit 73bbb94466fd ("kallsyms: support
> "big" kernel symbols"), ULEB128 was used to encode symbol name length.
> That is, for "big" kernel symbols of which name length is longer than
> 0x7f characters, the length info is encoded into 2 bytes.
>
> kallsyms_get_symbol_type() expects to read the first char of the
> symbol name which indicates the symbol type. However, due to the
> "big" symbol case not being handled, the symbol type read from
> /proc/kallsyms may be wrong, so handle it properly.
>
> Cc: stable@vger.kernel.org
> Fixes: 73bbb94466fd ("kallsyms: support "big" kernel symbols")
> Signed-off-by: Zheng Yejian <zhengyejian@huaweicloud.com>

Gary made me aware of this thread (thanks!) -- we are coming from:

    https://lore.kernel.org/all/aQjua6zkEHYNVN3X@x1/

For which I sent this patch without knowing about this one:

    https://lore.kernel.org/rust-for-linux/20251107050414.511648-1-ojeda@kernel.org/

This has been seen now by Arnaldo (Cc'ing) in a real system, so I think
we should take this one since it was first, with:

Cc: stable@vger.kernel.org

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-11-11 21:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20241011143853.3022643-1-zhengyejian@huaweicloud.com>
2025-11-11 21:13 ` [PATCH v2] kallsyms: Fix wrong "big" kernel symbol type read from procfs Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox