Patch "ubifs: do_rename: Fix wrong space budget when target inode's nlink > 1" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ubifs: do_rename: Fix wrong space budget when target inode's nlink > 1

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     ubifs-do_rename-fix-wrong-space-budget-when-target-i.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit c4c115314b470a2ae8a0d487340043d094a45d62
Author: Zhihao Cheng <chengzhihao1@xxxxxxxxxx>
Date:   Tue Oct 11 11:47:31 2022 +0800

    ubifs: do_rename: Fix wrong space budget when target inode's nlink > 1
    
    [ Upstream commit 25fce616a61fc2f1821e4a9ce212d0e064707093 ]
    
    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: 1e51764a3c2ac0 ("UBIFS: add new flash file system")
    Signed-off-by: Zhihao Cheng <chengzhihao1@xxxxxxxxxx>
    Signed-off-by: Richard Weinberger <richard@xxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 15b5664fd5c93..6039943877e10 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1288,6 +1288,8 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
 	if (unlink) {
 		ubifs_assert(c, inode_is_locked(new_inode));
 
+		/* Budget for old inode's data when its nlink > 1. */
+		req.dirtied_ino_d = ALIGN(ubifs_inode(new_inode)->data_len, 8);
 		err = ubifs_purge_xattrs(new_inode);
 		if (err)
 			return err;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux