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 9DE7CC433DF for ; Sun, 18 Oct 2020 19:34:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6489A204FD for ; Sun, 18 Oct 2020 19:34:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603049676; bh=DoHMJVW9vLJaZWoKIKqf6iqzojGxJFnlThHFDjwg+Ac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=nUD0FwrtO5KKpwOSzaoPIREgtEvw7HnDvLvgJAf4PxV4PNZopd4II+RuJ1eF23ysd Xob1puZJ4GrPFGPhBX1ciEcas4hEip073mIjwK1oh1tO+SszyzickQgaEIOjrKnkqS lF9Vh/EgB1x/wjpIsPdc07AL06krkbZF4G4ZxjkA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731653AbgJRT0V (ORCPT ); Sun, 18 Oct 2020 15:26:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:41134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731552AbgJRT0H (ORCPT ); Sun, 18 Oct 2020 15:26:07 -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 DF91C222C8; Sun, 18 Oct 2020 19:26:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603049166; bh=DoHMJVW9vLJaZWoKIKqf6iqzojGxJFnlThHFDjwg+Ac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nz1fzuK5dZkaQBA3lw+QfMnJpYgOYJpJeHjtEaf9Yg9ONqp340gzS7QlsS0SiEvMe bM9fcF1R1dgcCEXGVhzVYiyR/Yw1EqTQf2SehJINox+kGZS93dFdcCznkAxyjEhX4A 8jwYZIULv5dsbmjwBZikaAaLDBurbGfbYfdf4Ix4= 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.14 30/52] udf: Avoid accessing uninitialized data on failed inode read Date: Sun, 18 Oct 2020 15:25:07 -0400 Message-Id: <20201018192530.4055730-30-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201018192530.4055730-1-sashal@kernel.org> References: <20201018192530.4055730-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 3c1b54091d6cc..dd57bd446340c 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -132,21 +132,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