u-boot/fs
Pali Rohár 339f652992 ubifs: Fix lockup/crash when reading files
Commit b1a14f8a1c ("UBIFS: Change ubifsload to not read beyond the
requested size") added optimization to do not read more bytes than it is
really needed. But this commit introduced incorrect handling of the hole at
the end of file. This logic cause U-Boot to crash or lockup when trying to
read from the ubifs filesystem.

When read_block() call returns -ENOENT error (not an error, but the hole)
then dn-> structure is not filled and contain garbage. So using of dn->size
for memcpy() argument cause that U-Boot tries to copy unspecified amount of
bytes from possible unmapped memory. Which randomly cause lockup of P2020
CPU.

Fix this issue by copying UBIFS_BLOCK_SIZE bytes from read buffer when
dn->size is not available. UBIFS_BLOCK_SIZE is the size of the buffer
itself and read_block() fills buffer by zeros when it returns -ENOENT.

This patch fixes ubifsload on P2020.

Fixes: b1a14f8a1c ("UBIFS: Change ubifsload to not read beyond the requested size")
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
2022-06-03 10:23:22 -04:00
..
btrfs btrfs: Fix compilation on big endian systems 2022-04-19 14:52:34 -04:00
cbfs doc: replace @return by Return: 2022-01-19 18:11:34 +01:00
cramfs common: Drop flash.h from common header 2020-05-18 14:53:28 -04:00
erofs fs/erofs: add lz4 decompression support 2022-03-15 16:19:29 -04:00
ext4 fs: ext4: Use CRC-16 implementation from linux/crc16.h 2022-04-21 14:32:40 -04:00
fat doc: replace @return by Return: 2022-01-19 18:11:34 +01:00
jffs2 Convert CONFIG_JFFS2_DEV et al to Kconfig 2021-12-27 16:20:19 -05:00
reiserfs common: Drop asm/global_data.h from common header 2021-02-02 15:33:42 -05:00
sandbox bootstd: sandbox: Add a hostfs bootdev 2022-04-25 10:00:04 -04:00
squashfs fs/squashfs: use lldiv function for math 2022-05-23 09:33:10 -04:00
ubifs ubifs: Fix lockup/crash when reading files 2022-06-03 10:23:22 -04:00
yaffs2 fs: yaffs2: Finish Kconfig migration 2021-11-05 11:23:29 -04:00
zfs common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
fs_internal.c fs: convert error and debug messages to log 2020-09-06 21:21:41 +02:00
fs.c fs: Add a function to set the filesystem type 2022-04-25 10:00:03 -04: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 fs: Add semihosting filesystem 2022-04-01 15:03:13 -04:00