All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: "Pali Rohár" <pali@kernel.org>
Cc: u-boot@lists.denx.de, "Marek Behún" <marek.behun@nic.cz>
Subject: Re: [PATCH 3/4] tools: kwbimage: Verify size of image data
Date: Wed, 1 Sep 2021 11:08:34 +0200	[thread overview]
Message-ID: <8f078f58-71ce-5c2f-f9e6-5f60b041ebb9@denx.de> (raw)
In-Reply-To: <20210811081417.18010-3-pali@kernel.org>

On 11.08.21 10:14, Pali Rohár wrote:
> Part of image data is 4 byte checksum, so every image must contain at least
> 4 bytes. Verify it to prevent memory corruptions.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Applied to u-boot-marvell/master

Thanks,
Stefan

> ---
>   tools/kwbimage.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/kwbimage.c b/tools/kwbimage.c
> index 84c41210e39e..5ac34ac5e9c8 100644
> --- a/tools/kwbimage.c
> +++ b/tools/kwbimage.c
> @@ -1757,7 +1757,7 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size,
>   			return -FDT_ERR_BADSTRUCTURE;
>   
>   		size = le32_to_cpu(mhdr->blocksize);
> -		if (offset + size > image_size || size % 4 != 0)
> +		if (size < 4 || offset + size > image_size || size % 4 != 0)
>   			return -FDT_ERR_BADSTRUCTURE;
>   
>   		if (image_checksum32(ptr + offset, size - 4) !=
> 


Viele Grüße,
Stefan

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

  parent reply	other threads:[~2021-09-01  9:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11  8:14 [PATCH 1/4] tools: kwbimage: Verify supported image version Pali Rohár
2021-08-11  8:14 ` [PATCH 2/4] tools: kwbimage: Verify size of v0 image header Pali Rohár
2021-08-11 14:18   ` Stefan Roese
2021-09-01  9:08   ` Stefan Roese
2021-08-11  8:14 ` [PATCH 3/4] tools: kwbimage: Verify size of image data Pali Rohár
2021-08-11 14:19   ` Stefan Roese
2021-09-01  9:08   ` Stefan Roese [this message]
2021-08-11  8:14 ` [PATCH 4/4] tools: kwbimage: Use IBR_HDR_* constants instead of raw numbers Pali Rohár
2021-08-11 14:19   ` Stefan Roese
2021-09-01  9:08   ` Stefan Roese
2021-08-11 14:18 ` [PATCH 1/4] tools: kwbimage: Verify supported image version Stefan Roese
2021-09-01  9:07 ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8f078f58-71ce-5c2f-f9e6-5f60b041ebb9@denx.de \
    --to=sr@denx.de \
    --cc=marek.behun@nic.cz \
    --cc=pali@kernel.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.