* [PATCH] arm64: idreg-override: Use property length in get_bootargs_cmdline()
@ 2026-10-15 19:28 Thorsten Blum
2026-10-27 14:39 ` Catalin Marinas
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-10-15 19:28 UTC (permalink / raw)
To: Catalin Marinas, Will Deacon, Mark Rutland, Oliver Upton,
Robin Murphy, Yureka Lilian, Marc Zyngier
Cc: Thorsten Blum, linux-arm-kernel, linux-kernel
fdt_getprop() already provides the length of the bootargs property. Use
it to reject a zero-length property before dereferencing it, and test
the first byte directly instead of calling strlen().
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
arch/arm64/kernel/pi/idreg-override.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/kernel/pi/idreg-override.c b/arch/arm64/kernel/pi/idreg-override.c
index acaf56234973..588c8af2a567 100644
--- a/arch/arm64/kernel/pi/idreg-override.c
+++ b/arch/arm64/kernel/pi/idreg-override.c
@@ -383,15 +383,17 @@ static __init const u8 *get_bootargs_cmdline(const void *fdt, int node)
{
static char const bootargs[] __initconst = "bootargs";
const u8 *prop;
+ int len;
if (node < 0)
return NULL;
- prop = fdt_getprop(fdt, node, bootargs, NULL);
- if (!prop)
+ prop = fdt_getprop(fdt, node, bootargs, &len);
+ /* No bootargs for a missing, zero-length, or empty-string property. */
+ if (!prop || !len || !*prop)
return NULL;
- return strlen(prop) ? prop : NULL;
+ return prop;
}
static __init void parse_cmdline(const void *fdt, int chosen)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] arm64: idreg-override: Use property length in get_bootargs_cmdline()
2026-10-15 19:28 [PATCH] arm64: idreg-override: Use property length in get_bootargs_cmdline() Thorsten Blum
@ 2026-10-27 14:39 ` Catalin Marinas
0 siblings, 0 replies; 2+ messages in thread
From: Catalin Marinas @ 2026-10-27 14:39 UTC (permalink / raw)
To: Thorsten Blum
Cc: Will Deacon, Mark Rutland, Oliver Upton, Robin Murphy,
Yureka Lilian, Marc Zyngier, linux-arm-kernel, linux-kernel
On Thu, Oct 15, 2026 at 09:28:08PM +0200, Thorsten Blum wrote:
> fdt_getprop() already provides the length of the bootargs property. Use
> it to reject a zero-length property before dereferencing it, and test
> the first byte directly instead of calling strlen().
>
> Signed-off-by: Thorsten Blum <blum@kernel.org>
> ---
> arch/arm64/kernel/pi/idreg-override.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm64/kernel/pi/idreg-override.c b/arch/arm64/kernel/pi/idreg-override.c
> index acaf56234973..588c8af2a567 100644
> --- a/arch/arm64/kernel/pi/idreg-override.c
> +++ b/arch/arm64/kernel/pi/idreg-override.c
> @@ -383,15 +383,17 @@ static __init const u8 *get_bootargs_cmdline(const void *fdt, int node)
> {
> static char const bootargs[] __initconst = "bootargs";
> const u8 *prop;
> + int len;
>
> if (node < 0)
> return NULL;
>
> - prop = fdt_getprop(fdt, node, bootargs, NULL);
> - if (!prop)
> + prop = fdt_getprop(fdt, node, bootargs, &len);
> + /* No bootargs for a missing, zero-length, or empty-string property. */
> + if (!prop || !len || !*prop)
> return NULL;
>
> - return strlen(prop) ? prop : NULL;
> + return prop;
I think the patch makes sense. In theory we may have a value-less
bootargs property and prop points to the next token (or some
FDT_END_NODE) but they would all have 0 as the first byte, so the
strlen() check would catch it. Anyway, the above is clearer, so:
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-27 14:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-15 19:28 [PATCH] arm64: idreg-override: Use property length in get_bootargs_cmdline() Thorsten Blum
2026-10-27 14:39 ` Catalin Marinas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®