u-boot/fs/ubifs
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
..
budget.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
debug.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
debug.h mtd: ubi, ubifs debug: Use pr_debug instead of pr_crit 2019-04-09 07:46:42 +02:00
gc.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
io.c ubifs: do not decide upon uninitialized variable 2021-01-20 14:01:45 -05:00
Kconfig Convert CONFIG_UBIFS_SILENCE_MSG to Kconfig 2018-03-24 06:37:10 +01:00
key.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
log.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
lprops.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
lpt_commit.c crc16: Rename fs/ubifs/crc16.h to include/linux/crc16.h 2022-04-21 14:32:40 -04:00
lpt.c crc16: Rename fs/ubifs/crc16.h to include/linux/crc16.h 2022-04-21 14:32:40 -04:00
Makefile crc16: Move standard CRC-16 implementation from ubifs to lib 2022-04-21 14:32:40 -04:00
master.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
misc.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
orphan.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
recovery.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
replay.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
sb.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
scan.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
super.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
tnc_misc.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
tnc.c ubifs: Fix journal replay wrt. xattr nodes 2022-04-11 15:03:28 -04:00
ubifs-media.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
ubifs.c ubifs: Fix lockup/crash when reading files 2022-06-03 10:23:22 -04:00
ubifs.h WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00