]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
drivers/of: fdt: validate flat DT string properties before string use
authorPengpeng Hou <pengpeng@iscas.ac.cn>
Fri, 3 Apr 2026 05:59:47 +0000 (13:59 +0800)
committerRob Herring (Arm) <robh@kernel.org>
Mon, 13 Apr 2026 20:01:26 +0000 (15:01 -0500)
commitb74f2f7fb2bb8c651e322919342aeddf747d69f7
tree0335504daa8608e1af292647137bfeb12432df5a
parentbb04fcc89a889ad7d5e3427cd1afddd924ef691c
drivers/of: fdt: validate flat DT string properties before string use

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@iscas.ac.cn>
Link: https://patch.msgid.link/20260403164501.1-drivers-of-fdt-v2-pengpeng@iscas.ac.cn
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
drivers/of/fdt.c