bootcmdline_scan_chosen() fetches the raw flat-DT bootargs property and
passes it straight to bootcmdline_append(). That helper later feeds the
same pointer into strlcat(), which computes strlen(src) before copying.
Flat DT properties are external boot input, and this path does not
prove that bootargs is NUL-terminated within its declared bounds.
Reject unterminated bootargs properties before appending them to the
kernel command line.
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
#include <linux/of_fdt.h>
#include <linux/dmi.h>
#include <linux/crash_dump.h>
+#include <linux/string.h>
#include <asm/addrspace.h>
#include <asm/bootinfo.h>
p = of_get_flat_dt_prop(node, "bootargs", &l);
if (p != NULL && l > 0) {
+ if (strnlen(p, l) >= l)
+ return 1;
+
bootcmdline_append(p, min(l, COMMAND_LINE_SIZE));
*dt_bootargs = true;
}