u-boot/fs
Sam Edwards 6d6ea52b62 fs: btrfs: fix reading when length specified
The btrfs read function limits the read length to ensure that it
and the read offset do not together exceed the size of the file.
However, this size was only being queried if the read length was
passed a value of zero (meaning "whole file"), and the size is
defaulted to 0 otherwise. This means the clamp will just zero out
the length if one is specified, preventing reading of the file.

Fix this by checking the file size unconditionally, and unifying
the default length and clamping logic as a single range check instead.

This bug was discovered when trying to boot Linux with initrd= via
'bootefi' from a btrfs partition. The EFI stub entered an infinite
loop of zero-length reads while trying to read the initrd, and the
boot process stalled indefinitely.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
2023-11-16 18:59:58 -05:00
..
btrfs fs: btrfs: fix reading when length specified 2023-11-16 18:59:58 -05:00
cbfs spl: Ensure all SPL symbols in Kconfig have some SPL dependency 2022-07-07 09:29:08 -04:00
cramfs cramfs: clean up some error messages 2023-08-08 17:41:52 -04:00
erofs fs/erofs: Quieten test for filesystem presence 2023-08-19 04:12:52 +02:00
ext4 fs: ext4: Remove unused parameter from ext4_mount 2023-11-16 18:53:09 -05:00
fat part: Add accessors for struct disk_partition uuid 2023-08-25 17:55:18 -04:00
jffs2 fs: jffs2: Move SYS_JFFS2_SORT_FRAGMENTS to Kconfig 2022-11-10 09:45:54 -05:00
reiserfs common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
sandbox bootstd: Use bootdev instead of bootdevice 2023-07-16 23:13:17 +08:00
squashfs fs/squashfs: enable LZ4 compression support 2023-11-16 18:53:09 -05:00
ubifs treewide: use linux/time.h for time conversion defines 2023-11-16 18:59:58 -05:00
yaffs2 common: Drop linux/printk.h from common header 2023-09-24 09:54:57 -04:00
zfs common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
fs.c fs: Disable sandbox filesystem in SPL 2023-10-17 20:50:52 -04:00
fs_internal.c fs: Quieten down the filesystems more 2022-10-17 21:17:12 -06:00
Kconfig bootstd: sandbox: Add a hostfs bootdev 2022-04-25 10:00:04 -04:00
Makefile fs: Add semihosting filesystem 2022-04-01 15:03:13 -04:00
semihostingfs.c semihosting: create file in smh_fs_write_at() 2023-05-31 17:23:01 -04:00