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; 9+ 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] 9+ messages in thread

* [PATCH 0/3] init/Kconfig: generalize config COMMAND_LINE_SIZE
@ 2026-08-06  6:14 Wilson Felipe Pereira
  2026-08-06  6:14 ` [PATCH 1/3] init/Kconfig: generalize config COMMAND_LINE_SIZE to all architectures Wilson Felipe Pereira
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ 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

[Note: Resending the full series to ensure all patches are delivered with a
 unified recipient and CC list across all mailing lists.]

This patch series promotes COMMAND_LINE_SIZE from arch/s390/Kconfig to
init/Kconfig to be generally available to other architectures.

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.

Since COMMAND_LINE_SIZE can be larger, it also makes sense to allow
INIT_ENV_ARG_LIMIT to be configured.

Wilson Felipe Pereira (3):
  init/Kconfig: generalize config COMMAND_LINE_SIZE to all architectures
  arch: use CONFIG_COMMAND_LINE_SIZE across all architectures
  init/Kconfig: make config INIT_ENV_ARG_LIMIT user-configurable

 arch/alpha/include/uapi/asm/setup.h      |  4 ++++
 arch/arc/include/asm/setup.h             |  2 +-
 arch/arm/include/uapi/asm/setup.h        |  6 +++++-
 arch/arm64/include/uapi/asm/setup.h      |  4 ++++
 arch/loongarch/include/uapi/asm/setup.h  |  4 ++++
 arch/m68k/include/uapi/asm/setup.h       |  6 +++++-
 arch/microblaze/include/uapi/asm/setup.h |  4 ++++
 arch/mips/include/uapi/asm/setup.h       |  4 ++++
 arch/parisc/include/uapi/asm/setup.h     |  4 ++++
 arch/powerpc/include/uapi/asm/setup.h    |  4 ++++
 arch/riscv/include/uapi/asm/setup.h      |  4 ++++
 arch/s390/Kconfig                        |  8 --------
 arch/sparc/include/uapi/asm/setup.h      | 10 +++++++---
 arch/um/include/asm/setup.h              |  2 +-
 arch/x86/include/asm/setup.h             |  2 +-
 arch/xtensa/include/uapi/asm/setup.h     |  4 ++++
 include/uapi/asm-generic/setup.h         |  4 ++++
 init/Kconfig                             | 15 ++++++++++++++-
 18 files changed, 74 insertions(+), 17 deletions(-)

--
2.55.0.654.g21b8a5bc05-goog

^ permalink raw reply	[flat|nested] 9+ 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
  2026-08-06  6:14 ` [PATCH 2/3] arch: use CONFIG_COMMAND_LINE_SIZE across " Wilson Felipe Pereira
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ 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] 9+ messages in thread

* [PATCH 2/3] arch: use CONFIG_COMMAND_LINE_SIZE across 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 ` [PATCH 1/3] init/Kconfig: generalize config COMMAND_LINE_SIZE to all architectures Wilson Felipe Pereira
@ 2026-08-06  6:14 ` Wilson Felipe Pereira
  2026-08-06  6:25   ` sashiko-bot
  2026-08-06  6:14 ` [PATCH 3/3] init/Kconfig: make config INIT_ENV_ARG_LIMIT user-configurable Wilson Felipe Pereira
  2026-08-06 22:57 ` [PATCH 0/3] init/Kconfig: generalize config COMMAND_LINE_SIZE Andrew Morton
  3 siblings, 1 reply; 9+ 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

Now that CONFIG_COMMAND_LINE_SIZE is available in init/Kconfig for all
architectures, update every architecture's setup.h header to define
COMMAND_LINE_SIZE as CONFIG_COMMAND_LINE_SIZE.

For user-space API (uapi) headers, wrap the definition in an
`#ifdef __KERNEL__` guard and retain the historical hardcoded default in
the `#else` block. When user-space headers are installed via
`make headers_install`, unifdef strips out the kernel section, ensuring
same value as before for user-space applications including `<asm/setup.h>`.

