From: Gary Johnson <garyjohn@spocom.com>
To: u-boot@lists.denx.de
Subject: Bug in ext2load?
Date: Thu, 29 Sep 2022 13:01:45 -0700 [thread overview]
Message-ID: <20220929200145.GB7620@phoenix> (raw)
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
next reply other threads:[~2022-09-29 22:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-29 20:01 Gary Johnson [this message]
2022-09-30 13:28 ` Bug in ext2load? Simon Glass
2022-10-01 21:17 ` Heinrich Schuchardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220929200145.GB7620@phoenix \
--to=garyjohn@spocom.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox