All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH] kallsyms: Fix wrong "big" kernel symbol type read from procfs
@ 2024-08-30  6:29 Zheng Yejian
  2024-08-30  6:32 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Zheng Yejian @ 2024-08-30  6:29 UTC (permalink / raw)
  To: arnd, masahiroy, kees, mcgrof, jannh, ardb, song, gregkh, ojeda,
	gary, wedsonaf
  Cc: zhengyejian, linux-kernel

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.

Fixes: 73bbb94466fd ("kallsyms: support "big" kernel symbols")
Signed-off-by: Zheng Yejian <zhengyejian@huaweicloud.com>
---

Resend this patch due to no reply more than a month.

 kernel/kallsyms.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index a9a0ca605d4a..9e4bf061bb83 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -103,8 +103,11 @@ static char kallsyms_get_symbol_type(unsigned int off)
 {
 	/*
 	 * Get just the first code, look it up in the token table,
-	 * and return the first char from this token.
+	 * and return the first char from this token. If MSB of length
+	 * is 1, it is a "big" symbol, so needs an additional byte.
 	 */
+	if (kallsyms_names[off] & 0x80)
+		off++;
 	return kallsyms_token_table[kallsyms_token_index[kallsyms_names[off + 1]]];
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-30  6:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-30  6:29 [RESEND PATCH] kallsyms: Fix wrong "big" kernel symbol type read from procfs Zheng Yejian
2024-08-30  6:32 ` Greg KH

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.