Originally-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: Wilson Felipe Pereira <wfelipe@google.com>
---
 arch/alpha/include/uapi/asm/setup.h      |  4 ++++
 arch/arc/include/asm/setup.h             |  2 +-
 arch/arm/include/uapi/asm/setup.h        |  6 +++++-
 arch/arm64/include/uapi/asm/setup.h      |  4 ++++
 arch/loongarch/include/uapi/asm/setup.h  |  4 ++++
 arch/m68k/include/uapi/asm/setup.h       |  6 +++++-
 arch/microblaze/include/uapi/asm/setup.h |  4 ++++
 arch/mips/include/uapi/asm/setup.h       |  4 ++++
 arch/parisc/include/uapi/asm/setup.h     |  4 ++++
 arch/powerpc/include/uapi/asm/setup.h    |  4 ++++
 arch/riscv/include/uapi/asm/setup.h      |  4 ++++
 arch/sparc/include/uapi/asm/setup.h      | 10 +++++++---
 arch/um/include/asm/setup.h              |  2 +-
 arch/x86/include/asm/setup.h             |  2 +-
 arch/xtensa/include/uapi/asm/setup.h     |  4 ++++
 include/uapi/asm-generic/setup.h         |  4 ++++
 16 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/arch/alpha/include/uapi/asm/setup.h b/arch/alpha/include/uapi/asm/setup.h
index f881ea5947cbc..169f743ef7658 100644
--- a/arch/alpha/include/uapi/asm/setup.h
+++ b/arch/alpha/include/uapi/asm/setup.h
@@ -2,6 +2,10 @@
 #ifndef _UAPI__ALPHA_SETUP_H
 #define _UAPI__ALPHA_SETUP_H
 
+#ifdef __KERNEL__
+#define COMMAND_LINE_SIZE	CONFIG_COMMAND_LINE_SIZE
+#else
 #define COMMAND_LINE_SIZE	256
+#endif
 
 #endif /* _UAPI__ALPHA_SETUP_H */
diff --git a/arch/arc/include/asm/setup.h b/arch/arc/include/asm/setup.h
index 1c6db599e1fcc..60e158d58cec7 100644
--- a/arch/arc/include/asm/setup.h
+++ b/arch/arc/include/asm/setup.h
@@ -9,7 +9,7 @@
 #include <linux/types.h>
 #include <uapi/asm/setup.h>
 
-#define COMMAND_LINE_SIZE 256
+#define COMMAND_LINE_SIZE CONFIG_COMMAND_LINE_SIZE
 
 /*
  * Data structure to map a ID to string
diff --git a/arch/arm/include/uapi/asm/setup.h b/arch/arm/include/uapi/asm/setup.h
index 8e50e034fec73..4aa93558af1e7 100644
--- a/arch/arm/include/uapi/asm/setup.h
+++ b/arch/arm/include/uapi/asm/setup.h
@@ -17,7 +17,11 @@
 
 #include <linux/types.h>
 
-#define COMMAND_LINE_SIZE 1024
+#ifdef __KERNEL__
+#define COMMAND_LINE_SIZE	CONFIG_COMMAND_LINE_SIZE
+#else
+#define COMMAND_LINE_SIZE	1024
+#endif
 
 /* The list ends with an ATAG_NONE node. */
 #define ATAG_NONE	0x00000000
diff --git a/arch/arm64/include/uapi/asm/setup.h b/arch/arm64/include/uapi/asm/setup.h
index 5d703888f3511..2236890175a5a 100644
--- a/arch/arm64/include/uapi/asm/setup.h
+++ b/arch/arm64/include/uapi/asm/setup.h
@@ -22,6 +22,10 @@
 
 #include <linux/types.h>
 
+#ifdef __KERNEL__
+#define COMMAND_LINE_SIZE	CONFIG_COMMAND_LINE_SIZE
+#else
 #define COMMAND_LINE_SIZE	2048
+#endif
 
 #endif
diff --git a/arch/loongarch/include/uapi/asm/setup.h b/arch/loongarch/include/uapi/asm/setup.h
index d46363ce3e024..03c7bfa1e5d9f 100644
--- a/arch/loongarch/include/uapi/asm/setup.h
+++ b/arch/loongarch/include/uapi/asm/setup.h
@@ -3,6 +3,10 @@
 #ifndef _UAPI_ASM_LOONGARCH_SETUP_H
 #define _UAPI_ASM_LOONGARCH_SETUP_H
 
+#ifdef __KERNEL__
+#define COMMAND_LINE_SIZE	CONFIG_COMMAND_LINE_SIZE
+#else
 #define COMMAND_LINE_SIZE	4096
