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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 176B4C433FE for ; Thu, 29 Sep 2022 22:31:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AA26384AC8; Fri, 30 Sep 2022 00:31:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=spocom.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id C09EF84A99; Thu, 29 Sep 2022 22:00:34 +0200 (CEST) Received: from mail.spocom.com (mail.spocom.com [206.63.224.240]) by phobos.denx.de (Postfix) with ESMTP id 1BBEC84956 for ; Thu, 29 Sep 2022 22:00:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=spocom.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=garyjohn@spocom.com Received: from localhost (174-31-97-138.spkn.qwest.net [174.31.97.138]) by mail.spocom.com with SMTP; Thu, 29 Sep 2022 13:00:10 -0700 Date: Thu, 29 Sep 2022 13:01:45 -0700 From: Gary Johnson To: u-boot@lists.denx.de Subject: Bug in ext2load? Message-ID: <20220929200145.GB7620@phoenix> Mail-Followup-To: u-boot@lists.denx.de MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: Linux 2.6.32-74-generic GNU/Linux User-Agent: Mutt/1.5.20 (2009-06-14) X-Exim-Id: 20220929200145.GB7620 X-Mailman-Approved-At: Fri, 30 Sep 2022 00:31:33 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean I think I've found a bug in the ext2load command. When the file being read is a sparse file, the command fails as in this example. => ext2load usb 0:1 $load_addr firmware_ls2088ardb_norboot.img fs_devread read outside partition 60063712 Failed to load 'firmware_ls2088ardb_norboot.img' However, if the same image file is copied to the USB flash drive on the build machine so that it is not sparse, that is, with "cp --sparse=never ...", then the ext2load command on the target machine succeeds. I think the problem may be in the ext4fs_read_file() command in fs/ext4/ext4fs.c. That is the only function I see in the path from the ext2load command to the error message that does anything explicitly with blocks. Also, this comment at the top of that function suggests that someone tried to optimize the reading of the file and may have missed some sparse-file condition. /* * Taken from openmoko-kernel mailing list: By Andy green * Optimized read file API : collects and defers contiguous sector * reads into one potentially more efficient larger sequential read action */ However, I did not try to debug the problem further, as using "cp --sparse=never" is an adequate workaround and I have more pressing work to do. It appears that the ext2load command runs off the end of the list of blocks in the inode and tries to read beyond the end of the partition. => usb storage Device 0: Vendor: USB Rev: 1.00 Prod: SanDisk 3.2Gen1 Type: Removable Hard Disk Capacity: 29328.0 MB = 28.6 GB (60063744 x 512) Note that the drive capacity is 32 sectors less than the sector reported in the error message. According to the part list command, the partition starts at sector 32, and the number of sectors available matches the number reported in the error message, so this adds up. => part list usb 0 Partition Map for USB device 0 -- Partition Type: DOS Part Start Sector Num Sectors UUID Type 1 32 60063712 eca4cd09-01 83 This error happens with two versions of U-Boot: U-Boot 2016.092.0+ga06b209 (Mar 30 2017 - 01:15:01 +0800) U-Boot 2021.04-ge2eba0cd58 (Aug 27 2021 - 22:23:21 +0800) The last change to fs/ext4/ext4fs.c appears to have been made at commit e6f6f9e648 (2020-05-10). Let me know if you need any addtional information or if I missed something and am wrong about all this. Regards, Gary