Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2171307ybv; Fri, 21 Feb 2020 10:14:03 -0800 (PST) X-Google-Smtp-Source: APXvYqwrmcXi6t8ozpLgjJe8+KYwwTv85I88+VfW3pw5Dg8iAy6DxF9EtS5r1X+Oyomxr2jgLMqB X-Received: by 2002:a05:6808:8d5:: with SMTP id k21mr3045694oij.121.1582308843777; Fri, 21 Feb 2020 10:14:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582308843; cv=none; d=google.com; s=arc-20160816; b=a7LRjwQ/iMLkIs/RPSd80AdtvA5wifbM0tY6k3HtdFzqFBjWuqwSu0hKGa8EoKi94W ebNah2n5fgUyjWBvilYZuk7XCarJ9oxNJbJsmZWTjtLJpW2h0XGzTEkGsueholZPjnD1 nN4qRDkriFBDZFAGTScHa+g66W5xBDm9FUOa/0eVTPzYSd2/Fg5c0yLgZZQ3A7vWRpPt 6fY2BqF8oP79AMRVtDPN0607CM5bPKYpAIRjkWmBRFygD/gHucw79/dKG8mdU+rRTJEf lF2xNArfYQ4O3c7FK9hHpHZv9ehVSsX6DGkHJAaAbO5PEODyUonLBITIpqGFxGtbNmgi /3ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=xqw5dC8E63KUoGC1Gm+Or2PRDalBHkhCku+Uh3ybQkU=; b=mhXnpO98vYDyK6q3Td6CT3s5MLOCtC7EOezJInFg8P1iROwh76cBKM0CRYbWTR2lXz Lmu3yE7jDwqJBp822GkqqEYk+bLXdpCT7dI7XGI1H5UghdQKdnEOZ2WjMWwnKuI4mDfP IiqE6eBwTZy0Y7oeo5jqB3aR5wh19wfISau8fKFj3kGLN1soshlPNx7UFtrE/zR6HPdK hmVx2jHHMsep8OzIz+AWq5qjjxjDc6eqnHE2Xt3gjSHzmOpbDwvCnDNzf3lSReYhLybZ TBPL8L7TTN8A/tYawL+vjejW/guz2zB4JZsX2uOFSzyQvysK4oWcRPkLzKfNtTLSpbbC Ff9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d199si1213738oib.135.2020.02.21.10.13.51; Fri, 21 Feb 2020 10:14:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728594AbgBUSMr (ORCPT + 99 others); Fri, 21 Feb 2020 13:12:47 -0500 Received: from mail.parknet.co.jp ([210.171.160.6]:40028 "EHLO mail.parknet.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbgBUSMq (ORCPT ); Fri, 21 Feb 2020 13:12:46 -0500 Received: from ibmpc.myhome.or.jp (server.parknet.ne.jp [210.171.168.39]) by mail.parknet.co.jp (Postfix) with ESMTPSA id A378415CBEB; Sat, 22 Feb 2020 03:12:45 +0900 (JST) Received: from devron.myhome.or.jp (foobar@devron.myhome.or.jp [192.168.0.3]) by ibmpc.myhome.or.jp (8.15.2/8.15.2/Debian-17) with ESMTPS id 01LICitc040560 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 22 Feb 2020 03:12:45 +0900 Received: from devron.myhome.or.jp (foobar@localhost [127.0.0.1]) by devron.myhome.or.jp (8.15.2/8.15.2/Debian-17) with ESMTPS id 01LIChMR408200 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 22 Feb 2020 03:12:44 +0900 Received: (from hirofumi@localhost) by devron.myhome.or.jp (8.15.2/8.15.2/Submit) id 01LICcT1408196; Sat, 22 Feb 2020 03:12:38 +0900 From: OGAWA Hirofumi To: Andrew Morton Cc: syzbot , glider@google.com, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: fat: Fix uninit-memory access for partial initialized inode References: <0000000000008a9e79059f1409f1@google.com> Date: Sat, 22 Feb 2020 03:12:38 +0900 In-Reply-To: <0000000000008a9e79059f1409f1@google.com> (syzbot's message of "Fri, 21 Feb 2020 03:08:11 -0800") Message-ID: <871rqnreqx.fsf@mail.parknet.co.jp> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When got error at middle of reading inode, some fields in inode might be still not initialized. And then evict_inode path may access those fields via iput(). To fix, this makes sure that inode fields are initialized. Reported-by: syzbot+9d82b8de2992579da5d0@syzkaller.appspotmail.com Cc: stable@vger.kernel.org Signed-off-by: OGAWA Hirofumi --- fs/fat/inode.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 5f04c5c..686130f 100644 --- a/fs/fat/inode.c 2020-02-09 21:29:07.541357068 +0900 +++ b/fs/fat/inode.c 2020-02-22 02:15:20.451313122 +0900 @@ -749,6 +749,13 @@ static struct inode *fat_alloc_inode(str return NULL; init_rwsem(&ei->truncate_lock); + /* Zeroing to allow iput() even if partial initialized inode. */ + ei->mmu_private = 0; + ei->i_start = 0; + ei->i_logstart = 0; + ei->i_attrs = 0; + ei->i_pos = 0; + return &ei->vfs_inode; } @@ -1373,16 +1380,6 @@ out: return 0; } -static void fat_dummy_inode_init(struct inode *inode) -{ - /* Initialize this dummy inode to work as no-op. */ - MSDOS_I(inode)->mmu_private = 0; - MSDOS_I(inode)->i_start = 0; - MSDOS_I(inode)->i_logstart = 0; - MSDOS_I(inode)->i_attrs = 0; - MSDOS_I(inode)->i_pos = 0; -} - static int fat_read_root(struct inode *inode) { struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb); @@ -1843,13 +1840,11 @@ int fat_fill_super(struct super_block *s fat_inode = new_inode(sb); if (!fat_inode) goto out_fail; - fat_dummy_inode_init(fat_inode); sbi->fat_inode = fat_inode; fsinfo_inode = new_inode(sb); if (!fsinfo_inode) goto out_fail; - fat_dummy_inode_init(fsinfo_inode); fsinfo_inode->i_ino = MSDOS_FSINFO_INO; sbi->fsinfo_inode = fsinfo_inode; insert_inode_hash(fsinfo_inode); _