Patch "f2fs: reject CASEFOLD inode flag without casefold feature" has been added to the 5.8-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: reject CASEFOLD inode flag without casefold feature

to the 5.8-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-reject-casefold-inode-flag-without-casefold-fea.patch
and it can be found in the queue-5.8 subdirectory.

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



commit 5be2261b6dde7a19d879f0b699720e4b99089a31
Author: Eric Biggers <ebiggers@xxxxxxxxxx>
Date:   Thu Oct 8 12:15:22 2020 -0700

    f2fs: reject CASEFOLD inode flag without casefold feature
    
    [ Upstream commit f6322f3f1212e005e7e6aa82ceb62be53030a64b ]
    
    syzbot reported:
    
        general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] PREEMPT SMP KASAN
        KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
        CPU: 0 PID: 6860 Comm: syz-executor835 Not tainted 5.9.0-rc8-syzkaller #0
        Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
        RIP: 0010:utf8_casefold+0x43/0x1b0 fs/unicode/utf8-core.c:107
        [...]
        Call Trace:
         f2fs_init_casefolded_name fs/f2fs/dir.c:85 [inline]
         __f2fs_setup_filename fs/f2fs/dir.c:118 [inline]
         f2fs_prepare_lookup+0x3bf/0x640 fs/f2fs/dir.c:163
         f2fs_lookup+0x10d/0x920 fs/f2fs/namei.c:494
         __lookup_hash+0x115/0x240 fs/namei.c:1445
         filename_create+0x14b/0x630 fs/namei.c:3467
         user_path_create fs/namei.c:3524 [inline]
         do_mkdirat+0x56/0x310 fs/namei.c:3664
         do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        [...]
    
    The problem is that an inode has F2FS_CASEFOLD_FL set, but the
    filesystem doesn't have the casefold feature flag set, and therefore
    super_block::s_encoding is NULL.
    
    Fix this by making sanity_check_inode() reject inodes that have
    F2FS_CASEFOLD_FL when the filesystem doesn't have the casefold feature.
    
    Reported-by: syzbot+05139c4039d0679e19ff@xxxxxxxxxxxxxxxxxxxxxxxxx
    Fixes: 2c2eb7a300cd ("f2fs: Support case-insensitive file name lookups")
    Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
    Reviewed-by: Gabriel Krisman Bertazi <krisman@xxxxxxxxxxxxx>
    Reviewed-by: Chao Yu <yuchao0@xxxxxxxxxx>
    Signed-off-by: Jaegeuk Kim <jaegeuk@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 44582a4db513e..1e014535c2530 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -287,6 +287,13 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
 		return false;
 	}
 
+	if ((fi->i_flags & F2FS_CASEFOLD_FL) && !f2fs_sb_has_casefold(sbi)) {
+		set_sbi_flag(sbi, SBI_NEED_FSCK);
+		f2fs_warn(sbi, "%s: inode (ino=%lx) has casefold flag, but casefold feature is off",
+			  __func__, inode->i_ino);
+		return false;
+	}
+
 	if (f2fs_has_extra_attr(inode) && f2fs_sb_has_compression(sbi) &&
 			fi->i_flags & F2FS_COMPR_FL &&
 			F2FS_FITS_IN_INODE(ri, fi->i_extra_isize,



[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