From patchwork Wed Jun 8 07:51:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 1640390 X-Patchwork-Delegate: david.oberhollenzer@sigma-star.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=IAiIxbvJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LHzw56BqTz9sFk for ; Wed, 8 Jun 2022 17:52:21 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=EUjKaD3geoqaMjk8ajyWG9apS5LmDEVYTNolSKNv6Io=; b=IAiIxbvJm1k6Lw V3sJkHjofClkH6wtptVtsvsOdU2njFuMsnNBtePi+wVBpmUKi5l+EKi6cq3cTPcb3yMNpTdQft3nU dZlXnpkyPKpCzHwM0R1XWLbc5oQBli7tRSDEkYP5kkqQXJ1JwwDjRU+0XFtIbvE9SIn5otHkXKaja rPrdhtE79iBLMVLtaIzovF3FgFa8RfX0qB3kAKuoQw7SQb+TAk3Ff3pjmGyzCqMkzBQCJqVb1C+w8 /rk+re9ZqEscXpxkUTUBoS2946qYAGLQ9ck/O+WgrJRF7g2mB9qGKEQvCWI9QQdL8Ij5T6Hzl7QHe 9+yVKfpqY0VYpZ3cZeYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyqTb-00BlPi-9f; Wed, 08 Jun 2022 07:51:39 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nyqTX-00BlNL-Tg for linux-mtd@lists.infradead.org; Wed, 08 Jun 2022 07:51:37 +0000 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nyqTW-0004zO-K6; Wed, 08 Jun 2022 09:51:34 +0200 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1nyqTX-0078xZ-3F; Wed, 08 Jun 2022 09:51:33 +0200 Received: from sha by dude02.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1nyqTU-008IRE-RK; Wed, 08 Jun 2022 09:51:32 +0200 From: Sascha Hauer To: linux-mtd@lists.infradead.org Cc: Richard Weinberger , David Oberhollenzer , Sascha Hauer Subject: [PATCH] mtd-utils: nanddump: fix writing big images on 32bit machines Date: Wed, 8 Jun 2022 09:51:14 +0200 Message-Id: <20220608075114.1977454-1-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mtd@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220608_005135_996464_E8F9707B X-CRM114-Status: GOOD ( 13.68 ) X-Spam-Score: -2.3 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When writing a full 4GiB NAND to a file end_addr becomes 0x100000000. With that writing out the first page to the file doesn't happen because size_left is calculated to 0x100000000 - 0 = 0x100000000 w [...] Content analysis details: (-2.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [2001:67c:670:201:290:27ff:fe1d:cc33 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When writing a full 4GiB NAND to a file end_addr becomes 0x100000000. With that writing out the first page to the file doesn't happen because size_left is calculated to 0x100000000 - 0 = 0x100000000 which is then truncated to 32bit and becomes zero. Fix this by using an appropriate 64bit type for size_left. Signed-off-by: Sascha Hauer --- nand-utils/nanddump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nand-utils/nanddump.c b/nand-utils/nanddump.c index d7fc320..47539f5 100644 --- a/nand-utils/nanddump.c +++ b/nand-utils/nanddump.c @@ -499,7 +499,7 @@ int main(int argc, char * const argv[]) } } else { /* Write requested length if oob is omitted */ - size_t size_left = end_addr - ofs; + long long size_left = end_addr - ofs; if (omitoob && (size_left < bs)) err = ofd_write(ofd, readbuf, size_left); else