+#endif
 
 #endif /* _UAPI_ASM_LOONGARCH_SETUP_H */
diff --git a/arch/m68k/include/uapi/asm/setup.h b/arch/m68k/include/uapi/asm/setup.h
index 25fe26d5597cc..2d5b24a5345f9 100644
--- a/arch/m68k/include/uapi/asm/setup.h
+++ b/arch/m68k/include/uapi/asm/setup.h
@@ -12,6 +12,10 @@
 #ifndef _UAPI_M68K_SETUP_H
 #define _UAPI_M68K_SETUP_H
 
-#define COMMAND_LINE_SIZE 256
+#ifdef __KERNEL__
+#define COMMAND_LINE_SIZE	CONFIG_COMMAND_LINE_SIZE
+#else
+#define COMMAND_LINE_SIZE	256
+#endif
 
 #endif /* _UAPI_M68K_SETUP_H */
diff --git a/arch/microblaze/include/uapi/asm/setup.h b/arch/microblaze/include/uapi/asm/setup.h
index 16c56807f86a2..e4b253064c7d9 100644
--- a/arch/microblaze/include/uapi/asm/setup.h
+++ b/arch/microblaze/include/uapi/asm/setup.h
@@ -12,6 +12,10 @@
 #ifndef _UAPI_ASM_MICROBLAZE_SETUP_H
 #define _UAPI_ASM_MICROBLAZE_SETUP_H
 
+#ifdef __KERNEL__
+#define COMMAND_LINE_SIZE	CONFIG_COMMAND_LINE_SIZE
+#else
 #define COMMAND_LINE_SIZE	256
+#endif
 
 #endif /* _UAPI_ASM_MICROBLAZE_SETUP_H */
diff --git a/arch/mips/include/uapi/asm/setup.h b/arch/mips/include/uapi/asm/setup.h
index 7d48c433b0c27..8d6c474835aec 100644
--- a/arch/mips/include/uapi/asm/setup.h
+++ b/arch/mips/include/uapi/asm/setup.h
@@ -2,7 +2,11 @@
 #ifndef _UAPI_MIPS_SETUP_H
 #define _UAPI_MIPS_SETUP_H
 
+#ifdef __KERNEL__
+#define COMMAND_LINE_SIZE	CONFIG_COMMAND_LINE_SIZE
+#else
 #define COMMAND_LINE_SIZE	4096
+#endif
 
 
 #endif /* _UAPI_MIPS_SETUP_H */
diff --git a/arch/parisc/include/uapi/asm/setup.h b/arch/parisc/include/uapi/asm/setup.h
index 78b2f4ec7d652..cfa77e84205dc 100644
--- a/arch/parisc/include/uapi/asm/setup.h
+++ b/arch/parisc/include/uapi/asm/setup.h
@@ -2,6 +2,10 @@
 #ifndef _PARISC_SETUP_H
 #define _PARISC_SETUP_H
 
+#ifdef __KERNEL__
+#define COMMAND_LINE_SIZE	CONFIG_COMMAND_LINE_SIZE
+#else
 #define COMMAND_LINE_SIZE	1024
+#endif
 
 #endif /* _PARISC_SETUP_H */
diff --git a/arch/powerpc/include/uapi/asm/setup.h b/arch/powerpc/include/uapi/asm/setup.h
index c54940b09d065..daa15ac4e94c6 100644
--- a/arch/powerpc/include/uapi/asm/setup.h
+++ b/arch/powerpc/include/uapi/asm/setup.h
@@ -2,6 +2,10 @@
 #ifndef _UAPI_ASM_POWERPC_SETUP_H
 #define _UAPI_ASM_POWERPC_SETUP_H
 
+#ifdef __KERNEL__
+#define COMMAND_LINE_SIZE	CONFIG_COMMAND_LINE_SIZE
+#else
 #define COMMAND_LINE_SIZE	2048
+#endif
 
 #endif /* _UAPI_ASM_POWERPC_SETUP_H */
diff --git a/arch/riscv/include/uapi/asm/setup.h b/arch/riscv/include/uapi/asm/setup.h
index eb4f0209c6960..a6c1f4b0987e3 100644
--- a/arch/riscv/include/uapi/asm/setup.h
+++ b/arch/riscv/include/uapi/asm/setup.h
@@ -3,6 +3,10 @@
 #ifndef _UAPI_ASM_RISCV_SETUP_H
 #define _UAPI_ASM_RISCV_SETUP_H
 
