From: Zhihao Cheng Date: Tue, 11 Oct 2022 03:47:28 +0000 (+0800) Subject: ubifs: Rectify space budget for ubifs_xrename() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=8e166cc9b64b8dac0f7ea9e33c34e6c71e729b0c;p=linux.git 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 Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index a72e2ac4fdcd1..f193caae69c20 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -1572,6 +1572,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); @@ -1597,6 +1601,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;