Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp462391pxx; Wed, 28 Oct 2020 08:54:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJxCYBHM2QCikT48XkSRtCHq7YxJex7XGueHS7cpfSKWZGKqCZXrf2pf+N0y2XNUcYrBmT X-Received: by 2002:a50:8a02:: with SMTP id i2mr8747427edi.40.1603900460353; Wed, 28 Oct 2020 08:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603900460; cv=none; d=google.com; s=arc-20160816; b=YhSnfpFwmhmIvGPgvwyCYPQeYMjBbX1yxNSQvcFgOe2iWiNUiMRLQaP8OFrsKPDQoy eWZeqZ/5kTVBcI0oQFSl+hPU3Lwq/JXT/qw7CrTwGhp68I3bjO2P0JN6DwwGqQNX9LnC JRQ4cFtxSu861pgwK0J6fiUB0bJIxanKOhNTaNbV2N0CGmVTGCy+zjOyH3/X4AlT1MDB hRvpMr9QnAby2jVTg8rIAaS5gsm/6FnpDvq/qQx7tH60vUVEGKe70Hrlw0mf2XYgAHUM WKYlFqOmvriev7ShQJM9lJsAGiQvh8L0ZDLNSbnQZNZueaVexsq6GG2m9gfva7iqBV5z wlSA== 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=64580/OS/6pInAHKZiswCUrKQmR1vKgDLPKAhDhpe9c=; b=B8kNz6LvW0AXpbVRHkBiVXiywvqOKbfflv6W9ud/EynT0aEp+oiabU5QwlNfS0hdAw VH+CnbKK0Nf6E6flJQfTSUUVe+vJm6nKmrLnFiC4lm0tC+wSCa/dvvneHpZgSxvcnfHg TqufKMFD3az+jqfIPGydZby42TPbVOOYmiqxi5vMns1HObDtlD2V3KLGBcPG6/CnF2cY 1HPemtVza5JfxKDVBo3ClkRs1Cp2ngRP9DuSaNnqwiSdcmnDKHr6myBYWhJAcSXLw0Tr 0B/WiQ2JkTbCLInYPqa9tvPn/w595TbJL6XrpB8sHDaZvXom4QgTWAaMFSRWQumtGi/x g1UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KyF6VPBg; 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 y19si2789537ejd.730.2020.10.28.08.53.58; Wed, 28 Oct 2020 08:54:20 -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=KyF6VPBg; 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 S1813487AbgJ0QuY (ORCPT + 99 others); Tue, 27 Oct 2020 12:50:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:51378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1794917AbgJ0POW (ORCPT ); Tue, 27 Oct 2020 11:14:22 -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 51F6620728; Tue, 27 Oct 2020 15:14:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811661; bh=My1jZhxrhaIwPxyYadbJWkFqJCp8iFABq5AI9LDc2wU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KyF6VPBgI24i++4orly0NgrK0gp6kJHDSoBRxRCvDX2oeg3td3oxzRpN7+SXyfOop RBVB+JE4ANfzli1O6zG9xAaiocImgjQGRRPiX8Tg8nc4quyH5oJ6C5ud+jaW+D9VFR 8wBlP5I6ggn9gwZBp01NzP96L0U7am0nWDSg/xGw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+91f02b28f9bb5f5f1341@syzkaller.appspotmail.com, Jan Kara , Sasha Levin Subject: [PATCH 5.8 572/633] udf: Avoid accessing uninitialized data on failed inode read Date: Tue, 27 Oct 2020 14:55:15 +0100 Message-Id: <20201027135549.639822710@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: 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 adaba8e8b326e..566118417e562 100644 --- a/fs/udf/inode.c +++ b/fs/udf/inode.c @@ -139,21 +139,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