+#ifdef __KERNEL__
+#define COMMAND_LINE_SIZE	CONFIG_COMMAND_LINE_SIZE
+#else
 #define COMMAND_LINE_SIZE	2048
+#endif
 
 #endif /* _UAPI_ASM_RISCV_SETUP_H */
diff --git a/arch/sparc/include/uapi/asm/setup.h b/arch/sparc/include/uapi/asm/setup.h
index 3c208a4dd4640..7054f5249a3a6 100644
--- a/arch/sparc/include/uapi/asm/setup.h
+++ b/arch/sparc/include/uapi/asm/setup.h
@@ -6,10 +6,14 @@
 #ifndef _UAPI_SPARC_SETUP_H
 #define _UAPI_SPARC_SETUP_H
 
-#if defined(__sparc__) && defined(__arch64__)
-# define COMMAND_LINE_SIZE 2048
+#ifdef __KERNEL__
+# define COMMAND_LINE_SIZE CONFIG_COMMAND_LINE_SIZE
 #else
-# define COMMAND_LINE_SIZE 256
+# if defined(__sparc__) && defined(__arch64__)
+#  define COMMAND_LINE_SIZE 2048
+# else
+#  define COMMAND_LINE_SIZE 256
+# endif
 #endif
 
 
diff --git a/arch/um/include/asm/setup.h b/arch/um/include/asm/setup.h
index 80ada899f2542..bc83dc4d467d3 100644
--- a/arch/um/include/asm/setup.h
+++ b/arch/um/include/asm/setup.h
@@ -6,6 +6,6 @@
  * command line, so this choice is ok.
  */
 
-#define COMMAND_LINE_SIZE 4096
+#define COMMAND_LINE_SIZE CONFIG_COMMAND_LINE_SIZE
 
 #endif		/* SETUP_H_INCLUDED */
diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h
index 914eb32581c73..b73caf64f2199 100644
--- a/arch/x86/include/asm/setup.h
+++ b/arch/x86/include/asm/setup.h
@@ -4,7 +4,7 @@
 
 #include <uapi/asm/setup.h>
 
-#define COMMAND_LINE_SIZE 2048
+#define COMMAND_LINE_SIZE CONFIG_COMMAND_LINE_SIZE
 
 #include <linux/linkage.h>
 #include <asm/page_types.h>
diff --git a/arch/xtensa/include/uapi/asm/setup.h b/arch/xtensa/include/uapi/asm/setup.h
index 5356a5fd4d173..dcf33a403527a 100644
--- a/arch/xtensa/include/uapi/asm/setup.h
+++ b/arch/xtensa/include/uapi/asm/setup.h
@@ -12,6 +12,10 @@
 #ifndef _XTENSA_SETUP_H
 #define _XTENSA_SETUP_H
 
+#ifdef __KERNEL__
+#define COMMAND_LINE_SIZE	CONFIG_COMMAND_LINE_SIZE
+#else
 #define COMMAND_LINE_SIZE	256
+#endif
 
 #endif
diff --git a/include/uapi/asm-generic/setup.h b/include/uapi/asm-generic/setup.h
index 88ac5100df359..b8d06e6d56bd7 100644
--- a/include/uapi/asm-generic/setup.h
+++ b/include/uapi/asm-generic/setup.h
@@ -2,6 +2,10 @@
 #ifndef __ASM_GENERIC_SETUP_H
 #define __ASM_GENERIC_SETUP_H
 
+#ifdef __KERNEL__
+#define COMMAND_LINE_SIZE	CONFIG_COMMAND_LINE_SIZE
+#else
 #define COMMAND_LINE_SIZE	512
+#endif
 
 #endif	/* __ASM_GENERIC_SETUP_H */
-- 
2.55.0.654.g21b8a5bc05-goog


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

* [PATCH 3/3] init/Kconfig: make config INIT_ENV_ARG_LIMIT user-configurable
  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:14 ` [PATCH 2/3] arch: use CONFIG_COMMAND_LINE_SIZE across " Wilson Felipe Pereira
@ 2026-08-06  6:14 ` Wilson Felipe Pereira
  2026-08-06  6:29   ` sashiko-bot
  2026-08-06 22:57 ` [PATCH 0/3] init/Kconfig: generalize config COMMAND_LINE_SIZE Andrew Morton
  3 siblings, 1 reply; 9+ 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

