Patch "f2fs: fix to do sanity check on inline_dots inode" has been added to the 5.18-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

    f2fs: fix to do sanity check on inline_dots inode

to the 5.18-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:
     f2fs-fix-to-do-sanity-check-on-inline_dots-inode.patch
and it can be found in the queue-5.18 subdirectory.

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



commit 44e1229af1ae4518f3650ff47441f14b1990dcfe
Author: Chao Yu <chao@xxxxxxxxxx>
Date:   Tue Mar 29 00:02:53 2022 +0800

    f2fs: fix to do sanity check on inline_dots inode
    
    [ Upstream commit 12662d19467b391b5b509ac5e9ab4f583c6dde16 ]
    
    As Wenqing reported in bugzilla:
    
    https://bugzilla.kernel.org/show_bug.cgi?id=215765
    
    It will cause a kernel panic with steps:
    - mkdir mnt
    - mount tmp40.img mnt
    - ls mnt
    
    folio_mark_dirty+0x33/0x50
    f2fs_add_regular_entry+0x541/0xad0 [f2fs]
    f2fs_add_dentry+0x6c/0xb0 [f2fs]
    f2fs_do_add_link+0x182/0x230 [f2fs]
    __recover_dot_dentries+0x2d6/0x470 [f2fs]
    f2fs_lookup+0x5af/0x6a0 [f2fs]
    __lookup_slow+0xac/0x200
    lookup_slow+0x45/0x70
    walk_component+0x16c/0x250
    path_lookupat+0x8b/0x1f0
    filename_lookup+0xef/0x250
    user_path_at_empty+0x46/0x70
    vfs_statx+0x98/0x190
    __do_sys_newlstat+0x41/0x90
    __x64_sys_newlstat+0x1a/0x30
    do_syscall_64+0x37/0xb0
    entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    The root cause is for special file: e.g. character, block, fifo or
    socket file, f2fs doesn't assign address space operations pointer array
    for mapping->a_ops field, so, in a fuzzed image, if inline_dots flag was
    tagged in special file, during lookup(), when f2fs runs into
    __recover_dot_dentries(), it will cause NULL pointer access once
    f2fs_add_regular_entry() calls a_ops->set_dirty_page().
    
    Fixes: 510022a85839 ("f2fs: add F2FS_INLINE_DOTS to recover missing dot dentries")
    Reported-by: Wenqing Liu <wenqingliu0120@xxxxxxxxx>
    Signed-off-by: Chao Yu <chao.yu@xxxxxxxx>
    Signed-off-by: Jaegeuk Kim <jaegeuk@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 5ed79b29999f..fffafd2aa438 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -461,6 +461,13 @@ static int __recover_dot_dentries(struct inode *dir, nid_t pino)
 		return 0;
 	}
 
+	if (!S_ISDIR(dir->i_mode)) {
+		f2fs_err(sbi, "inconsistent inode status, skip recovering inline_dots inode (ino:%lu, i_mode:%u, pino:%u)",
+			  dir->i_ino, dir->i_mode, pino);
+		set_sbi_flag(sbi, SBI_NEED_FSCK);
+		return -ENOTDIR;
+	}
+
 	err = f2fs_dquot_initialize(dir);
 	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