From: Heinrich Schuchardt Date: Wed, 13 Jan 2021 01:09:12 +0000 (+0100) Subject: image-fit: fit_check_format check for valid FDT X-Git-Tag: v2021.10~371^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ea1a9ec5f430359720d9a0621ed1acfbba6a142a;p=platform%2Fkernel%2Fu-boot.git image-fit: fit_check_format check for valid FDT fit_check_format() must check that the buffer contains a flattened device tree before calling any device tree library functions. Failure to do may cause segmentation faults. Signed-off-by: Heinrich Schuchardt --- diff --git a/common/image-fit.c b/common/image-fit.c index 6a8787c..21c44bd 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -1553,6 +1553,12 @@ int fit_image_check_comp(const void *fit, int noffset, uint8_t comp) */ int fit_check_format(const void *fit) { + /* A FIT image must be a valid FDT */ + if (fdt_check_header(fit)) { + debug("Wrong FIT format: not a flattened device tree\n"); + return 0; + } + /* mandatory / node 'description' property */ if (fdt_getprop(fit, 0, FIT_DESC_PROP, NULL) == NULL) { debug("Wrong FIT format: no description\n");