INIT_ENV_ARG_LIMIT is defined without a prompt string (`int`), making it
a hidden Kconfig symbol that defaults to 32 (or 128 for UML) and cannot
be configured in `make menuconfig`.

Now that CONFIG_COMMAND_LINE_SIZE is configurable across all architectures,
users who select larger kernel command lines (e.g., 4096 bytes) may pass
more than 32 command-line arguments or environment variables (`foo=bar`) to
`/sbin/init`. If INIT_ENV_ARG_LIMIT remains hardcoded at 32, any argument
after the 32nd is silently dropped when the kernel executes init.

Add a prompt string ("Maximum number of kernel command line arguments") and
a `range 32 4096` to `config INIT_ENV_ARG_LIMIT` so that users can
configure their init argument and environment variable limit when needed,
while preserving the existing default of 32 for standard builds.

Originally-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: Wilson Felipe Pereira <wfelipe@google.com>
---
 init/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/init/Kconfig b/init/Kconfig
index d42bb55cb2152..28c0f1fb00ebb 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -231,9 +231,10 @@ config BROKEN_ON_SMP
 	default y
 
 config INIT_ENV_ARG_LIMIT
-	int
+	int "Maximum number of kernel command line arguments"
 	default 32 if !UML
 	default 128 if UML
+	range 32 4096
 	help
 	  Maximum of each of the number of arguments and environment
 	  variables passed to init from the kernel command line.
-- 
2.55.0.654.g21b8a5bc05-goog


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

* Re: [PATCH 2/3] arch: use CONFIG_COMMAND_LINE_SIZE across all architectures
  2026-08-06  6:14 ` [PATCH 2/3] arch: use CONFIG_COMMAND_LINE_SIZE across " Wilson Felipe Pereira
@ 2026-08-06  6:25   ` sashiko-bot
  0 siblings, 0 replies; 9+ messages in thread
From: sashiko-bot @ 2026-08-06  6:25 UTC (permalink / raw)
  To: Wilson Felipe Pereira
  Cc: Alexander Gordeev, linux-s390, Heiko Carstens, Vasily Gorbik

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] RISC-V default command line size is silently truncated from 2048 to 1024 bytes.
- [High] Exposing COMMAND_LINE_SIZE to Kconfig allows deterministic stack exhaustion in the ARM boot decompressor.
- [High] Configurable COMMAND_LINE_SIZE causes stack exhaustion during early boot on m68k Atari.
--

--- Patch [2]: [PATCH 2/3] arch: use CONFIG_COMMAND_LINE_SIZE across all architectures ---
commit 86e4b8b798d614166a3d212659ea7796c8a7ee99
Author: Wilson Felipe Pereira <wfelipe@google.com>

arch: use CONFIG_COMMAND_LINE_SIZE across all architectures

This commit updates every architecture's setup.h to define COMMAND_LINE_SIZE
using CONFIG_COMMAND_LINE_SIZE for the kernel. The historical hardcoded
defaults are retained in user-space API headers by wrapping the definition
in an #ifdef __KERNEL__ guard.

> diff --git a/arch/arm/include/uapi/asm/setup.h b/arch/arm/include/uapi/asm/setup.h
> index 8e50e034fec73..4aa93558af1e7 100644
> --- a/arch/arm/include/uapi/asm/setup.h
> +++ b/arch/arm/include/uapi/asm/setup.h
> @@ -17,7 +17,11 @@
>  
>  #include <linux/types.h>
>  
> -#define COMMAND_LINE_SIZE 1024
> +#ifdef __KERNEL__
> +#define COMMAND_LINE_SIZE	CONFIG_COMMAND_LINE_SIZE
> +#else
> +#define COMMAND_LINE_SIZE	1024
> +#endif

[Severity: High]
Does exposing COMMAND_LINE_SIZE to Kconfig allow deterministic stack exhaustion
in the ARM boot decompressor?

The ARM boot decompressor uses a fixed 4KB stack (.L_user_stack in
arch/arm/boot/compressed/head.S), and merge_fdt_bootargs() allocates:

