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 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 71C0DC07E96 for ; Thu, 15 Jul 2021 08:36:37 +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 E368D6128D for ; Thu, 15 Jul 2021 08:36:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E368D6128D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DDA3A82903; Thu, 15 Jul 2021 10:36:34 +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=1626338195; bh=bh7iG3tv4R3HceUE31AouABcgr603gAX40PCIIujQjA=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=sTXiSP1ed1GZbQFvt869Bd5t1H7zoL7T88I66VbmDKgVHi6CMILUOBB+fXMBW5ccl TfiM/25zdFljhAwEXcLeW3M0eBG5sd3Gp4eN4it+a9RVq97rRrahtwqOoVHe98LZU7 Ohg2zg4DAKM52E+/9wbfbZXexO3E88q3IJSC+6eludj9uPqC2zkAoS55bUfP6lbuc5 5051pHY7JOGt20PHNYoBKmvt+O2qRl/EYQdW2fwPvq+c6/M8dcxC7HUF6w8waRYF0b 7ECyszP/PEdrla47L3+RxYoDTT6CAcvinmWDa+7p8BV7Y5Rkpzvy+2MEfp+d+oAzhJ RASqEkENpO/Qg== Received: by phobos.denx.de (Postfix, from userid 109) id 57D4882959; Thu, 15 Jul 2021 10:36:33 +0200 (CEST) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [91.198.250.253]) (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 2C18580EF8 for ; Thu, 15 Jul 2021 10:36:30 +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 [IPv6:2001:67c:2050:105:465:1:1:0]) (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-204.mailbox.org (Postfix) with ESMTPS id 4GQSQQ0f8YzQjrd; Thu, 15 Jul 2021 10:36:30 +0200 (CEST) Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id Q_gk-apDPCfU; Thu, 15 Jul 2021 10:36:27 +0200 (CEST) Subject: Re: [PATCH u-boot-mvebu 07/31] tools: kwbimage: Fix check for v0 extended header checksum To: =?UTF-8?Q?Marek_Beh=c3=ban?= , u-boot@lists.denx.de, Chris Packham , Baruch Siach , Dirk Eibach , Chris Packham Cc: Dennis Gilmore , Mario Six , Jon Nettleton , =?UTF-8?Q?Pali_Roh=c3=a1r?= References: <20210708173032.27999-1-marek.behun@nic.cz> <20210708173032.27999-8-marek.behun@nic.cz> From: Stefan Roese Message-ID: Date: Thu, 15 Jul 2021 10:36:25 +0200 MIME-Version: 1.0 In-Reply-To: <20210708173032.27999-8-marek.behun@nic.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 8bit X-MBO-SPAM-Probability: X-Rspamd-Score: -5.06 / 15.00 / 15.00 X-Rspamd-Queue-Id: 317E01898 X-Rspamd-UID: 21c909 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 08.07.21 19:30, Marek Behún wrote: > From: Pali Rohár > > Extended header checksum for v0 image is present only in the case when > extended header is present. Skip checksum validation if extended header > is not present. > > Signed-off-by: Pali Rohár > Reviewed-by: Marek Behún Reviewed-by: Stefan Roese Thanks, Stefan > --- > tools/kwbimage.c | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > > diff --git a/tools/kwbimage.c b/tools/kwbimage.c > index c08fb678d4..5192edb330 100644 > --- a/tools/kwbimage.c > +++ b/tools/kwbimage.c > @@ -1653,15 +1653,19 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size, > > /* Only version 0 extended header has checksum */ > if (image_version((void *)ptr) == 0) { > - struct ext_hdr_v0 *ext_hdr; > + struct main_hdr_v0 *mhdr = (struct main_hdr_v0 *)ptr; > > - ext_hdr = (struct ext_hdr_v0 *) > + if (mhdr->ext & 0x1) { > + struct ext_hdr_v0 *ext_hdr; > + > + ext_hdr = (struct ext_hdr_v0 *) > (ptr + sizeof(struct main_hdr_v0)); > - checksum = image_checksum8(ext_hdr, > - sizeof(struct ext_hdr_v0) > - - sizeof(uint8_t)); > - if (checksum != ext_hdr->checksum) > - return -FDT_ERR_BADSTRUCTURE; > + checksum = image_checksum8(ext_hdr, > + sizeof(struct ext_hdr_v0) > + - sizeof(uint8_t)); > + if (checksum != ext_hdr->checksum) > + return -FDT_ERR_BADSTRUCTURE; > + } > } > > return 0; > 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