Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp167239pxx; Wed, 28 Oct 2020 01:22:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDHDbeW8lxkOAaVaRAaT+9uxYLfXBYwm9O6jWtLBbU3+QtfDeVtstgVncLcT9c3H0PgKFO X-Received: by 2002:a17:906:3c03:: with SMTP id h3mr6271795ejg.78.1603873342947; Wed, 28 Oct 2020 01:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603873342; cv=none; d=google.com; s=arc-20160816; b=rYuYJXb1qaC0BF9sqplJv9Bn9vZZaas02MC9lSmc8UdcULYHEGjOkC6uDg5Ly6l4PM QFG7xU2BRbTB+M45G57kT9MA3Xc0ar+Aw1OGAmhTE9hc966Ki9z2213OsXLoBcT4Aye+ u56+Gf1oYK9ObEsY92NlYZmO0f34ti7Xm6XZEhTq0GGCTdc6Iiqy6kdxpZUPXowbvw8L omnHVZtDQGv0j4h8m74yDBfZWsOejBG9zSaj7BDAmetcBvsSv5DLOiM8V9zpUmkNN0as XPcAxJzSj3bprm3F0oCIxr1BWNcDPtJuSjk0wlkyBHfdiNiJBrNro0EkV+ing9USqlMg IMcQ== 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=muYXqS+lcmJ0iP7wWzZPXN2eFZuAO5F/UPSq2OODX1E=; b=TR35t9Wn/RMafKUFDetBICCncbUusho4OHqZYUNxdPW+pnH4I01finhQeK3HCOLuKN fXLgtvwaGnCLDEoNH5kiWH5Wi7pSUyt2OzNm2TpipUoxoNYMbe2Kxyu3xtuTlV5qU+q/ OfoM2MWz6u+2bETtnoMPi5gqOTP8KR00LTe6+NPSfzzBFI5vk1F9WcAiPngkJW2zqeVQ RqDaO+IIuZuiWt6Z3s7KVMmPQJfCC0nDMr8E/m8zvmIx0y4iuwCH5mde4q59eg9qD0k2 4UKHNzPaXnQCtp+NBoTk2H+/aMsXt6BY5pGp6kvi4KDO4Kmy040vrrOPme1n8OTUjBaE m2vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aEYpibT5; 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 lg14si2653130ejb.82.2020.10.28.01.22.01; Wed, 28 Oct 2020 01:22:22 -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=aEYpibT5; 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 S1753802AbgJ0OCR (ORCPT + 99 others); Tue, 27 Oct 2020 10:02:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:49126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753678AbgJ0OB0 (ORCPT ); Tue, 27 Oct 2020 10:01:26 -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 BA4C6221F8; Tue, 27 Oct 2020 14:01:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807286; bh=rlLzz3Jh8H+CytRmdH/a8fvAOVgqamMizoyS7i1vZm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aEYpibT5QnhN+SoyB+PGQp1wR2iDXJiPiS6jKvBfYON98zD9Yc2dGNVweXwtoEx5g SDxAKVJw3ds6Cx5b2zSLyVnVXey2Gi2T52bcJFB/2Z1mPjIH2lD1UUWpShd9mAVj6h 5iEmITCfi+PC9FL8b8aBtjrdvwzdhGgRXRlqQDqE= 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 4.4 093/112] udf: Avoid accessing uninitialized data on failed inode read Date: Tue, 27 Oct 2020 14:50:03 +0100 Message-Id: <20201027134904.948048940@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@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 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