]> git.baikalelectronics.ru Git - kernel.git/commit
ubifs: do_rename: Fix wrong space budget when target inode's nlink > 1
authorZhihao Cheng <chengzhihao1@huawei.com>
Tue, 11 Oct 2022 03:47:31 +0000 (11:47 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 12:55:20 +0000 (13:55 +0100)
commit63b08cf0665fa861fe0b3cbbee45d2c4f5bd55e3
treea716d5721ecf978e218a6b06439fc7f87fe0ccca
parent870248428b7fba5540852e784277b7ad00df1452
ubifs: do_rename: Fix wrong space budget when target inode's nlink > 1

[ Upstream commit 810c85cdfecd6a9e72ca3dac0b8bd1b33689bd2f ]

If target inode is a special file (eg. block/char device) with nlink
count greater than 1, the inode with ui->data will be re-written on
disk. However, UBIFS losts target inode's data_len while doing space
budget. Bad space budget may let make_reservation() return with -ENOSPC,
which could turn ubifs to read-only mode in do_writepage() process.

Fetch a reproducer in [Link].

Link: https://bugzilla.kernel.org/show_bug.cgi?id=216494
Fixes: 974763da840dbf ("UBIFS: add new flash file system")
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ubifs/dir.c