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 15935C433FE for ; Sat, 1 Oct 2022 21:17:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EBDAC84A59; Sat, 1 Oct 2022 23:17:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="dScXXKXg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F3B26848DC; Sat, 1 Oct 2022 23:17:13 +0200 (CEST) Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (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 1C96C848DC for ; Sat, 1 Oct 2022 23:17:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1664659028; bh=N26tNvrL68gQQwEI9jMz4rXvJH0kcfz4TZewAI8Dcwo=; h=X-UI-Sender-Class:Date:Subject:To:References:Cc:From:In-Reply-To; b=dScXXKXgkuyyYjOC8MI0bY4Gn4c4V4wnKR5SokbX4HmOR8lqkqrlGy9a5vlDvVLQD odJOiHjUveoTPdK0KpFbDqKX7d21/6u7a7BZq++ffMM9KQs0dXc7fqtPuIlyRGWHPJ OGAebP1jj5V+wtbEYWNHvO52ffP+hdgmr28uSEZE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.94] ([84.118.157.2]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1M2O6Y-1oeApO1aIg-003uZ5; Sat, 01 Oct 2022 23:17:08 +0200 Message-ID: <978073d0-94da-8a67-231c-46b09f65a5b8@gmx.de> Date: Sat, 1 Oct 2022 23:17:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: Bug in ext2load? To: Gary Johnson References: <20220929200145.GB7620@phoenix> Content-Language: en-US Cc: U-Boot Mailing List , Simon Glass From: Heinrich Schuchardt In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:Aexog8QY8GXejfWcD/AEQT/8ksq8+bIBoRAOFWE9azZQOvXCBWj ORbl6VAZQJbjsI5tePoVG1YCZ8MFzwoJS+h3kQBo/0LHz+PfRzjUd5DpB0cYuEsmo7Jf7Zi oPr4miewLzfoorvGbBBSpd5PPtldY7iytdEqJq45ZHD0gjLwtfXXQ0zboQwOiWwl4IT3Ino aUbpjmWOeDulMOb4CK90w== X-UI-Out-Filterresults: notjunk:1;V03:K0:JTuAZIiY2pE=:+HD38a95iBn0aETJ6H0vWB wGjOHj+3wRV9oIQmqQJzfRguk9e9y7ggG7X4SKMzYQvzJpj0mcA20vAQmdnO1dWFqtlnW95O3 mMgMQXp+iPQk9zmCD0+WRtV18hV2NsIjelqAsq489hER38/7Myzr0CrqWPMjgC62mtHAfItbU S2PpY6a0jXcKr+bDAo1AnaXEfUgyC9t4PsWkT4HTVa7ZiyVEHtmj9VL7wYmQCEoOIiv8bX8zB hSeB8jUT16Ip8unbjHBQZ6m2iMHld89NcnXtl+q/UHKqFOt0fqyKXWFTl0RsevsYCzP7Mwf+p JOYM7RFnLaRLxIMihLmhOvZkP+ddNLakd7jq5uFdUhWWqyKuM2+elcqGW8ON1BFl/ymgAzA1c iqa4L0jbtnkVx3xz4xERNQs/27Z3we7s/QvbXMhEAr7VqvLsS/OBvXznnOsN+7QrYJV36xWyD tH6LDHe3pyZ2l3ztBw31gzxRJzeA5L5ICHSiZPrVMCd793zWuGSE/ztsCIe7MFHS3fceHHP1u srLpVo7t3vcNjT7XES9jWTk0uLlnecTMo7rtkb668GoKLP8uj9qDPBFYKmsfz14bSehmqNwDD 0oqxa4//yJ4gs+4nDxkDUAC6hNMPGGYLfxhUlWuxlJLxENUu1K1EOkZDKLDxEfjdgTXrfZDhR 0wdpRnIlreThzsytRqgWiXmQ3uvQKQrmMA3cAb3/Efk7DC3zu2pJMAYgmeKJrC4MuIAmeggF4 4/noq3OVF20f6jHUrkMQNz8CxyYnBn5k0id1wnwNZd+4XTnFzhkpKqfqrwWSstrsF5w9nfKFz n3XvVxSxXjcZHNYU/mMd2/i6s2nkluUw50UL/bBSIjvCOV4Uxl6tQxZ87hQVt2Yy5+6Zjd/Bp n35pboazmrs0MXKmvlw01d7grc1WtEOh6IHKICcaX4z1A9/JGuS3LS+8/+gUMWPjcc6V50r/K yMm2V+txmq4HsvKmghDJsd+PysfSduhmDLwYRqgjP/BFNlLAkysb5/6GFz6z7qUsMp7Q3JBq5 J+kCD5iRKVMwa/vnEuCsr7otYCQDM60ZynSuxnSzoa59Eog81g1WimC6Csz+j3vKvyWRPuDwJ WPaY/QDvh5ybc8XP10/hzQnFANr7tENFrcLxrTLWanwcd9rOwchNZMxLLQMoXCREeeC/1i+R2 8Xjd4LWz5CWWIiiCqyjLYiRzP6 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 On 9/30/22 15:28, Simon Glass wrote: > +Heinrich Schuchardt > > On Thu, 29 Sept 2022 at 16:31, Gary Johnson wrote: >> >> I think I've found a bug in the ext2load command. When the file According to the description below the bug is not in the command but in the file-system driver. Function read_allocated_block() tries to implement handling of sparse files. According to comments it is a copy from GRUB. GRUB has tried to fix an error for sparse files with commit 1e5ed5f5f5a ("fs/ext2: Fix handling of missing sparse extent leafs.") Maybe we could try to upgrade to GRUB's current code. >> being read is a sparse file, the command fails as in this example. >> >> =3D> 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=3Dnever ...", 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 rea= d action >> */ >> >> However, I did not try to debug the problem further, as using "cp >> --sparse=3Dnever" 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. >> >> =3D> usb storage >> Device 0: Vendor: USB Rev: 1.00 Prod: SanDisk 3.2Gen1 >> Type: Removable Hard Disk >> Capacity: 29328.0 MB =3D 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. >> >> =3D> 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 >> Here is another error report for ext4: [BUG] ext4: the load command on an EXT4 partition leads to errors due to unaligned buffers https://lists.denx.de/pipermail/u-boot/2021-January/437180.html Unfortunately filesystems cbfs, fat, ext4, reiserfs, zfs don't have maintainers. Best regards Heinrich