Skip to content

Commit 25fce61

Browse files
Zhihao Chengrichardweinberger
Zhihao Cheng
authored andcommitted
ubifs: do_rename: Fix wrong space budget when target inode's nlink > 1
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: 1e51764 ("UBIFS: add new flash file system") Signed-off-by: Zhihao Cheng <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent b248eaf commit 25fce61

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/ubifs/dir.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,8 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
13241324
if (unlink) {
13251325
ubifs_assert(c, inode_is_locked(new_inode));
13261326

1327+
/* Budget for old inode's data when its nlink > 1. */
1328+
req.dirtied_ino_d = ALIGN(ubifs_inode(new_inode)->data_len, 8);
13271329
err = ubifs_purge_xattrs(new_inode);
13281330
if (err)
13291331
return err;

0 commit comments

Comments
 (0)