From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 738A0C433DF for ; Sun, 18 Oct 2020 19:29:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 393FD207DE for ; Sun, 18 Oct 2020 19:29:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603049397; bh=rlLzz3Jh8H+CytRmdH/a8fvAOVgqamMizoyS7i1vZm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=o76DAt0wT5Jx/coiYQY2THZpkCVav5rgocS3NjbiamBjXPJHq5958qUCi9TtSzn4E yIixLrv4y6MxdUiT+QnfhiEdYiqnr32OKreiEDorYIi3Bcz0tB2SEElx6ldPbjiJHx HE06ZW5RcR6K7euWp7HDgVcpkwxcsUT1LK6xjZQQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729835AbgJRT3z (ORCPT ); Sun, 18 Oct 2020 15:29:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:43920 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731071AbgJRT1t (ORCPT ); Sun, 18 Oct 2020 15:27:49 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 99DCD22267; Sun, 18 Oct 2020 19:27:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603049269; bh=rlLzz3Jh8H+CytRmdH/a8fvAOVgqamMizoyS7i1vZm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y4+rLMQb3g1UwKVYQL08ld57DYQhNNXGnv6YXEWhcHkO6X/8jm+tFs0laCMW01Eil Nfe4kF48ib/yE7ekBpu13TON19G175/7EAxLMIPrx06sylUcjgsQYPoMhjhyPcbliU OYhOyw9acjCl5WRdS96c175uADIrmBRGmvKVxuJQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jan Kara , syzbot+91f02b28f9bb5f5f1341@syzkaller.appspotmail.com, Sasha Levin Subject: [PATCH AUTOSEL 4.4 17/33] udf: Avoid accessing uninitialized data on failed inode read Date: Sun, 18 Oct 2020 15:27:12 -0400 Message-Id: <20201018192728.4056577-17-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201018192728.4056577-1-sashal@kernel.org> References: <20201018192728.4056577-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Kara [ Upstream commit 044e2e26f214e5ab26af85faffd8d1e4ec066931 ] When we fail to read inode, some data accessed in udf_evict_inode() may be uninitialized. Move the accesses to !is_bad_inode() branch. Reported-by: syzbot+91f02b28f9bb5f5f1341@syzkaller.appspotmail.com Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/udf/inode.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/fs/udf/inode.c b/fs/udf/inode.c index 3876448ec0dcb..2c39c1c81196c 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -140,21 +140,24 @@ void udf_evict_inode(struct inode *inode) struct udf_inode_info *iinfo = UDF_I(inode); int want_delete = 0; - if (!inode->i_nlink && !is_bad_inode(inode)) { - want_delete = 1; - udf_setsize(inode, 0); - udf_update_inode(inode, IS_SYNC(inode)); + if (!is_bad_inode(inode)) { + if (!inode->i_nlink) { + want_delete = 1; + udf_setsize(inode, 0); + udf_update_inode(inode, IS_SYNC(inode)); + } + if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB && + inode->i_size != iinfo->i_lenExtents) { + udf_warn(inode->i_sb, + "Inode %lu (mode %o) has inode size %llu different from extent length %llu. Filesystem need not be standards compliant.\n", + inode->i_ino, inode->i_mode, + (unsigned long long)inode->i_size, + (unsigned long long)iinfo->i_lenExtents); + } } truncate_inode_pages_final(&inode->i_data); invalidate_inode_buffers(inode); clear_inode(inode); - if (iinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB && - inode->i_size != iinfo->i_lenExtents) { - udf_warn(inode->i_sb, "Inode %lu (mode %o) has inode size %llu different from extent length %llu. Filesystem need not be standards compliant.\n", - inode->i_ino, inode->i_mode, - (unsigned long long)inode->i_size, - (unsigned long long)iinfo->i_lenExtents); - } kfree(iinfo->i_ext.i_data); iinfo->i_ext.i_data = NULL; udf_clear_extent_cache(inode); -- 2.25.1