diff options
author | ZhaoLong Wang <wangzhaolong1@huawei.com> | 2022-07-09 16:40:32 +0800 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2022-09-21 11:32:38 +0200 |
commit | 713346ca1db2bebd4c7c4d5ea364ed03d504f5ed (patch) | |
tree | 9c661e9a380866cee9ce1d1b2cf293f2f1041eb5 /fs/ubifs/crypto.c | |
parent | 019ac05e4c97f51913318d9b0e2ffd34db917d3c (diff) | |
download | lwn-713346ca1db2bebd4c7c4d5ea364ed03d504f5ed.tar.gz lwn-713346ca1db2bebd4c7c4d5ea364ed03d504f5ed.zip |
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>
Diffstat (limited to 'fs/ubifs/crypto.c')
-rw-r--r-- | fs/ubifs/crypto.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/ubifs/crypto.c b/fs/ubifs/crypto.c index c57b46a352d8..3125e76376ee 100644 --- a/fs/ubifs/crypto.c +++ b/fs/ubifs/crypto.c @@ -24,6 +24,17 @@ static bool ubifs_crypt_empty_dir(struct inode *inode) return ubifs_check_dir_empty(inode) == 0; } +/** + * ubifs_encrypt - Encrypt data. + * @inode: inode which refers to the data node + * @dn: data node to encrypt + * @in_len: length of data to be compressed + * @out_len: allocated memory size for the data area of @dn + * @block: logical block number of the block + * + * This function encrypt a possibly-compressed data in the data node. + * The encrypted data length will store in @out_len. + */ int ubifs_encrypt(const struct inode *inode, struct ubifs_data_node *dn, unsigned int in_len, unsigned int *out_len, int block) { |