summaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
authorWilson Felipe Pereira <wfelipe@google.com>2026-08-18 23:16:32 +0000
committerAndrew Morton <akpm@linux-foundation.org>2026-09-05 20:23:22 -0700
commit478faa85cc6c16e8c5914b798d241836fd0bbdac (patch)
tree90c92781661cab78a96ac82d1cfc19d90bd391c6 /init
parent768190cc0e7ce0dc452399de21632363e82ce031 (diff)
downloadlinux-next-478faa85cc6c16e8c5914b798d241836fd0bbdac.tar.gz
linux-next-478faa85cc6c16e8c5914b798d241836fd0bbdac.zip
init, arch: make CONFIG_COMMAND_LINE_SIZE globally configurable
Currently, 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.h headers. In some use cases, such as netboot kernels, rootfs configurations, or larger initramfs setups, a larger command line size is required. 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, and 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 the same value as before for user-space applications including `<asm/setup.h>`. For S390, the range is kept the same, but other architectures have varying constraints. S390 requires a minimum of 896 bytes to protect legacy bootloaders from overwriting the .text section. ARM, M68K, and NIOS2 allocate the command line directly on severely constrained decompressor stacks, so their ranges are strictly capped at 2048 bytes to prevent deterministic stack exhaustion and boot panics. PowerPC (PPC) boot wrappers silently truncate arguments past 2048 bytes, so it is also capped at 2048 to prevent silent parameter loss. The SuperH (SUPERH) boot parameter page allocates exactly PAGE_SIZE (typically 4096 bytes), and placing a 4096-byte command line starting at offset 256 would cause strscpy() to read out of bounds; it is capped at 3840 bytes. Alpha physically limits its boot parameter block to 256 bytes, so its limit is strictly locked to 256. All other architectures are capped at 4096 bytes to prevent unreasonable allocations. Link: https://lore.kernel.org/20260818231646.804507-2-wfelipe@google.com Signed-off-by: Maciej Żenczykowski <maze@google.com> Signed-off-by: Wilson Felipe Pereira <wfelipe@google.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Alexandre Ghiti <alex@ghiti.fr> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'init')
-rw-r--r--init/Kconfig16
1 files changed, 16 insertions, 0 deletions
diff --git a/init/Kconfig b/init/Kconfig
index 8583d9f06c52..edc79893e1ac 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1614,6 +1614,22 @@ config CMDLINE_FROM_BOOTCONFIG
If unsure, say N.
+config COMMAND_LINE_SIZE
+ int "Maximum size of kernel command line"
+ default 4096 if S390 || LOONGARCH || MIPS || UML
+ default 2048 if X86 || ARM64 || PPC || SPARC64 || RISCV
+ default 1024 if ARM || PARISC
+ default 256 if ALPHA || ARC || M68K || MICROBLAZE || SPARC32 || XTENSA
+ default 512
+ range 896 1048576 if S390
+ range 256 2048 if ARM || M68K || NIOS2 || PPC
+ range 256 3840 if SUPERH
+ range 256 256 if ALPHA
+ range 256 4096
+ 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