Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3610112pxb; Mon, 24 Jan 2022 13:28:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9IyzQzqrMEdXLH8VsqGHLkv+W8XqM2SDeMOTs9wc0v7wOO9hQ0xnFefqPc1ApSxR18Gfq X-Received: by 2002:a63:1b4c:: with SMTP id b12mr13091973pgm.281.1643059694796; Mon, 24 Jan 2022 13:28:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643059694; cv=none; d=google.com; s=arc-20160816; b=KXgp2y/DZyR2ZjZU8fFVFCIxE0vHgaJXih4ya0SS7yoLA3num8nBnthbreDgL7xfNW Zuwt1U3cpz7uqFkGb48DCfgOKnE9yTifZeBBTLbPp2MkOyJ++dLJYLuwrzARBOCOWNpG bZxOiv8YWEv+4dTgvO4NA61/NlVkDBhtiHg3RG7reEZja/GThv4twKWS6uH57Cn7yicC tXWK3pHZ9FauSUmKsN3WIJeZt/zH8Tg0/XxiYPQm7a7OI7Wf7NhxylnY6R4/5X3r+Kg2 koxoSUE4ufygrWUX8hjrAkvKKt6/1sDD60nc8UxwyHuPlg9t2EMxo0wYJC3AX4uY9gY1 oyQA== 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=LIz8gabrmMzZGiip8u/3XRo0RS9li3BCTLw8x5uXHMfXe9/G/fNXd1XZ6WEmWngkBG gcDec/tb/Kfapexnl2hEsx/Bock7SJF/zqzgVtWYEi8bj1tCrL8cooCqQP6hlh1fBBsY iPXCpvjrHeSdcL+52b6gDOOFmZBFDOfB5mUEhWOssSQwf7BbrH7a5RFPO6Kwg9s/g4+0 L5+6dI63MnabEYT1DEqIsaV2tGFrVl4rd4bQ5/cQBVjAkDx1PysiSfanmUb3SxZCVCC7 wxBNzss5zcUSQsfMmXjXXXiUmERtZTyqwI9GxC6srGTCoasaX4Q7VFbhTmZQZF7Bc5Vh NR3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QpkrP0qb; 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 j3si149255plr.373.2022.01.24.13.28.02; Mon, 24 Jan 2022 13:28:14 -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=QpkrP0qb; 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 S1346755AbiAXVFs (ORCPT + 99 others); Mon, 24 Jan 2022 16:05:48 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:39712 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358153AbiAXUn7 (ORCPT ); Mon, 24 Jan 2022 15:43:59 -0500 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 dfw.source.kernel.org (Postfix) with ESMTPS id 3698260B28; Mon, 24 Jan 2022 20:43:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 196B9C340E5; Mon, 24 Jan 2022 20:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057037; bh=GzbYbsXc5BwyTSbLqMt453HSpU4UrE4xgXx+YQpBbjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QpkrP0qb86i8DB42Wrb58N+OPup/mcWpJqnbDKzUR9S3Wst98a4KBdmhXrEPZnmPr da+fgY+lkYsCcyLvyccpyHdyMgdLk7rWetoJqD8NREQ5o/RmaBUk5wC7DsMZWKsIoB b07zlPthWKk3GZ3oQ9TbPxbyOs9qCYOYoDi7SDz4= 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.15 649/846] udf: Fix error handling in udf_new_inode() Date: Mon, 24 Jan 2022 19:42:46 +0100 Message-Id: <20220124184123.406590822@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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