summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhihao Cheng <chengzhihao1@huawei.com>2022-10-11 11:47:28 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-03-11 16:26:50 +0100
commit3afd49bec1f857d856e88b4c2060d9df0ca0a57f (patch)
tree6d7c086c91235f302656ca9aed86fb289aa1b7a0
parent61e04db3bec87f7dd10074296deb7d083e2ccade (diff)
downloadlinux-3afd49bec1f857d856e88b4c2060d9df0ca0a57f.tar.gz
linux-3afd49bec1f857d856e88b4c2060d9df0ca0a57f.tar.bz2
linux-3afd49bec1f857d856e88b4c2060d9df0ca0a57f.zip
ubifs: Rectify space budget for ubifs_xrename()
[ Upstream commit 1b2ba09060e41adb356b9ae58ef94a7390928004 ] There is no space budget for ubifs_xrename(). It may let make_reservation() return with -ENOSPC, which could turn ubifs to read-only mode in do_writepage() process. Fix it by adding space budget for ubifs_xrename(). Fetch a reproducer in [Link]. Link: https://bugzilla.kernel.org/show_bug.cgi?id=216569 Fixes: 9ec64962afb170 ("ubifs: Implement RENAME_EXCHANGE") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--fs/ubifs/dir.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 299611052bbf..99e3692264ae 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1605,6 +1605,10 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
return err;
}
+ err = ubifs_budget_space(c, &req);
+ if (err)
+ goto out;
+
lock_4_inodes(old_dir, new_dir, NULL, NULL);
time = current_time(old_dir);
@@ -1630,6 +1634,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
unlock_4_inodes(old_dir, new_dir, NULL, NULL);
ubifs_release_budget(c, &req);
+out:
fscrypt_free_filename(&fst_nm);
fscrypt_free_filename(&snd_nm);
return err;