u-boot/fs/btrfs
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
..
common fs: btrfs: Crossport rbtree-utils from btrfs-progs 2020-09-07 20:57:27 -04:00
crypto fs/btrfs: use asm/unaligned.h 2023-05-31 14:05:34 -04:00
kernel-shared WS cleanup: remove excessive empty lines 2021-09-30 08:08:56 -04:00
btrfs.c fs: btrfs: fix reading when length specified 2023-11-16 18:59:58 -05:00
btrfs.h treewide: Fix Marek's name and change my e-mail address 2022-07-21 10:14:04 +02:00
compat.h global: Use proper project name U-Boot 2023-06-12 13:24:31 +02:00
compression.c treewide: Fix Marek's name and change my e-mail address 2022-07-21 10:14:04 +02:00
conv-funcs.h treewide: Fix Marek's name and change my e-mail address 2022-07-21 10:14:04 +02:00
ctree.c treewide: Fix Marek's name and change my e-mail address 2022-07-21 10:14:04 +02:00
ctree.h treewide: Fix Marek's name and change my e-mail address 2022-07-21 10:14:04 +02:00
dev.c treewide: Fix Marek's name and change my e-mail address 2022-07-21 10:14:04 +02:00
dir-item.c treewide: Fix Marek's name and change my e-mail address 2022-07-21 10:14:04 +02:00
disk-io.c fs/btrfs: handle data extents, which crosss stripe boundaries, correctly 2023-01-11 15:02:24 -05:00
disk-io.h fs: btrfs: Cleanup the old implementation 2020-09-07 21:00:36 -04:00
extent-cache.c fs: btrfs: Crossport extent-cache.[ch] from btrfs-progs 2020-09-07 20:57:27 -04:00
extent-cache.h fs: btrfs: Crossport extent-cache.[ch] from btrfs-progs 2020-09-07 20:57:27 -04:00
extent-io.c treewide: Fix Marek's name and change my e-mail address 2022-07-21 10:14:04 +02:00
extent-io.h global: Use proper project name U-Boot 2023-06-12 13:24:31 +02:00
inode.c btrfs: fix some error checking for btrfs_decompress() 2023-08-08 17:41:52 -04:00
Kconfig fs/btrfs: add dependency on BLAKE2 hash 2022-01-18 08:31:02 -05:00
Makefile treewide: Fix Marek's name and change my e-mail address 2022-07-21 10:14:04 +02:00
root-tree.c fs: btrfs: Crossport open_ctree_fs_info() from btrfs-progs 2020-09-07 20:57:27 -04:00
subvolume.c fs: btrfs: Prevent error pointer dereference in list_subvolums() 2023-08-08 17:05:43 -04:00
volumes.c fs: btrfs: limit the mapped length to the original length 2023-02-23 13:29:19 -05:00
volumes.h fs: btrfs: Crossport btrfs_read_sys_array() and btrfs_read_chunk_tree() 2020-09-07 20:57:27 -04:00