mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] x86/cmdline: Fix cmdline_find_option_bool() for unavailable cmdlines
@ 2026-09-21 11:13 Thorsten Blum
  0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-09-21 11:13 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86,
	H. Peter Anvin, Yue Haibing, devzero
  Cc: Thorsten Blum, Ingo Molnar, linux-kernel

cmdline_find_option_bool() returns the position of the requested option,
or 0 if it is not found. However, its implementations return -1 when the
command line is unavailable.

Several callers interpret -1 as an option being present. This can print
the setup debug message, suppress EDD output, force PAE, disable KASLR,
or prevent 5-level paging from being enabled, even without a command
line.

Return 0 from cmdline_find_option_bool() instead to match the documented
behavior when the command line is unavailable.

Fixes: 32d0b9898029 ("x86 setup: early cmdline parser handle boolean options")
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
Changes in v2:
- Describe the user-visible effects in the commit message
- Drop unnecessary comment changes
- v1: https://lore.kernel.org/r/20260801125444.18082-2-thorsten.blum@linux.dev/
---
 arch/x86/boot/boot.h    | 2 +-
 arch/x86/boot/cmdline.c | 2 +-
 arch/x86/lib/cmdline.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
index 8e3eab34dff4..b623572b6964 100644
--- a/arch/x86/boot/boot.h
+++ b/arch/x86/boot/boot.h
@@ -261,7 +261,7 @@ static inline int cmdline_find_option_bool(const char *option)
 	unsigned long cmd_line_ptr = boot_params.hdr.cmd_line_ptr;
 
 	if (cmd_line_ptr >= 0x100000)
-		return -1;      /* inaccessible */
+		return 0;	/* inaccessible */
 
 	return __cmdline_find_option_bool(cmd_line_ptr, option);
 }
diff --git a/arch/x86/boot/cmdline.c b/arch/x86/boot/cmdline.c
index 21d56ae83cdf..69dc33832a9d 100644
--- a/arch/x86/boot/cmdline.c
+++ b/arch/x86/boot/cmdline.c
@@ -110,7 +110,7 @@ int __cmdline_find_option_bool(unsigned long cmdline_ptr, const char *option)
 	} state = st_wordstart;
 
 	if (!cmdline_ptr)
-		return -1;      /* No command line */
+		return 0;	/* No command line */
 
 	cptr = cmdline_ptr & 0xf;
 	set_fs(cmdline_ptr >> 4);
diff --git a/arch/x86/lib/cmdline.c b/arch/x86/lib/cmdline.c
index c65cd5550454..f1e65aa8c479 100644
--- a/arch/x86/lib/cmdline.c
+++ b/arch/x86/lib/cmdline.c
@@ -42,7 +42,7 @@ __cmdline_find_option_bool(const char *cmdline, int max_cmdline_size,
 	} state = st_wordstart;
 
 	if (!cmdline)
-		return -1;      /* No command line */
+		return 0;	/* No command line */
 
 	/*
 	 * This 'pos' check ensures we do not overrun

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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-21 11:13 [PATCH v2] x86/cmdline: Fix cmdline_find_option_bool() for unavailable cmdlines Thorsten Blum

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

all inboxes | Powered by JetHome®