Skip to content

Commit

Permalink
ubifs: Rectify space budget for ubifs_xrename()
Browse files Browse the repository at this point in the history
[ Upstream commit 1b2ba09 ]

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: 9ec6496 ("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>
  • Loading branch information
Zhihao Cheng authored and gregkh committed Mar 11, 2023
1 parent 8666030 commit f29168f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs/ubifs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,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);
Expand All @@ -1563,6 +1567,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;
Expand Down

0 comments on commit f29168f

Please sign in to comment.