Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp626582pxv; Thu, 15 Jul 2021 11:53:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFMqQ1wn49k6Y/FKWMEpQpq5thOdYqaNinBMdaPU7p2ZEPfcRYfToF7Z+OkiMGjbyhncMk X-Received: by 2002:a92:7f07:: with SMTP id a7mr3514720ild.202.1626375221784; Thu, 15 Jul 2021 11:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626375221; cv=none; d=google.com; s=arc-20160816; b=SODVqXMDzdz4Hw1xGT0+exKzbYne1gUFfPQVURT7jmCEzvA6Ato/KeIEdd92+5tA/s rb526ttWkv6Xb9WKK4gf+5SBHXHi/kITAvUn3qQr/P390CjFhemqwk6x4D/3Siae6FBE nxutLAM+TE0a+qDrU+90Sex1gLXg2NuIDxjqpvov5nqJ+FvDaXDgy4caxdIXFCg/jaBV 4e7XPByrdtgzTxFUeoJ8oIc8KqwF6oMZRXwcrKpShFVpc126dKBWIRqd9qhT33JQUx0z 83WQcc/I11u5E4P5WXLEZe3f6U7f7eMQ9fb9wP8tBLDfPq5Phipo5JEZNnjmPrxrzvti H1KA== 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=rdbePtZxIDYYV/0d4ljZpWQLCLju/OU/vL9J3GyygqU=; b=KF9Ge6FPR+g3cMQYIvdEL4z4i+jyp6siWUSFHiSctEmOYCOiXaXW6Gp/WPBCrg0F0d 2xs8F/Z8CzZhJl26O5pqAd1Ii4lbH2QU3jFgpvwCN9zG9+L05sJH9KHdiAjt7VbCWcd+ XZvSJBv+4i+mRXNuwDQ5jvIpVwlB86fXCyRaxHCxeQK5R1zQ+BW3EtfVZWKkSfdsbXFM f8qTkPm8RH9pOS0eZ4C3rAUHoCvPK4Tk0IKKL1COtyVAtjn3SB8Exy9TMi8GO5shLv3x LyJkEbYVZr7nF7kfzb+zN/B+NF2QZdBWeSagV/IweGSMiuunQL2uxcFnrhWSH09GGenJ +9eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oeoo2RO0; 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 j2si5870895ilo.119.2021.07.15.11.53.29; Thu, 15 Jul 2021 11:53:41 -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=oeoo2RO0; 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 S241194AbhGOSzc (ORCPT + 99 others); Thu, 15 Jul 2021 14:55:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:53796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231909AbhGOSuw (ORCPT ); Thu, 15 Jul 2021 14:50:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0EE09613F1; Thu, 15 Jul 2021 18:47:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626374870; bh=3/5VTQ67dGpVPJEXLyxieGsl4R+yGH3Nmn7z9lut5mA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oeoo2RO04J4qkYhf7bGetPWLrdraWxYGhRz6VWxGwaRzsT2/ZjeIeN5wRdGd5BZHd IT/v/ssXboc13Mj1njamNHVGcVbGYGxmZALjXbuY3YLnwRHlCUyMAtfG6h3IFdR8ep nwoC2alBEzu9sKDBJQv80BZlQxP0rUTzpASiNzO0= 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.10 026/215] udf: Fix NULL pointer dereference in udf_symlink function Date: Thu, 15 Jul 2021 20:36:38 +0200 Message-Id: <20210715182603.564128238@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182558.381078833@linuxfoundation.org> References: <20210715182558.381078833@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 e169d8fe35b5..f4a72ff8cf95 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c @@ -932,6 +932,10 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry, 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