Linux s390 Architecture development
 help / color / mirror / Atom feed
* [PATCH 1/3] init/Kconfig: generalize config COMMAND_LINE_SIZE to all architectures
       [not found] <20260806060556.451370-1-wfelipe@google.com>
@ 2026-08-06  6:05 ` Wilson Felipe Pereira
  0 siblings, 0 replies; 3+ messages in thread
From: Wilson Felipe Pereira @ 2026-08-06  6:05 UTC (permalink / raw)
  To: Arnd Bergmann, Andrew Morton
  Cc: Yosry Ahmed, Wilson Felipe Pereira, Maciej Żenczykowski,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, linux-s390

Currently, only s390 has the ability to configure the maximum kernel
command line size via Kconfig (CONFIG_COMMAND_LINE_SIZE). Other
architectures define a hardcoded COMMAND_LINE_SIZE macro in their setup.sh
headers.

In some use cases, such as netboot kernels, rootfs configurations, larger
initramfs setups, require larger sizes. While for embedded workloads, it
can be reduced to save memory.

Move config COMMAND_LINE_SIZE out of arch/s390/Kconfig and into
init/Kconfig under General setup so that all architectures can configure
their maximum command line length. The default values were added to keep
the values unchanged.

Originally-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: Wilson Felipe Pereira <wfelipe@google.com>
---
 arch/s390/Kconfig |  8 --------
 init/Kconfig      | 12 ++++++++++++
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 84404e6778d50..f5536e042ce29 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -511,14 +511,6 @@ endchoice
 config 64BIT
 	def_bool y
 
-config COMMAND_LINE_SIZE
-	int "Maximum size of kernel command line"
-	default 4096
-	range 896 1048576
-	help
-	  This allows you to specify the maximum length of the kernel command
-	  line.
-
 config SMP
 	def_bool y
 
diff --git a/init/Kconfig b/init/Kconfig
index 10f2013b53216..d42bb55cb2152 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1569,6 +1569,18 @@ config BOOT_CONFIG_EMBED_FILE
 	  This bootconfig will be used if there is no initrd or no other
 	  bootconfig in the initrd.
 
+config COMMAND_LINE_SIZE
+	int "Maximum size of kernel command line"
+	default 4096 if S390 || LOONGARCH || MIPS || UM
+	default 2048 if X86 || ARM64 || POWERPC || SPARC64
+	default 1024 if ARM || PARISC || RISCV
+	default 256 if ALPHA || ARC || M68K || MICROBLAZE || SPARC32 || XTENSA
+	default 512
+	range 256 1048576
+	help
+	  This allows you to specify the maximum length of the kernel command
+	  line.
+
 config CMDLINE_LOG_WRAP_IDEAL_LEN
 	int "Length to try to wrap the cmdline when logged at boot"
 	default 1021
-- 
2.55.0.654.g21b8a5bc05-goog


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

* [PATCH 1/3] init/Kconfig: generalize config COMMAND_LINE_SIZE to all architectures
  2026-08-06  6:14 [PATCH 0/3] init/Kconfig: generalize config COMMAND_LINE_SIZE Wilson Felipe Pereira
@ 2026-08-06  6:14 ` Wilson Felipe Pereira
  2026-08-06  6:26   ` sashiko-bot
  0 siblings, 1 reply; 3+ messages in thread
From: Wilson Felipe Pereira @ 2026-08-06  6:14 UTC (permalink / raw)
  To: Arnd Bergmann, Andrew Morton
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, linux-arch, linux-riscv,
	linux-s390, Wilson Felipe Pereira, Maciej Żenczykowski

Currently, only s390 has the ability to configure the maximum kernel
command line size via Kconfig (CONFIG_COMMAND_LINE_SIZE). Other
architectures define a hardcoded COMMAND_LINE_SIZE macro in their setup.sh
headers.

In some use cases, such as netboot kernels, rootfs configurations, larger
initramfs setups, require larger sizes. While for embedded workloads, it
can be reduced to save memory.

Move config COMMAND_LINE_SIZE out of arch/s390/Kconfig and into
init/Kconfig under General setup so that all architectures can configure
their maximum command line length. The default values were added to keep
the values unchanged.

Originally-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: Wilson Felipe Pereira <wfelipe@google.com>
---
 arch/s390/Kconfig |  8 --------
 init/Kconfig      | 12 ++++++++++++
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 84404e6778d50..f5536e042ce29 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -511,14 +511,6 @@ endchoice
 config 64BIT
 	def_bool y
 
-config COMMAND_LINE_SIZE
-	int "Maximum size of kernel command line"
-	default 4096
-	range 896 1048576
-	help
-	  This allows you to specify the maximum length of the kernel command
-	  line.
-
 config SMP
 	def_bool y
 
diff --git a/init/Kconfig b/init/Kconfig
index 10f2013b53216..d42bb55cb2152 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1569,6 +1569,18 @@ config BOOT_CONFIG_EMBED_FILE
 	  This bootconfig will be used if there is no initrd or no other
 	  bootconfig in the initrd.
 
+config COMMAND_LINE_SIZE
+	int "Maximum size of kernel command line"
+	default 4096 if S390 || LOONGARCH || MIPS || UM
+	default 2048 if X86 || ARM64 || POWERPC || SPARC64
+	default 1024 if ARM || PARISC || RISCV
+	default 256 if ALPHA || ARC || M68K || MICROBLAZE || SPARC32 || XTENSA
+	default 512
+	range 256 1048576
+	help
+	  This allows you to specify the maximum length of the kernel command
+	  line.
+
 config CMDLINE_LOG_WRAP_IDEAL_LEN
 	int "Length to try to wrap the cmdline when logged at boot"
 	default 1021
-- 
2.55.0.654.g21b8a5bc05-goog


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

* Re: [PATCH 1/3] init/Kconfig: generalize config COMMAND_LINE_SIZE to all architectures
  2026-08-06  6:14 ` [PATCH 1/3] init/Kconfig: generalize config COMMAND_LINE_SIZE to all architectures Wilson Felipe Pereira
