Re: [PATCH 2/3] arch: use CONFIG_COMMAND_LINE_SIZE across all architectures

[email protected]
Newsgroups org.kernel.vger.linux-s390
Message-ID <[email protected]>
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 <[email protected]>

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/[email protected]?part=2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.