The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] lib/vsprintf: Require exact hash_pointers mode matches
@ 2026-05-19 13:01 Kaitao Cheng
  2026-05-21 11:52 ` Petr Mladek
  2026-05-26  9:13 ` Petr Mladek
  0 siblings, 2 replies; 3+ messages in thread
From: Kaitao Cheng @ 2026-05-19 13:01 UTC (permalink / raw)
  To: akpm, pmladek, rostedt, andriy.shevchenko, linux, senozhatsky
  Cc: linux-kernel, Kaitao Cheng

From: Kaitao Cheng <chengkaitao@kylinos.cn>

hash_pointers= accepts a small set of mode strings, but the parser uses
strncmp() with the length of each valid mode.  That accepts values with
trailing garbage, such as hash_pointers=autobots or
hash_pointers=nevermind, as valid aliases for auto and never.

Use strcmp() so that only the documented mode strings are accepted.
Invalid values will continue to fall back to auto through the existing
unknown-mode path.

Signed-off-by: Kaitao Cheng <chengkaitao@kylinos.cn>
---
 lib/vsprintf.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 9ca676feb8eb..03e87b933fd0 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -2354,13 +2354,13 @@ static int __init hash_pointers_mode_parse(char *str)
 	if (!str) {
 		pr_warn("Hash pointers mode empty; falling back to auto.\n");
 		hash_pointers_mode = HASH_PTR_AUTO;
-	} else if (strncmp(str, "auto", 4) == 0)   {
+	} else if (strcmp(str, "auto") == 0) {
 		pr_info("Hash pointers mode set to auto.\n");
 		hash_pointers_mode = HASH_PTR_AUTO;
-	} else if (strncmp(str, "never", 5) == 0) {
+	} else if (strcmp(str, "never") == 0) {
 		pr_info("Hash pointers mode set to never.\n");
 		hash_pointers_mode = HASH_PTR_NEVER;
-	} else if (strncmp(str, "always", 6) == 0) {
+	} else if (strcmp(str, "always") == 0) {
 		pr_info("Hash pointers mode set to always.\n");
 		hash_pointers_mode = HASH_PTR_ALWAYS;
 	} else {
-- 
2.50.1 (Apple Git-155)


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

end of thread, other threads:[~2026-05-26  9:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-19 13:01 [PATCH] lib/vsprintf: Require exact hash_pointers mode matches Kaitao Cheng
2026-05-21 11:52 ` Petr Mladek
2026-05-26  9:13 ` Petr Mladek

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