Skip to content

Commit 7c02d53

Browse files
jchu314atgithubstellarhopper
authored andcommitted
libnvdimm/security: the 'security' attr never show 'overwrite' state
'security' attribute displays the security state of an nvdimm. During normal operation, the nvdimm state maybe one of 'disabled', 'unlocked' or 'locked'. When an admin issues # ndctl sanitize-dimm nmem0 --overwrite the attribute is expected to change to 'overwrite' until the overwrite operation completes. But tests on our systems show that 'overwrite' is never shown during the overwrite operation. i.e. # cat /sys/devices/LNXSYSTM:00/LNXSYBUS:00/ACPI0012:00/ndbus0/nmem0/security unlocked the attribute remain 'unlocked' through out the operation, consequently "ndctl wait-overwrite nmem0" command doesn't wait at all. The driver tracks the state in 'nvdimm->sec.flags': when the operation starts, it adds an overwrite bit to the flags; and when the operation completes, it removes the bit. Hence security_show() should check the 'overwrite' bit first, in order to indicate the actual state when multiple bits are set in the flags. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Dave Jiang <[email protected]> Signed-off-by: Jane Chu <[email protected]> Signed-off-by: Vishal Verma <[email protected]>
1 parent dad42d1 commit 7c02d53

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/nvdimm/dimm_devs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,14 +363,14 @@ __weak ssize_t security_show(struct device *dev,
363363
{
364364
struct nvdimm *nvdimm = to_nvdimm(dev);
365365

366+
if (test_bit(NVDIMM_SECURITY_OVERWRITE, &nvdimm->sec.flags))
367+
return sprintf(buf, "overwrite\n");
366368
if (test_bit(NVDIMM_SECURITY_DISABLED, &nvdimm->sec.flags))
367369
return sprintf(buf, "disabled\n");
368370
if (test_bit(NVDIMM_SECURITY_UNLOCKED, &nvdimm->sec.flags))
369371
return sprintf(buf, "unlocked\n");
370372
if (test_bit(NVDIMM_SECURITY_LOCKED, &nvdimm->sec.flags))
371373
return sprintf(buf, "locked\n");
372-
if (test_bit(NVDIMM_SECURITY_OVERWRITE, &nvdimm->sec.flags))
373-
return sprintf(buf, "overwrite\n");
374374
return -ENOTTY;
375375
}
376376

0 commit comments

Comments
 (0)