anolis-cloud-kernel/drivers/of
Christian A. Ehrhardt 0081128589 of: Fix double free in of_parse_phandle_with_args_map
ANBZ: #12944

commit 4dde835698 upstream.

In of_parse_phandle_with_args_map() the inner loop that
iterates through the map entries calls of_node_put(new)
to free the reference acquired by the previous iteration
of the inner loop. This assumes that the value of "new" is
NULL on the first iteration of the inner loop.

Make sure that this is true in all iterations of the outer
loop by setting "new" to NULL after its value is assigned to "cur".

Extend the unittest to detect the double free and add an additional
test case that actually triggers this path.

Fixes: bd6f2fd5a1 ("of: Support parsing phandle argument lists through a nexus node")
Cc: Stephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: "Christian A. Ehrhardt" <lk@c--e.de>
Link: https://lore.kernel.org/r/20231229105411.1603434-1-lk@c--e.de
Signed-off-by: Rob Herring <robh@kernel.org>
Fixes: CVE-2023-52679
Signed-off-by: Guanghui Feng <guanghuifeng@linux.alibaba.com>
Reviewed-by: Guixin Liu <kanie@linux.alibaba.com>
Link: https://gitee.com/anolis/cloud-kernel/pulls/4971
2025-03-31 02:08:26 +00:00
..
unittest-data of: Fix double free in of_parse_phandle_with_args_map 2025-03-31 02:08:26 +00:00
Kconfig
Makefile
address.c
base.c of: Fix double free in of_parse_phandle_with_args_map 2025-03-31 02:08:26 +00:00
device.c
dynamic.c
fdt.c of/fdt: Don't calculate initrd size from DT if start > end 2023-02-21 09:07:07 +00:00
fdt_address.c
irq.c of/irq: Prevent device address out-of-bounds read in interrupt map walk 2024-12-09 06:12:50 +00:00
kobj.c of: Don't allow __of_attached_node_sysfs() without CONFIG_SYSFS 2021-09-18 13:40:31 +02:00
of_net.c
of_numa.c
of_private.h
of_reserved_mem.c memblock: make memblock_find_in_range method private 2024-07-10 01:38:34 +00:00
overlay.c of: overlay: do not break notify on NOTIFY_{OK|STOP} 2022-06-09 10:21:03 +02:00
pdt.c
platform.c
property.c
resolver.c
unittest.c of: Fix double free in of_parse_phandle_with_args_map 2025-03-31 02:08:26 +00:00