Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp638730pxv; Thu, 15 Jul 2021 12:10:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW3nob66Ls5LuPNsbrNtc1plCWBplCx/D2T48IJ03dAx4jAwsmhQry6oIh5TYUluAj7D9P X-Received: by 2002:a92:d10c:: with SMTP id a12mr3801693ilb.100.1626376209699; Thu, 15 Jul 2021 12:10:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626376209; cv=none; d=google.com; s=arc-20160816; b=JlvGaQjel8j2EQeoebLG7czfpvKbSGnXFwmtbpLGX4GS3SVxwM9ScoS+APcwlCGZC9 8CdVQ4N1ODdcfKzuvPyrTsqhvjE9LOqv0d0vijpfzOgODgh17+zNtOOQI/QbCFxRlDqa 3ctdo5kIpmuMEMwhjJLUBdPEq2xYfgOmhDJ6/tDouDsRBTm7BcHN+4l3cLl5v4E4ocUz S+uyDxJuzPUyDhhJ60WKWvbRmuPCizJ9w5HozM103cXTfSpucUgqIamyZQBPUjtx8V48 43uL+SD/hUjhET30Oz+VqbYofX3DdbjxaUwig75xZMQtY/rJVNFVwF34u04avsCbXYPW 2KEQ== 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=ktzFgqVIjUAYOZU15guLV1aWno1upol4JGIQlbjLSlc=; b=xB7+6dYbrBIGM6GY8uyNx0cio8R2bVRdYGvOngIxOhETCgqK6tJQAQhunJ8YBQSiOQ NN9Yl8fqz9Z6q+D3CuDtt2/zdhNGUwLvigWI/WvXEXm47LCl1c7om6cTikvWUt9b8gJL +Gd7gNpUlCnhE7f5WYXMNe3BgmUQ7tAGAESrw/kP9q4WGX+IU3uSsBhfSO7OK58vZ6JX HiAiJe5+5+vHpH4R6CWVOSDSpOVwnQ9GEm7GLfa9mdr9PLLXu0aSY/mpQawfJNPKTt/C zx667VIW8UvhOy6SUMfn7Qu+kQRkT85rY9pXpJ4286MAzAmzrctUDKVM+HIOP9jW8Z10 64Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hBb9JG7P; 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 y1si7463886jao.99.2021.07.15.12.09.57; Thu, 15 Jul 2021 12:10:09 -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=hBb9JG7P; 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 S243963AbhGOTK0 (ORCPT + 99 others); Thu, 15 Jul 2021 15:10:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:34230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242365AbhGOS7i (ORCPT ); Thu, 15 Jul 2021 14:59:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B1E1A601FE; Thu, 15 Jul 2021 18:56:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375396; bh=IuiwSptQ5Z8ADJkX/wvC2jxc0AwthtD6/yBlCmD2C5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hBb9JG7PvmAvX277eWcFGnwKFPzeFCvD9l85JcKQmAiQhc88ceXvwQnLzcWJnMwe+ TPxYW31wR2M4Xng+TvYd75oSUx+v4qLNHWFCEfgqFLE6hX3Y9nwLzDiB7mS6zkPhYY DKy1MMkHTxUzMkXSCv38S89Pji3slpn7GY0b/GKM= 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.12 027/242] udf: Fix NULL pointer dereference in udf_symlink function Date: Thu, 15 Jul 2021 20:36:29 +0200 Message-Id: <20210715182556.635188505@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182551.731989182@linuxfoundation.org> References: <20210715182551.731989182@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 f146b3089f3d..6c5692ad42b5 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