Received: by 10.192.165.148 with SMTP id m20csp2486408imm; Sun, 22 Apr 2018 08:02:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/J6BU3X/+Tury2fNUF/Dfv18C4ZxesRWXk7eRi8lsHTWwJ0HB4zUct20yLm6TbdjBIxjdV X-Received: by 2002:a17:902:5a5:: with SMTP id f34-v6mr17375837plf.288.1524409360124; Sun, 22 Apr 2018 08:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524409360; cv=none; d=google.com; s=arc-20160816; b=zIgxuWANmpRoOVHWmSAMHu5lXtDaqEiityamWW0HsfwvHy25ShC45Oc7IrSpvMxCW3 Kj4HiJxyAcZrz/2tw8pPKDKjuENEZSrCLNA0JSgricOPYLnmr7QiDI1LhH0gMbD6gJQp xfIjCAQLSGqOgRv8z4CnPp6QxazIvCieLx4ALk7m/bmATuo8CWwWYfU5MboFbclv9WZG 8LrnG9F1ItJQVURG6gudbn8Qpoem1HPsYME6WAQZB0+RcHE6wDoqlxdqI26qzo6UidEV zb0R6U+6z+SPoUUQxMMPMFPYl+fk6wrLlwwTVj71FEbqSSGmIm2gyWePRIfVv1QnaYp4 LoOQ== 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=KD1i+Ox0iv3abT5PSjdoQgx4+i6Fup1F85wl11wHpGY=; b=DyXakNp+N1Ofz2vb8buyV8rajVl7AA9QC5LOZZ9OOy6iUEzXvMM3w13hOt4WnQI837 KUmdSqW2jsqE2PtWYYWHaMgbCW3xkAIzoY0pU6Kd9R6W4Vl54CYZKEflJlpH9u4mYn6T 19IC+EpX7J82QP1CfhJ/lzg9wt3XwkQ/MeMFRJHySu2U9IEjzElewmticRPjDTDniL17 dH5HN5n2qnxLPhbDjVA5FhW+rGxclcOg5uOXqWengmPJirTisLDcBl2L0Udp0gf0hiSA nGqQXx5/kBMd0hq+b2/dK0seXy3HtyhuLtuIrc4OM+eXjGU2PFNj+xjSt7JSj29ZUyh9 7ZyQ== 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 d125si9146011pfa.263.2018.04.22.08.02.25; Sun, 22 Apr 2018 08:02:40 -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 S1756751AbeDVOMw (ORCPT + 99 others); Sun, 22 Apr 2018 10:12:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55272 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756740AbeDVOMr (ORCPT ); Sun, 22 Apr 2018 10:12:47 -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 2F399C97; Sun, 22 Apr 2018 14:12:47 +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.9 45/95] libnvdimm, namespace: use a safe lookup for dimm device name Date: Sun, 22 Apr 2018 15:53:14 +0200 Message-Id: <20180422135212.258941698@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135210.432103639@linuxfoundation.org> References: <20180422135210.432103639@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.9-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 @@ -1747,7 +1747,7 @@ struct device *create_namespace_pmem(str } 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 @@ -1755,7 +1755,7 @@ struct device *create_namespace_pmem(str * 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; }