Re: [PATCH] riscv: pi: validate early bootargs before string use
From: Paul Walmsley
Date: Tue Nov 24 2026 - 22:43:28 EST
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@xxxxxxxxxxx>
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