ubifs: Fix UBIFS ro fail due to truncate in the encrypted directory
authorZhaoLong Wang <wangzhaolong1@huawei.com>
Sat, 9 Jul 2022 08:40:32 +0000 (16:40 +0800)
committerRichard Weinberger <richard@nod.at>
Wed, 21 Sep 2022 09:32:38 +0000 (11:32 +0200)
commit713346ca1db2bebd4c7c4d5ea364ed03d504f5ed
tree9c661e9a380866cee9ce1d1b2cf293f2f1041eb5
parent019ac05e4c97f51913318d9b0e2ffd34db917d3c
ubifs: Fix UBIFS ro fail due to truncate in the encrypted directory

The ubifs_compress() function does not compress the data When the
data length is short than 128 bytes or the compressed data length
is not ideal.It cause that the compressed length of the truncated
data in the truncate_data_node() function may be greater than the
length of the raw data read from the flash.

The above two lengths are transferred to the ubifs_encrypt()
function as parameters. This may lead to assertion fails and then
the file system becomes read-only.

This patch use the actual length of the data in the memory as the
input parameter for assert comparison, which avoids the problem.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=216213
Signed-off-by: ZhaoLong Wang <wangzhaolong1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
fs/ubifs/crypto.c
fs/ubifs/journal.c