Skip to content

Commit 7f67402

Browse files
jchu314atgithubstellarhopper
authored andcommitted
libnvdimm/security: ensure sysfs poll thread woke up and fetch updated attr
commit 7d98809 ("acpi/nfit, libnvdimm/security: Add security DSM overwrite support") adds a sysfs_notify_dirent() to wake up userspace poll thread when the "overwrite" operation has completed. But the notification is issued before the internal dimm security state and flags have been updated, so the userspace poll thread wakes up and fetches the not-yet-updated attr and falls back to sleep, forever. But if user from another terminal issue "ndctl wait-overwrite nmemX" again, the command returns instantly. Link: https://lore.kernel.org/r/[email protected] Fixes: 7d98809 ("acpi/nfit, libnvdimm/security: Add security DSM overwrite support") Cc: Dave Jiang <[email protected]> Cc: Dan Williams <[email protected]> Reviewed-by: Dave Jiang <[email protected]> Signed-off-by: Jane Chu <[email protected]> Signed-off-by: Vishal Verma <[email protected]>
1 parent 7c02d53 commit 7f67402

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/nvdimm/security.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,14 +450,19 @@ void __nvdimm_security_overwrite_query(struct nvdimm *nvdimm)
450450
else
451451
dev_dbg(&nvdimm->dev, "overwrite completed\n");
452452

453-
if (nvdimm->sec.overwrite_state)
454-
sysfs_notify_dirent(nvdimm->sec.overwrite_state);
453+
/*
454+
* Mark the overwrite work done and update dimm security flags,
455+
* then send a sysfs event notification to wake up userspace
456+
* poll threads to picked up the changed state.
457+
*/
455458
nvdimm->sec.overwrite_tmo = 0;
456459
clear_bit(NDD_SECURITY_OVERWRITE, &nvdimm->flags);
457460
clear_bit(NDD_WORK_PENDING, &nvdimm->flags);
458-
put_device(&nvdimm->dev);
459461
nvdimm->sec.flags = nvdimm_security_flags(nvdimm, NVDIMM_USER);
460462
nvdimm->sec.ext_flags = nvdimm_security_flags(nvdimm, NVDIMM_MASTER);
463+
if (nvdimm->sec.overwrite_state)
464+
sysfs_notify_dirent(nvdimm->sec.overwrite_state);
465+
put_device(&nvdimm->dev);
461466
}
462467

463468
void nvdimm_security_overwrite_query(struct work_struct *work)

0 commit comments

Comments
 (0)