Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp655494ybh; Tue, 10 Mar 2020 06:00:05 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv/5hWJ/G5IXGYsbts5TVYVNpiW2guH2O4HNApURSTEMEzigTPVeOLM/rocWSmDGdfDTSga X-Received: by 2002:a54:448c:: with SMTP id v12mr1010620oiv.107.1583845204926; Tue, 10 Mar 2020 06:00:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583845204; cv=none; d=google.com; s=arc-20160816; b=ak2WdlhElhL5Okzy9FYQ0rxxM9iHq+1OICtjuCiCIVWQ6/WSXZr89LiYHoSJeQN5OH rh5Amjl1hKQnSxvU9XraJGwsmr9QNMQNm4aaeF/YXCxVVSduecZHh4INVG5hZAxBqRZ5 5kjLIpbecy2so3NFmaUmMmT/PT+EJ1lFkkyz5UrMtYp85eEto4IWjEZo4Yg/drutEWGY 2uaOD22lpX6PjMUD87yHHL8InIgqXCjOqPtYzfJq5bB8L8egur1x+enVzqAUGMvPXo4i xbF5gamy7kjDCTID69PlrsQ3VNbDFu+MSsWVxW/q0KBNTYSTf0v262aFBQLRV2SMy3zT l3cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bbvNDC6W47u1sHT6uhqP3A4u8Bz9md7M1ZDs7OUJQ1I=; b=aIdMlz3uoY4RtUICLNgXopD3z16wq0iFdQLmEss++CJp4C8Kaw5YOkaKcuEEfwpQ/B 42EhbQuln3Dy4OKEX2uIGgXyTlgngUG5d2GMbbyL5rkCHMJBQ/lt9ZQobDm1m8ofxhmX dzq2paiAf+fU4So3WumktrdRcz2UI+m9jkPtrJ0coTWJpeAEhwMaLOD2hbiHwij5SWZB 9b357aNKlZbmC8knp/Mftj7w6puRaX4UvxP35Lu0Lo8wiIgMshA5VQ6EhkCna+mfNAhh pQ8Z+8P42Hybw5GXtnxRwg97nj3WkQtiYzW4AWgBdcpRDBB/NZNTyY96IAW5RglsCfqT Dciw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WfItBJgJ; 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 m11si7957383otp.174.2020.03.10.05.59.53; Tue, 10 Mar 2020 06:00:04 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=WfItBJgJ; 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 S1729018AbgCJM7V (ORCPT + 99 others); Tue, 10 Mar 2020 08:59:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:39664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726526AbgCJM7R (ORCPT ); Tue, 10 Mar 2020 08:59:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 03A7E24694; Tue, 10 Mar 2020 12:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583845156; bh=zHbdShaZV+XM7ds1MbyGEf0M0GeteJZlB32nh7R+jx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WfItBJgJSmutL7fHNea7Yip2sZBXYnPnj3zVm1HcBoZcNP8sEfY1nSKTvxXXxXico yUixyWLpzrDQXOtdgW2cUR8E1+RSRTM0l2rNsndy+g0k78j6p4/EiIFFvyrTO81k7c r88uXnZ35RyfDiJwY6TiKbrEjpy9XRvjuOh+ZzMs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+9d82b8de2992579da5d0@syzkaller.appspotmail.com, Andrew Morton , OGAWA Hirofumi , Linus Torvalds Subject: [PATCH 5.5 083/189] fat: fix uninit-memory access for partial initialized inode Date: Tue, 10 Mar 2020 13:38:40 +0100 Message-Id: <20200310123648.078279873@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200310123639.608886314@linuxfoundation.org> References: <20200310123639.608886314@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: OGAWA Hirofumi commit bc87302a093f0eab45cd4e250c2021299f712ec6 upstream. When get an error in the middle of reading an inode, some fields in the inode might be still not initialized. And then the 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 Signed-off-by: Andrew Morton Signed-off-by: OGAWA Hirofumi Cc: Link: http://lkml.kernel.org/r/871rqnreqx.fsf@mail.parknet.co.jp Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/fat/inode.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -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);