arch/arm/boot/compressed/atags_to_fdt.c:merge_fdt_bootargs() {
    ...
	char cmdline[COMMAND_LINE_SIZE];
    ...
}

If a user configures CONFIG_COMMAND_LINE_SIZE to a value larger than ~3KB,
will this stack allocation deterministically crash on boot?

[ ... ]

> diff --git a/arch/m68k/include/uapi/asm/setup.h b/arch/m68k/include/uapi/asm/setup.h
> index 25fe26d5597cc..2d5b24a5345f9 100644
> --- a/arch/m68k/include/uapi/asm/setup.h
> +++ b/arch/m68k/include/uapi/asm/setup.h
> @@ -12,6 +12,10 @@
>  #ifndef _UAPI_M68K_SETUP_H
>  #define _UAPI_M68K_SETUP_H
>  
> -#define COMMAND_LINE_SIZE 256
> +#ifdef __KERNEL__
> +#define COMMAND_LINE_SIZE	CONFIG_COMMAND_LINE_SIZE
> +#else
> +#define COMMAND_LINE_SIZE	256
> +#endif

[Severity: High]
Can a configurable COMMAND_LINE_SIZE cause stack exhaustion during early boot
on m68k Atari?

atari_switches_setup() allocates an array locally on the limited kernel stack:

arch/m68k/atari/config.c:atari_switches_setup() {
    ...
	char switches[COMMAND_LINE_SIZE];
    ...
}

Will tying this to an unbound Kconfig option introduce deterministic stack
exhaustion on boot for m68k Atari kernels?

[ ... ]

> diff --git a/arch/riscv/include/uapi/asm/setup.h b/arch/riscv/include/uapi/asm/setup.h
> index eb4f0209c6960..a6c1f4b0987e3 100644
> --- a/arch/riscv/include/uapi/asm/setup.h
> +++ b/arch/riscv/include/uapi/asm/setup.h
> @@ -3,6 +3,10 @@
>  #ifndef _UAPI_ASM_RISCV_SETUP_H
>  #define _UAPI_ASM_RISCV_SETUP_H
>  
> +#ifdef __KERNEL__
> +#define COMMAND_LINE_SIZE	CONFIG_COMMAND_LINE_SIZE
> +#else
>  #define COMMAND_LINE_SIZE	2048
> +#endif

[Severity: High]
Is the RISC-V default command line size silently truncated from 2048 to 1024
bytes?

The Kconfig default in init/Kconfig erroneously groups RISC-V with ARM and
PARISC (1024):

init/Kconfig:
	default 1024 if ARM || PARISC || RISCV

By replacing the kernel definition with CONFIG_COMMAND_LINE_SIZE here, does
this create a dangerous discrepancy where userspace headers claim the limit
is 2048, while the kernel internally enforces 1024 and truncates existing
boot configurations?

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

^ permalink raw reply	[flat|nested] 9+ 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; 9+ 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] 9+ messages in thread

* Re: [PATCH 3/3] init/Kconfig: make config INIT_ENV_ARG_LIMIT user-configurable
  2026-08-06  6:14 ` [PATCH 3/3] init/Kconfig: make config INIT_ENV_ARG_LIMIT user-configurable Wilson Felipe Pereira
@ 2026-08-06  6:29   ` sashiko-bot
  0 siblings, 0 replies; 9+ messages in thread
From: sashiko-bot @ 2026-08-06  6:29 UTC (permalink / raw)
  To: Wilson Felipe Pereira
  Cc: linux-s390, Heiko Carstens, Alexander Gordeev, Vasily Gorbik

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] init_setup() and rdinit_setup() fail to clear argv_init[MAX_INIT_ARGS], leading to a ghost argument or spurious kernel panic.
--

--- Patch [3]: [PATCH 3/3] init/Kconfig: make config INIT_ENV_ARG_LIMIT user-configurable ---
commit 40d27a1b9f7dbca831686327245c33052b28fb18
Author: Wilson Felipe Pereira <wfelipe@google.com>

init/Kconfig: make config INIT_ENV_ARG_LIMIT user-configurable

This commit makes the INIT_ENV_ARG_LIMIT Kconfig symbol user-configurable
by adding a prompt string and a valid range. This allows users to increase
the maximum number of kernel command-line arguments passed to init beyond
the default.

