Re: [PATCH v2 1/2] drivers/of: validate live-tree string properties before string use

From: Rob Herring

Date: Tue May 05 2026 - 14:05:58 EST


On Fri, Apr 17, 2026 at 08:36:00PM +0800, Pengpeng Hou wrote:
> `populate_properties()` stores live-tree property values as raw byte
> sequences plus a separate `length`. They are not globally guaranteed to
> be NUL-terminated.
>
> `of_prop_next_string()` iterates string-list properties by walking raw
> bytes, `__of_node_is_type()` checks `device_type`,
> `__of_device_is_status()` checks `status`, and
> `of_alias_from_compatible()` reads the first `compatible` entry. These
> paths must validate that the relevant string fits within the property
> bounds before they hand it to C string helpers.
>
> Validate these live-tree string properties within their declared bounds.
> In particular, make `of_prop_next_string()` reject malformed entries
> before returning them, use `of_property_match_string()` for
> `device_type`, and add unit coverage for malformed first and trailing
> string-list entries.
>
> Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
> ---
> Changes since v1:
> - use of_property_match_string() for device_type as suggested by
> Rob Herring
> - rework of_prop_next_string() so the first returned string is validated
> through the same bounded path
> - add of_unittest_property_string() coverage for malformed first and
> trailing string-list entries

Did you even test this? The virt machine under QEMU doesn't even boot.

[ 0.000000] OF: reserved mem: Reserved memory: No reserved-memory node in the DT

It hangs here.

[ 0.000000] NUMA: Faking a node at [mem 0x0000000040000000-0x000000007fffffff]