Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3724869pxb; Mon, 24 Jan 2022 16:24:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJyAQ1I/C2y3M5SKV6Q2nZ1abT3W+bEQZwrQDMTYy+fmzIH1YuMLsX+RsoD4HizlyPnuAbU0 X-Received: by 2002:a17:902:8307:b0:14a:c935:4403 with SMTP id bd7-20020a170902830700b0014ac9354403mr15479686plb.15.1643070250965; Mon, 24 Jan 2022 16:24:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643070250; cv=none; d=google.com; s=arc-20160816; b=epUInx0Qjx1dl5OfcoCPnJVlYQxgbSqnM5tCvoI+wYfjhlzKqj5Twde4cQJZGGWyUW ojwVfdca1e4keqxIcrcCVUo0+vB22GyAkEHJ2cf067hkxmeCMLqGX0d+AYD71MExj2Uz q2iqN9U9OHgRaGqs5eV03iCqkV2FVxqlRw4AxTvwvlkdjDiaIMRmnG327cZVwR4s+q9b gkolmbVu98vfJy5MzDvyRHZzz8wokeIrfj+lcKDN78eenp9D8PxqZZZ2ekZRYEysDHKW cM8xh1q6PizsuMxC7Myw3Qq+lVvaxzNudBm7tZTD2jjOQTUEcF9lpg/QgrWs7Heot8LX mHAw== 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=lIDjzbfuu6u4+78Vb8eAOO5gxo04jkX4bQAczm3hq2E=; b=ixNRy1YO52IHtU7g0y5c4bt9E8OGJdSyWYAWQnJuBei0GjlYoOM0bZjx8suJ8sHrVV /zVFku74BARbPmp2PG80kUXj4uuS9pphdntqqJ0NcEm2g0ubFE2hMZmSPczJ5R0yjkro C3h1IcfSFbTgnCig2Gvyioi4uXXMzCc2gbdbgv69eN146Ouo3uWL3mcNMoufjFmimRk4 p4BKk5z8iRBe9IuNDNFvS1aOhG5Z+81Bywzg8eWKhl0afJNkhSuf2DQlYaSsrKMRiAsp W2/s4q2ignRx+P/v94TU5yvqyWp0u0YQrrKY6dtgNdJkKcHqRWhlYPLlR/Tsf4nV8v10 Wxcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=b5ITBnkl; 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=pass (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 d6si14567078pgc.95.2022.01.24.16.23.58; Mon, 24 Jan 2022 16:24:10 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=b5ITBnkl; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2373536AbiAYAOs (ORCPT + 99 others); Mon, 24 Jan 2022 19:14:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1574354AbiAXX2Q (ORCPT ); Mon, 24 Jan 2022 18:28:16 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5711EC0A54D9; Mon, 24 Jan 2022 13:32:54 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 14576B80FA1; Mon, 24 Jan 2022 21:32:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D86C7C340E4; Mon, 24 Jan 2022 21:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059971; bh=GzbYbsXc5BwyTSbLqMt453HSpU4UrE4xgXx+YQpBbjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b5ITBnkli9wJz6Uk5mClsU/jdyT5pdKGeI/lSITuKtuWjOVZoMaqBO08x8lCGdflM 4uFH4ovVnZEN2rE0L7stJfAdFXauUEOSD5BSGkgKl+dzp6vEB+1LeFgXWLB7Bc++lX 4CYpX7bqFM0ROFFb37BtlgOhnTJyjUei+a2F6dWM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+9ca499bb57a2b9e4c652@syzkaller.appspotmail.com, Jan Kara , Sasha Levin Subject: [PATCH 5.16 0763/1039] udf: Fix error handling in udf_new_inode() Date: Mon, 24 Jan 2022 19:42:32 +0100 Message-Id: <20220124184150.964657576@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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 f05f2429eec60851b98bdde213de31dab697c01b ] When memory allocation of iinfo or block allocation fails, already allocated struct udf_inode_info gets freed with iput() and udf_evict_inode() may look at inode fields which are not properly initialized. Fix it by marking inode bad before dropping reference to it in udf_new_inode(). Reported-by: syzbot+9ca499bb57a2b9e4c652@syzkaller.appspotmail.com Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/udf/ialloc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c index 2ecf0e87660e3..b5d611cee749c 100644 --- a/fs/udf/ialloc.c +++ b/fs/udf/ialloc.c @@ -77,6 +77,7 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode) GFP_KERNEL); } if (!iinfo->i_data) { + make_bad_inode(inode); iput(inode); return ERR_PTR(-ENOMEM); } @@ -86,6 +87,7 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode) dinfo->i_location.partitionReferenceNum, start, &err); if (err) { + make_bad_inode(inode); iput(inode); return ERR_PTR(err); } -- 2.34.1