Received: by 10.192.165.148 with SMTP id m20csp2525298imm; Sun, 22 Apr 2018 08:51:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/YYvDPahZYYJuGREfuSUTpikbCIRihXIeUCol7o1R6Q5m6eko4IIdxmdkK64tYznMGJEgq X-Received: by 2002:a17:902:9688:: with SMTP id n8-v6mr17719179plp.366.1524412292884; Sun, 22 Apr 2018 08:51:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524412292; cv=none; d=google.com; s=arc-20160816; b=YFSkNMRu7qhkr7Xp0eUXOl+Xvr4aEFVYyQ6irw1oeX36vJiFtbb0xv9gJV34Pdkr2g xIPLpOSytAhVNJcYZEAxC297WM9HGpmmPzcWrwGlw7GOhi62NRRwQYBwwkrCRXMZnxf6 AY93CDA3u87U6qjynSvnvF1xkm3pz+/yusXul2yJmWvY+m9r0tiO/qe3xhg0PIdyw/85 NMNXdAVTwufeoK5t+VI0p54Z7dTMOCXTY0eK1rBNzgZTN6VXJid0NDhtq3YPnf31fptV YEsCxhAKo0nbywIGGFtfabhCwX0fJYiNyZ6Pa54GA2xLfyZ7XhhzYL1dOM/vVeKLxKmo pAuQ== 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=T2dv/fGe84mSUwMuGrO5PaR0JlUHjuesn5uhZNitj6s=; b=HynXGKzCgE1xlTATTS93O0JjvxYQEdkOF8Pm8z3UO5Ee2fRnLqS0Zo8QBvFKNx8/vk uWeqkaCNiuDtaRHR+b7sVaGgrTMFiig4NBsMgoGa99SzFIDxKGOW9p9GsbvLLQ/ydFs9 1Nw0UIb0NCH7wp5kLHG+v6gGRHhheo+TmhRfyRD73kke6IMcP0tBfhe14ji67WOmppjp xKsbK4cpblV7FoX5vhqiNatLLFacm2fMNt7TRux2Rn9DqvsjW1Zjq/y5792ETuov0WtW PT2NDze6wgsujQ/Tv6juuRJcX6avtamOSpxI+2htcQ88wPhZTeFACIL2N/kl8WqWG+IU dSIw== 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 w4-v6si8638987plp.130.2018.04.22.08.51.18; Sun, 22 Apr 2018 08:51:32 -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 S1754891AbeDVPt2 (ORCPT + 99 others); Sun, 22 Apr 2018 11:49:28 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47954 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754483AbeDVOBZ (ORCPT ); Sun, 22 Apr 2018 10:01:25 -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 29506C9B; Sun, 22 Apr 2018 14:01:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Krzysztof Rusocki , Dan Williams Subject: [PATCH 4.16 122/196] libnvdimm, dimm: fix dpa reservation vs uninitialized label area Date: Sun, 22 Apr 2018 15:52:22 +0200 Message-Id: <20180422135110.562601461@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 c31898c8c711f2bbbcaebe802a55827e288d875a upstream. At initialization time the 'dimm' driver caches a copy of the memory device's label area and reserves address space for each of the namespaces defined. However, as can be seen below, the reservation occurs even when the index blocks are invalid: nvdimm nmem0: nvdimm_init_config_data: len: 131072 rc: 0 nvdimm nmem0: config data size: 131072 nvdimm nmem0: __nd_label_validate: nsindex0 labelsize 1 invalid nvdimm nmem0: __nd_label_validate: nsindex1 labelsize 1 invalid nvdimm nmem0: : pmem-6025e505: 0x1000000000 @ 0xf50000000 reserve <-- bad Gate dpa reservation on the presence of valid index blocks. Cc: Fixes: 4a826c83db4e ("libnvdimm: namespace indices: read and validate") Reported-by: Krzysztof Rusocki Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- drivers/nvdimm/dimm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/nvdimm/dimm.c +++ b/drivers/nvdimm/dimm.c @@ -67,9 +67,11 @@ static int nvdimm_probe(struct device *d ndd->ns_next = nd_label_next_nsindex(ndd->ns_current); nd_label_copy(ndd, to_next_namespace_index(ndd), to_current_namespace_index(ndd)); - rc = nd_label_reserve_dpa(ndd); - if (ndd->ns_current >= 0) - nvdimm_set_aliasing(dev); + if (ndd->ns_current >= 0) { + rc = nd_label_reserve_dpa(ndd); + if (rc == 0) + nvdimm_set_aliasing(dev); + } nvdimm_clear_locked(dev); nvdimm_bus_unlock(dev);