[PATCH] fs: btrfs: fix reading when length specified

Tom Rini trini at konsulko.com
Fri Nov 17 14:41:46 CET 2023


On Sat, Nov 11, 2023 at 08:19:04AM -0700, Sam Edwards wrote:

> 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 at gmail.com>
> Reviewed-by: Qu Wenruo <wqu at suse.com>

Applied to u-boot/next, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20231117/63499ff5/attachment.sig>


More information about the U-Boot mailing list