Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp655045pxv; Thu, 15 Jul 2021 12:36:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwt8fZXkY1TMNJnqoaJLefoB6PlaSOUytbFFflz1wDFyDu+8AaT9DmRDAINPxf04fVec7XM X-Received: by 2002:a17:907:3c81:: with SMTP id gl1mr7269178ejc.48.1626377775050; Thu, 15 Jul 2021 12:36:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626377775; cv=none; d=google.com; s=arc-20160816; b=ahq6qrovSnIxvINI0a2Dev4SYpUKBhDVDx+Xe9ecs0dnC0A5e00iyrKk9of/vlYm+g yoKC+JVPciPVCNbO7xL6/zsHmOgPTAsmQhfLOApjzGjusUKO+9OJMZBV+MkMTUrulgDn XelAh3+EGWuITGCgI0YMFJy8t42v92GaqbL8vsKaQ1kunA0nQ59GqguSQVR/cIVIn2EC jFCPnW3RfYfhQWlOrou71Y7E6WzGOJxcrG65x7781Mmqbcf4lsMoV4FUbbSZ0Tpd/QCz DaP0vdqt8r6Ab1qLaZQ6DJO9G4fqbpWelokwgcxVOBUIBuMl/5Q/xhqoy295wKa/TeIZ 63Qw== 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=H2EVqm4M2xScgaMH1QjpCTEeTlN7lMYKeW/DleCXnZ4=; b=isSHalEKC2EFrl7nEqhW2ebWaQpK7RApcjyOHkh+NwfyNQAnoonACC8Tx7pQ2zMTi2 d16+3xN6Mk3B/DxbuwWK1Ef4jT2pXawByPkEnLI7zocfLReA33FQhaa7ZODKwy2tiGW/ T7yVkM8YUx3yRaE8oYEoHOa6lsbVMy3izN66LmqB5/v6NgVrFcxGZ75OFvqAo+L07ri/ I4pU7TdOf5nSMUGo+X9w+/zj6HvcAzGzZgvmvMxv+bIfRl7awv0Ec1TR64G0DxnLohTa NjVW/keHpIT04mPVf2ab0bm1OUohbsIfLE7+XCNZBwXfuXKweaLCEwo7YephSyShbEua Jz9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aHgyShSa; 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 m4si9078496eja.301.2021.07.15.12.35.52; Thu, 15 Jul 2021 12:36:15 -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=@linuxfoundation.org header.s=korg header.b=aHgyShSa; 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 S245539AbhGOTbt (ORCPT + 99 others); Thu, 15 Jul 2021 15:31:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:46434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243698AbhGOTKB (ORCPT ); Thu, 15 Jul 2021 15:10:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5C9BC61417; Thu, 15 Jul 2021 19:06:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375979; bh=eWhmhpiMqM87jdVbTbTJeoNWiAD8ZXiQSfYHQ/uJd5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aHgyShSaYbTC9DLkW8Rl9zMf93LMsh7UrOu+15iTuHTz/PRpQa3PquEfFc13MX1xC mc5T4TZ7CreRtkB76FdqSeDdEKKcGPpBWPCnWj3pTcLxTGXCZTvDwFKY1N1cly02jb DbsfakVQ8UAqiyyvZiS21+lI/kB9WYB7lEzJJM1Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arturo Giusti , Jan Kara , Sasha Levin Subject: [PATCH 5.13 034/266] udf: Fix NULL pointer dereference in udf_symlink function Date: Thu, 15 Jul 2021 20:36:29 +0200 Message-Id: <20210715182620.324321032@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@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: Arturo Giusti [ Upstream commit fa236c2b2d4436d9f19ee4e5d5924e90ffd7bb43 ] In function udf_symlink, epos.bh is assigned with the value returned by udf_tgetblk. The function udf_tgetblk is defined in udf/misc.c and returns the value of sb_getblk function that could be NULL. Then, epos.bh is used without any check, causing a possible NULL pointer dereference when sb_getblk fails. This fix adds a check to validate the value of epos.bh. Link: https://bugzilla.kernel.org/show_bug.cgi?id=213083 Signed-off-by: Arturo Giusti Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/udf/namei.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 3ae9f1e91984..7c7c9bbbfa57 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -934,6 +934,10 @@ static int udf_symlink(struct user_namespace *mnt_userns, struct inode *dir, iinfo->i_location.partitionReferenceNum, 0); epos.bh = udf_tgetblk(sb, block); + if (unlikely(!epos.bh)) { + err = -ENOMEM; + goto out_no_entry; + } lock_buffer(epos.bh); memset(epos.bh->b_data, 0x00, bsize); set_buffer_uptodate(epos.bh); -- 2.30.2