Received: by 10.192.165.148 with SMTP id m20csp2520915imm; Sun, 22 Apr 2018 08:45:19 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Pyz8P0Eot85smbCUAY/NtREXqkSTC78A0/1XGYYm+Cit0vmvrPU9we+/YNhUK/2GX3z8t X-Received: by 10.99.125.86 with SMTP id m22mr14963348pgn.257.1524411919353; Sun, 22 Apr 2018 08:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524411919; cv=none; d=google.com; s=arc-20160816; b=POdVPIVRZ6JDkEn88Pf9x5PDSGXeIxgXzUTkVNDiZIPk3zYV4LDkvNXDk6cn2hLuSH 4WXwVHtGaCcBPxqE5tj0kVIUyQjHSVgyh90DOCffv6vgDpvXUoJoyYT4bh81c/y8G/Bi 12pM2FzmOJ+oiCSIy1xeLlaWyzEPfUSatMNz5jXbIhdwE99wQubTUqZQFu3FoMxMO74h IXK3MLfw1gXrZ4mALf/AReRgHFQJn11wjGHmfmHtuBX4S8GeYPiLEvcJw3IdPSDTLUOJ hEhXU/0LzvE8XjMVhJ0mQo07uhaWAuW6G1DwYJ1GFEsk4eaXCmOJir32qRNIiChiRdlj emiQ== 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=3uJAgX7/ziS39aN2VtDuQkJeN1XilkDPym0bQn+KUmI=; b=GEsL/LG7LZ+6zaRw/Pxii/U/KFrNVNp4zWtjB28HTzf4Q2lyBiFXzv5Xc4Xj67+0oG cEroZOC8R6wTGYOZTkLIvmXQZ+fsf8imvdJxwP+HS2xrkf9p0h2Mo3RvQTf5mPWxxEnm PH6qqkfMGO87RzmGEBjpdyt6rPBqTlL3lmM+u8fiMy5htffK9rwJ7i9Y5GKC93yC/Rri 4I5ZCQH2CUTuWU73qCtnqXzXA/4blvSAVeiiKWtNRqdi/bshdqpp0VlIShOzWEc5Kbys 508XctcjMl2r+FOw5Cyd9bo0ulVklFFqWZOT0MA9kmFRAboqc6TdWQvCw+AkQZzZMlhd z5vQ== 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 d9si7419423pfm.226.2018.04.22.08.45.05; Sun, 22 Apr 2018 08:45:19 -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 S1754972AbeDVODD (ORCPT + 99 others); Sun, 22 Apr 2018 10:03:03 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48928 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754956AbeDVOC6 (ORCPT ); Sun, 22 Apr 2018 10:02:58 -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 603A5CEC; Sun, 22 Apr 2018 14:02:57 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Williams Subject: [PATCH 4.16 190/196] libnvdimm, dimm: handle EACCES failures from label reads Date: Sun, 22 Apr 2018 15:53:30 +0200 Message-Id: <20180422135114.075241881@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 e7c5a571a8d6a266aee9ca3f3f26e5afe3717eca upstream. The new support for the standard _LSR and _LSW methods neglected to also update the nvdimm_init_config_data() and nvdimm_set_config_data() to return the translated error code from failed commands. This precision is necessary because the locked status that was previously returned on ND_CMD_GET_CONFIG_SIZE commands is now returned on ND_CMD_{GET,SET}_CONFIG_DATA commands. If the kernel misses this indication it can inadvertently fall back to label-less mode when it should otherwise avoid all access to locked regions. Cc: Fixes: 4b27db7e26cd ("acpi, nfit: add support for the _LSI, _LSR, and...") Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- drivers/nvdimm/dimm_devs.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) --- a/drivers/nvdimm/dimm_devs.c +++ b/drivers/nvdimm/dimm_devs.c @@ -88,9 +88,9 @@ int nvdimm_init_nsarea(struct nvdimm_drv int nvdimm_init_config_data(struct nvdimm_drvdata *ndd) { struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(ndd->dev); + int rc = validate_dimm(ndd), cmd_rc = 0; struct nd_cmd_get_config_data_hdr *cmd; struct nvdimm_bus_descriptor *nd_desc; - int rc = validate_dimm(ndd); u32 max_cmd_size, config_size; size_t offset; @@ -124,9 +124,11 @@ int nvdimm_init_config_data(struct nvdim cmd->in_offset = offset; rc = nd_desc->ndctl(nd_desc, to_nvdimm(ndd->dev), ND_CMD_GET_CONFIG_DATA, cmd, - cmd->in_length + sizeof(*cmd), NULL); - if (rc || cmd->status) { - rc = -ENXIO; + cmd->in_length + sizeof(*cmd), &cmd_rc); + if (rc < 0) + break; + if (cmd_rc < 0) { + rc = cmd_rc; break; } memcpy(ndd->data + offset, cmd->out_buf, cmd->in_length); @@ -140,9 +142,9 @@ int nvdimm_init_config_data(struct nvdim int nvdimm_set_config_data(struct nvdimm_drvdata *ndd, size_t offset, void *buf, size_t len) { - int rc = validate_dimm(ndd); size_t max_cmd_size, buf_offset; struct nd_cmd_set_config_hdr *cmd; + int rc = validate_dimm(ndd), cmd_rc = 0; struct nvdimm_bus *nvdimm_bus = walk_to_nvdimm_bus(ndd->dev); struct nvdimm_bus_descriptor *nd_desc = nvdimm_bus->nd_desc; @@ -164,7 +166,6 @@ int nvdimm_set_config_data(struct nvdimm for (buf_offset = 0; len; len -= cmd->in_length, buf_offset += cmd->in_length) { size_t cmd_size; - u32 *status; cmd->in_offset = offset + buf_offset; cmd->in_length = min(max_cmd_size, len); @@ -172,12 +173,13 @@ int nvdimm_set_config_data(struct nvdimm /* status is output in the last 4-bytes of the command buffer */ cmd_size = sizeof(*cmd) + cmd->in_length + sizeof(u32); - status = ((void *) cmd) + cmd_size - sizeof(u32); rc = nd_desc->ndctl(nd_desc, to_nvdimm(ndd->dev), - ND_CMD_SET_CONFIG_DATA, cmd, cmd_size, NULL); - if (rc || *status) { - rc = rc ? rc : -ENXIO; + ND_CMD_SET_CONFIG_DATA, cmd, cmd_size, &cmd_rc); + if (rc < 0) + break; + if (cmd_rc < 0) { + rc = cmd_rc; break; } }