From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7339C432BE for ; Wed, 1 Sep 2021 09:08:48 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3A4A060F11 for ; Wed, 1 Sep 2021 09:08:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3A4A060F11 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 51B418327F; Wed, 1 Sep 2021 11:08:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1630487326; bh=R7azvr7DrEH6IwPhv23JgEKiR/3+mEMMUvSN6KUPNZM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=JgSErXvRsYbHmptkYAjBmmj+bm5/ob3iUeuIyYhECJ/80tVK5mQca+te83NI/V3Ax qniWJTOU983GrBilFZX5bH3572SBvzrKtpkzWNhGqGisRQgNfP1iHXQh7T2CEpN49O fXbYwaJ9LYYWZ/nAOlqR5W636XuQSXfP7omTSERd67Od/cRrTdHJSLmxy/tPnHBHQX rhVtnI31XIJA/Hgy2qkw8ngwUUDeIHcJT3/Md5qMK/Y1px3qjc9dGI49sOrfUAHqiv 8LIArC0gNvrvSln1ALpz8NyZhSbCNFfiFhcxB8EhvFc38ewWPYWu+hnM1oZMVvBT7X 7rEUw3ojaZwdw== Received: by phobos.denx.de (Postfix, from userid 109) id 179F083231; Wed, 1 Sep 2021 11:08:44 +0200 (CEST) Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [IPv6:2001:67c:2050:1::465:107]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3C03B83363 for ; Wed, 1 Sep 2021 11:08:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4GzysK3YqnzQkW7; Wed, 1 Sep 2021 11:08:37 +0200 (CEST) Subject: Re: [PATCH 3/4] tools: kwbimage: Verify size of image data To: =?UTF-8?Q?Pali_Roh=c3=a1r?= Cc: u-boot@lists.denx.de, =?UTF-8?Q?Marek_Beh=c3=ban?= References: <20210811081417.18010-1-pali@kernel.org> <20210811081417.18010-3-pali@kernel.org> From: Stefan Roese Message-ID: <8f078f58-71ce-5c2f-f9e6-5f60b041ebb9@denx.de> Date: Wed, 1 Sep 2021 11:08:34 +0200 MIME-Version: 1.0 In-Reply-To: <20210811081417.18010-3-pali@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B8AC2189C X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean 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 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