Commit 1b2ba090 authored by Zhihao Cheng's avatar Zhihao Cheng Committed by Richard Weinberger

ubifs: Rectify space budget for ubifs_xrename()

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: 9ec64962 ("ubifs: Implement RENAME_EXCHANGE")
Signed-off-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent c2c36cc6
...@@ -1576,6 +1576,10 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1576,6 +1576,10 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
return err; return err;
} }
err = ubifs_budget_space(c, &req);
if (err)
goto out;
lock_4_inodes(old_dir, new_dir, NULL, NULL); lock_4_inodes(old_dir, new_dir, NULL, NULL);
time = current_time(old_dir); time = current_time(old_dir);
...@@ -1601,6 +1605,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1601,6 +1605,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
unlock_4_inodes(old_dir, new_dir, NULL, NULL); unlock_4_inodes(old_dir, new_dir, NULL, NULL);
ubifs_release_budget(c, &req); ubifs_release_budget(c, &req);
out:
fscrypt_free_filename(&fst_nm); fscrypt_free_filename(&fst_nm);
fscrypt_free_filename(&snd_nm); fscrypt_free_filename(&snd_nm);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment