Re: [PATCH v2] drivers/of: fdt: validate flat DT string properties before string use
From: Rob Herring (Arm)
Date: Mon Apr 13 2026 - 13:26:28 EST
On Fri, 03 Apr 2026 13:59:47 +0800, Pengpeng Hou wrote:
> Firmware-supplied flat DT properties are raw byte sequences. Several
> early FDT helpers fetch properties such as status, model, compatible,
> and device_type and then use them as C strings with strcmp(), strlen(),
> or pr_info() without first proving that the property is NUL-terminated
> within its declared length.
>
> Use fdt_stringlist_get() for these string properties instead. That
> preserves the existing behavior for valid DTBs while rejecting malformed
> unterminated properties before they are passed to C string helpers.
>
> Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
> ---
> Changes since v1:
> - also validate raw compatible string-list walks in `of_fdt_is_compatible()`
>
> drivers/of/fdt.c | 38 ++++++++++++++------------------------
> 1 file changed, 14 insertions(+), 24 deletions(-)
>
Applied, thanks!