Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp483603pxx; Wed, 28 Oct 2020 09:20:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJmsoklegvn/bKiMd5TKFfYceM2Jj83wVuS7AUCpJmwpTSrdPm3RUGcFZSRGROPLDKj655 X-Received: by 2002:a17:906:3fd3:: with SMTP id k19mr8736500ejj.434.1603902052076; Wed, 28 Oct 2020 09:20:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603902052; cv=none; d=google.com; s=arc-20160816; b=IjRgekANAvSV0zEMlK960fVSo7gW3GcC6PCHb5p1/2VO/PFGFzwqqYQwRe/cOOgBeX IijOFWUTc56KDeWt+uCh840yZBDf02STrc5HQ9DlbLhQormqz8TIf45OaHoY6CuKfHDM sp+8ui3gvKHQndpDVTZwdaKv9UZuW0xLyR0sDQtxS3AfyMg6KWQ+4PXe7mr88LSWwJQx LtTm5CgpnooSNkIjrF287rZrR6OzBOvmGRnITI4mifiPfvWVN0IP95D4As4v0is4OVRH jGGwKuo2aBKOdrNA85PXp9WwQKQdmWJv+fGgKUqp3BhBESwzZsBqO2vxQxcZrfLK3IId D3XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1quuwJdNHrHi3/iYmKIOssCc87OuaNV93vHzOd/FHP8=; b=SU7d7Fm7F5549wfE1vaF5cEimAiiNEBDe5J1Mamgj48zJOuSzya0CGiqw1C0Zs4kTa xe50IRtTIas8drBasMCo5H2EPap3ncsPn8aDlGpQwFLEGptMKfEKikR7h/ICaHk/RoJT Xxkeenm0Q7fVgcAisnMRXnadT558eIh55c6WeHe4fcKXlPvY8JJvZpupPekgnpLjauAa qp8g96uWdKKZF4uqstT6fyaEX4NcVKXe85cTbK9vztZfF7y5pdnC4x68a0xtEPhHSf2X 5cjfqQU22PPmiutfqhM/ki4Q+/RRkC0tppgWT7eGY2Fz5sLeQGcuYny8l0jcsn2De8Ts 4ZIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NmRPPfiW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d14si3866156edu.275.2020.10.28.09.20.28; Wed, 28 Oct 2020 09:20:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NmRPPfiW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1816550AbgJ0RHe (ORCPT + 99 others); Tue, 27 Oct 2020 13:07:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:40822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1762641AbgJ0PGl (ORCPT ); Tue, 27 Oct 2020 11:06:41 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F180C22275; Tue, 27 Oct 2020 15:06:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811199; bh=hyRHfek5kRpCjhxU/oAuY4RrZ4hzquBLpSBV0g4MUvY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NmRPPfiWApwtu3KOnLYgWcMZUxsBBUl3cfoVHTVAQ3MiitCocc7fe7QdFOdKUbsdV N+up2jmdeClS7ITRPThl+Z3Yv+L48w7VsNideChm6cIhtv2bnmB16LPN4rLRIe7EmX GVGRdCUMJarVuKH3x0ivNgiYRRtQGe8HIzbOVDDE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+05139c4039d0679e19ff@syzkaller.appspotmail.com, Eric Biggers , Gabriel Krisman Bertazi , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 5.8 407/633] f2fs: reject CASEFOLD inode flag without casefold feature Date: Tue, 27 Oct 2020 14:52:30 +0100 Message-Id: <20201027135541.814012524@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Biggers [ 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@syzkaller.appspotmail.com Fixes: 2c2eb7a300cd ("f2fs: Support case-insensitive file name lookups") Signed-off-by: Eric Biggers Reviewed-by: Gabriel Krisman Bertazi Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/inode.c | 7 +++++++ 1 file changed, 7 insertions(+) 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, -- 2.25.1