Received: by 10.192.165.148 with SMTP id m20csp2433783imm; Sun, 22 Apr 2018 07:02:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx48hdjGD+oJzPgvvfpItpQRzJYaVUItlZqPN510SAsx2iJE31vg9lzOHHAjkELADYpfuMwKK X-Received: by 2002:a17:902:24c:: with SMTP id 70-v6mr17632479plc.384.1524405765970; Sun, 22 Apr 2018 07:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524405765; cv=none; d=google.com; s=arc-20160816; b=TZjyAA/aX7vy0GWgE4KnENNagxq1XvPXxEhmX27cXHBsE4V5w/sXIHJ8fynP9uiUzn Z9rKtl4nt20Knfx+A8NvL49Ql1EExfq6gpZmwOHUxZU2Su7/1dE2NMfjwfEPtofXveGh CETFx/MCkKPzsEj2rWu03OrgipOlG/PFuzFsr7xF/4rxPBQfgaWMW6dnrH9zDijTFtWu lsOIjw9H2r7Raahb/E/l5QRk7OfzBPjdzY/428lfX96XD3s+jkITNFge8Hjw7aPmPsLh mmhCaYfVDFQ3Z+P/0Pi/8RYm+SFpVbxFQG7rH7tN1gVu8ExGyrocSDTN77Sr0ILycNVC QdYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=t9t7HSfXuEQ7nZOme7R/qdGuF+sEx8nnB1beu8+Y/8U=; b=EsYBRHuBvC/AgxGecGe0mpvWDIXoiWgluKcjyF2dVFuWojECrsBotb7Bt0xcIceQTX pCH+y7Kz5k369g7Jyfy6vzkH8BovjCdE9DWNJ9CL+tgG6SNpnL6WylU6KJvMgmuVlRN2 JmFqBhze9SAwzzmq58bXzmykqd56xE3Y1q6Hy6QuFaenSwEJmGUv9Gn480HmHwag8iT6 uJrcKei8ppqVgWU6WIZwuugjmCrauo5h/BLrIcxWjSbn6GgC3yM7MDcVl4qQCjwIYHgJ UkkcxAJwRHehbrBuF1PMY8c2M9t6OZM+Yr6Zlvo1nF+HvECIx/KIQ3+QF7RVa41gt4qP oVJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t134si8173835pgc.519.2018.04.22.07.02.31; Sun, 22 Apr 2018 07:02:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754733AbeDVOBe (ORCPT + 99 others); Sun, 22 Apr 2018 10:01:34 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47966 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754504AbeDVOB2 (ORCPT ); Sun, 22 Apr 2018 10:01:28 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C9C1D941; Sun, 22 Apr 2018 14:01:27 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dave Jiang , Dan Williams Subject: [PATCH 4.16 123/196] libnvdimm, namespace: use a safe lookup for dimm device name Date: Sun, 22 Apr 2018 15:52:23 +0200 Message-Id: <20180422135110.617420376@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Williams commit 4f8672201b7e7ed4f5f6c3cf6dcd080648580582 upstream. The following NULL dereference results from incorrectly assuming that ndd is valid in this print: struct nvdimm_drvdata *ndd = to_ndd(&nd_region->mapping[i]); /* * Give up if we don't find an instance of a uuid at each * position (from 0 to nd_region->ndr_mappings - 1), or if we * find a dimm with two instances of the same uuid. */ dev_err(&nd_region->dev, "%s missing label for %pUb\n", dev_name(ndd->dev), nd_label->uuid); BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 IP: nd_region_register_namespaces+0xd67/0x13c0 [libnvdimm] PGD 0 P4D 0 Oops: 0000 [#1] SMP PTI CPU: 43 PID: 673 Comm: kworker/u609:10 Not tainted 4.16.0-rc4+ #1 [..] RIP: 0010:nd_region_register_namespaces+0xd67/0x13c0 [libnvdimm] [..] Call Trace: ? devres_add+0x2f/0x40 ? devm_kmalloc+0x52/0x60 ? nd_region_activate+0x9c/0x320 [libnvdimm] nd_region_probe+0x94/0x260 [libnvdimm] ? kernfs_add_one+0xe4/0x130 nvdimm_bus_probe+0x63/0x100 [libnvdimm] Switch to using the nvdimm device directly. Fixes: 0e3b0d123c8f ("libnvdimm, namespace: allow multiple pmem...") Cc: Reported-by: Dave Jiang Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- drivers/nvdimm/namespace_devs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/nvdimm/namespace_devs.c +++ b/drivers/nvdimm/namespace_devs.c @@ -1926,7 +1926,7 @@ static struct device *create_namespace_p } if (i < nd_region->ndr_mappings) { - struct nvdimm_drvdata *ndd = to_ndd(&nd_region->mapping[i]); + struct nvdimm *nvdimm = nd_region->mapping[i].nvdimm; /* * Give up if we don't find an instance of a uuid at each @@ -1934,7 +1934,7 @@ static struct device *create_namespace_p * find a dimm with two instances of the same uuid. */ dev_err(&nd_region->dev, "%s missing label for %pUb\n", - dev_name(ndd->dev), nd_label->uuid); + nvdimm_name(nvdimm), nd_label->uuid); rc = -EINVAL; goto err; }