diff options
| author | Wilson Felipe Pereira <wfelipe@google.com> | 2026-08-18 23:16:32 +0000 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-09-13 21:33:29 -0700 |
| commit | f451617518f83523e04afc2442c4df5087a7087e (patch) | |
| tree | 68a3c156629461f3a01da1c0d976469c360f01e1 /include/uapi | |
| parent | f1755c618de78e46141f8d8d0f81b5e574c7e856 (diff) | |
| download | linux-next-f451617518f83523e04afc2442c4df5087a7087e.tar.gz linux-next-f451617518f83523e04afc2442c4df5087a7087e.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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
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>
Diffstat (limited to 'include/uapi')
| -rw-r--r-- | include/uapi/asm-generic/setup.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/uapi/asm-generic/setup.h b/include/uapi/asm-generic/setup.h index 88ac5100df35..b8d06e6d56bd 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 */ |
