Blob Blame History Raw
From bb7bf697fed58eae9d3445944e457ab0de4da54f Mon Sep 17 00:00:00 2001
From: Dan Williams <dan.j.williams@intel.com>
Date: Thu, 28 Apr 2022 15:47:46 -0700
Subject: [PATCH] nvdimm: Allow overwrite in the presence of disabled dimms
Git-commit: bb7bf697fed58eae9d3445944e457ab0de4da54f
Patch-mainline: v5.19-rc1
References: git-fixes

It is not clear why the original implementation of overwrite support
required the dimm driver to be active before overwrite could proceed. In
fact that can lead to cases where the kernel retains an invalid cached
copy of the labels from before the overwrite. Unfortunately the kernel
has not only allowed that case, but enforced it.

Going forward, allow for overwrite to happen while the label area is
offline, and follow-on with updates to 'ndctl sanitize-dimm --overwrite'
to trigger the label area invalidation by default.

(Coly Li: refreshed for Linux 4.12 based SUSE kernel)

Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Jeff Moyer <jmoyer@redhat.com>
Reported-by: Krzysztof Kensicki <krzysztof.kensicki@intel.com>
Fixes: 7d988097c546 ("acpi/nfit, libnvdimm/security: Add security DSM overwrite support")
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Coly Li <colyli@suse.de>

---
 drivers/nvdimm/security.c |    5 -----
 1 file changed, 5 deletions(-)

--- a/drivers/nvdimm/security.c
+++ b/drivers/nvdimm/security.c
@@ -389,11 +389,6 @@ int nvdimm_security_overwrite(struct nvd
 		return -EBUSY;
 	}
 
-	if (dev->driver == NULL) {
-		dev_dbg(dev, "Unable to overwrite while DIMM active.\n");
-		return -EINVAL;
-	}
-
 	rc = check_security_state(nvdimm);
 	if (rc)
 		return rc;