All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] image-fit: fit_check_format check for valid FDT
@ 2021-01-13  1:36 Heinrich Schuchardt
  2021-01-14 15:42 ` Simon Glass
  0 siblings, 1 reply; 2+ messages in thread
From: Heinrich Schuchardt @ 2021-01-13  1:36 UTC (permalink / raw)
  To: u-boot

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 <xypron.glpk@gmx.de>
---
 common/image-fit.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/common/image-fit.c b/common/image-fit.c
index 6a8787ca0a..21c44bdf69 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");
--
2.29.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 1/1] image-fit: fit_check_format check for valid FDT
  2021-01-13  1:36 [PATCH 1/1] image-fit: fit_check_format check for valid FDT Heinrich Schuchardt
@ 2021-01-14 15:42 ` Simon Glass
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Glass @ 2021-01-14 15:42 UTC (permalink / raw)
  To: u-boot

On Tue, 12 Jan 2021 at 18:36, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> 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 <xypron.glpk@gmx.de>
> ---
>  common/image-fit.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-14 15:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-13  1:36 [PATCH 1/1] image-fit: fit_check_format check for valid FDT Heinrich Schuchardt
2021-01-14 15:42 ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.