> diff --git a/init/Kconfig b/init/Kconfig
> index c581817966ee2..a77a2c33c319c 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -228,9 +228,10 @@ config BROKEN_ON_SMP
>  	default y
>  
>  config INIT_ENV_ARG_LIMIT
> -	int
> +	int "Maximum number of kernel command line arguments"
>  	default 32 if !UML
>  	default 128 if UML
> +	range 32 4096

[Severity: High]
This is a pre-existing issue, but could making this limit configurable 
expose a bug in init_setup() and rdinit_setup() where they fail to clear 
the last element of argv_init?

Looking at init_setup() in init/main.c:

init/main.c:init_setup() {
    ...
	for (i = 1; i < MAX_INIT_ARGS; i++)
		argv_init[i] = NULL;
    ...
}

And similarly in rdinit_setup():

init/main.c:rdinit_setup() {
    ...
	for (i = 1; i < MAX_INIT_ARGS; i++)
		argv_init[i] = NULL;
    ...
}

Since argv_init is sized MAX_INIT_ARGS + 2, if the boot command line includes 
exactly MAX_INIT_ARGS unknown arguments before 'init=', they populate 
argv_init[1] through argv_init[MAX_INIT_ARGS]. The loop in init_setup() stops 
at MAX_INIT_ARGS - 1, leaving argv_init[MAX_INIT_ARGS] populated with a stale 
argument.

If the boot command line then provides MAX_INIT_ARGS - 1 arguments after 
'init=', they fill indices 1 to MAX_INIT_ARGS - 1. This makes the uncleared 
argv_init[MAX_INIT_ARGS] contiguous, which could cause kernel_execve to 
pass it to init as a ghost argument. 

Alternatively, if exactly MAX_INIT_ARGS arguments are provided after 'init=',
could the argument checking loop evaluate argv_init[MAX_INIT_ARGS] as true,
set panic_later, and cause a spurious boot panic?

>  	help
>  	  Maximum of each of the number of arguments and environment
>  	  variables passed to init from the kernel command line.

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

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

* Re: [PATCH 0/3] init/Kconfig: generalize config COMMAND_LINE_SIZE
  2026-08-06  6:14 [PATCH 0/3] init/Kconfig: generalize config COMMAND_LINE_SIZE Wilson Felipe Pereira
                   ` (2 preceding siblings ...)
  2026-08-06  6:14 ` [PATCH 3/3] init/Kconfig: make config INIT_ENV_ARG_LIMIT user-configurable Wilson Felipe Pereira
@ 2026-08-06 22:57 ` Andrew Morton
  3 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2026-08-06 22:57 UTC (permalink / raw)
  To: Wilson Felipe Pereira
  Cc: Arnd Bergmann, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger, Sven Schnelle, linux-arch, linux-riscv,
	linux-s390

On Thu,  6 Aug 2026 06:14:13 +0000 Wilson Felipe Pereira <wfelipe@google.com> wrote:

> This patch series promotes COMMAND_LINE_SIZE from arch/s390/Kconfig to
> init/Kconfig to be generally available to other architectures.
> 
> 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.
> 
> Since COMMAND_LINE_SIZE can be larger, it also makes sense to allow
> INIT_ENV_ARG_LIMIT to be configured.

Thanks.

AI review pointed at a few possible issues - I eyeballed a couple and
they appear significant.
	https://sashiko.dev/#/patchset/20260806061429.474992-1-wfelipe@google.com


> Originally-by: Maciej Żenczykowski <maze@google.com>

fyi, it's minor, but Originally-by: isn't actually a thing.  It's
mentioned in the -tip documentation, nothing else endorses it.

I have no issue with it but formally these patches should also have
Maciej's Signed-off-by: 


Please let's target 7.3-rc1 for these changes - I'm deep into
stem-the-flood mode for this -rc cycle.


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

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

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-08-06  6:14 ` [PATCH 2/3] arch: use CONFIG_COMMAND_LINE_SIZE across " Wilson Felipe Pereira
2026-08-06  6:25   ` sashiko-bot
2026-08-06  6:14 ` [PATCH 3/3] init/Kconfig: make config INIT_ENV_ARG_LIMIT user-configurable Wilson Felipe Pereira
2026-08-06  6:29   ` sashiko-bot
2026-08-06 22:57 ` [PATCH 0/3] init/Kconfig: generalize config COMMAND_LINE_SIZE Andrew Morton
     [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

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