@ 2026-08-06  6:26   ` sashiko-bot
  0 siblings, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-08-06  6:26 UTC (permalink / raw)
  To: Wilson Felipe Pereira
  Cc: Alexander Gordeev, Heiko Carstens, Vasily Gorbik, linux-s390

Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [High] Moving COMMAND_LINE_SIZE to init/Kconfig removes the minimum size limit of 896 bytes for s390, allowing legacy bootloaders to overflow the parmarea and corrupt the kernel .text section.
- [Medium] The newly introduced COMMAND_LINE_SIZE Kconfig option is silently bypassed and acts as a placebo for all architectures except s390.
- [Medium] Making COMMAND_LINE_SIZE globally configurable via Kconfig conflicts with its static definition in userspace-exported UAPI headers.
- [Medium] The Kconfig default definition for COMMAND_LINE_SIZE references the non-existent symbol 'UM'.
- [Medium] The default value of CONFIG_COMMAND_LINE_SIZE for RISC-V is incorrectly set to 1024, which is a reduction from its existing hardcoded size of 2048.
--

--- Patch [1]: [PATCH 1/3] init/Kconfig: generalize config COMMAND_LINE_SIZE to all architectures ---
commit 331242b120be7dde8a2decc92398462a27944ed5
Author: Wilson Felipe Pereira <wfelipe@google.com>
Subject: init/Kconfig: generalize config COMMAND_LINE_SIZE to all architectures

This commit moves CONFIG_COMMAND_LINE_SIZE from s390 to init/Kconfig to
allow all architectures to configure their maximum command line length. It
also sets default values intended to match the existing hardcoded sizes.

[ ... ]

> diff --git a/init/Kconfig b/init/Kconfig
> index 5230d4879b1c8..c581817966ee2 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -1566,6 +1566,18 @@ config BOOT_CONFIG_EMBED_FILE
>  	  This bootconfig will be used if there is no initrd or no other
>  	  bootconfig in the initrd.
>  
> +config COMMAND_LINE_SIZE

[Severity: Medium]
Will this Kconfig option actually be used by other architectures?

For example, in arch/x86/include/asm/setup.h, COMMAND_LINE_SIZE is still
defined as a hardcoded macro:

#define COMMAND_LINE_SIZE 2048

Because the C preprocessor will continue to use the hardcoded macro rather
than the CONFIG_COMMAND_LINE_SIZE Kbuild variable, won't any changes made
by users in menuconfig be silently ignored on architectures other than s390?


[Severity: Medium]
Furthermore, does making this globally configurable conflict with its static
definition in userspace-exported UAPI headers?

Many architectures expose this as a hardcoded constant in their
include/uapi/asm/setup.h headers:

arch/arm64/include/uapi/asm/setup.h:
#define COMMAND_LINE_SIZE 2048

Since UAPI headers cannot depend on kernel build configurations (they do
not include <generated/autoconf.h>), if an architecture maintainer tries to
fix the bypass by replacing the hardcoded value with the Kconfig variable,
wouldn't that break the userspace ABI for tools like kexec-tools which rely
on the UAPI header?

> +	int "Maximum size of kernel command line"
> +	default 4096 if S390 || LOONGARCH || MIPS || UM

[Severity: Medium]
Is UM the correct Kconfig symbol here?

The User-Mode Linux architecture uses the config symbol UML. If UM
evaluates to false because it does not exist, won't User-Mode Linux builds
silently fall back to the incorrect default of 512 instead of 4096?

> +	default 2048 if X86 || ARM64 || POWERPC || SPARC64
> +	default 1024 if ARM || PARISC || RISCV

[Severity: Medium]
The commit message mentions adding defaults to keep values unchanged, but
is 1024 the correct default for RISC-V?

Checking arch/riscv/include/uapi/asm/setup.h shows that the current size
is 2048. If this Kconfig option is respected, would this cause a regression
by halving the allowed command line size for RISC-V?

> +	default 256 if ALPHA || ARC || M68K || MICROBLAZE || SPARC32 || XTENSA
> +	default 512
> +	range 256 1048576

[Severity: High]
Does lowering the minimum range to 256 introduce memory corruption risks
for s390?

The previous range in arch/s390/Kconfig enforced a minimum of 896 bytes. On
s390, the command_line buffer is placed at the end of struct parmarea, and
the executable .text section immediately follows it in the linker script:

arch/s390/boot/vmlinux.lds.S:
.text : {
    _text = .;  /* Text */

If an administrator configures a small size like 256, and a legacy
bootloader writes up to the historical 896 bytes into the parmarea,
wouldn't it overrun the buffer and corrupt the .text section?

> +	help
> +	  This allows you to specify the maximum length of the kernel command
> +	  line.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260806061429.474992-1-wfelipe@google.com?part=1

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

end of thread, other threads:[~2026-08-06  6:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260806060556.451370-1-wfelipe@google.com>
2026-08-06  6:05 ` [PATCH 1/3] init/Kconfig: generalize config COMMAND_LINE_SIZE to all architectures Wilson Felipe Pereira
2026-08-06  6:14 [PATCH 0/3] init/Kconfig: generalize config COMMAND_LINE_SIZE Wilson Felipe Pereira
2026-08-06  6:14 ` [PATCH 1/3] init/Kconfig: generalize config COMMAND_LINE_SIZE to all architectures Wilson Felipe Pereira
2026-08-06  6:26   ` sashiko-bot

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