Home
last modified time | relevance | path

Searched hist:"255 bb28338c545348cae4d9681888d7654f307a2" (Results 1 – 1 of 1) sorted by relevance

/rk3399_rockchip-uboot/fs/ubifs/
H A Dubifs.c255bb28338c545348cae4d9681888d7654f307a2 Tue May 17 20:45:28 UTC 2022 Pali Rohár <pali@kernel.org> UPSTREAM: ubifs: Fix lockup/crash when reading files

Commit b1a14f8a1c2e ("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: b1a14f8a1c2e ("UBIFS: Change ubifsload to not read beyond the requested size")
Change-Id: I361a8cae545d40475bb540b9ae92f4c04cce484d
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 339f652992919be11e3f1b791515140de646a3ef)