[PATCH] riscv: pi: validate early bootargs before string use

Paul Walmsley pjw at kernel.org
Tue Nov 24 19:43:21 PST 2026


On Fri, 3 Apr 2026, Pengpeng Hou wrote:

> get_early_cmdline() fetches bootargs directly from the FDT and
> immediately passes the raw property pointer to strlen() before copying
> it into the early command-line buffer. Flat DT properties are external
> boot input, and this path does not prove that bootargs is
> NUL-terminated within its declared bounds.
> 
> Use fdt_stringlist_get() so malformed unterminated bootargs are
> rejected before any C-string helpers walk them.
> 
> Signed-off-by: Pengpeng Hou <pengpeng at iscas.ac.cn>

Sashiko points out that this could cause a regression in the 
CONFIG_CMDLINE_FALLBACK-related code, later in get_early_cmdline().  The 
CONFIG_CMDLINE_FALLBACK-related code only tests for fdt_cmdline_size == 0, 
but fdt_stringlist_get() could pass back a negative error code in 
fdt_cmdline_size under some error conditions.  

Care to fix that and resubmit?

thanks,


- Paul



More information about the linux-riscv mailing list