]> Git Repo - linux.git/commitdiff
libnvdimm/security: ensure sysfs poll thread woke up and fetch updated attr
authorJane Chu <[email protected]>
Mon, 3 Aug 2020 22:41:39 +0000 (16:41 -0600)
committerVishal Verma <[email protected]>
Tue, 4 Aug 2020 00:54:13 +0000 (18:54 -0600)
commit 7d988097c546 ("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: 7d988097c546 ("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]>
drivers/nvdimm/security.c

index acfd211c01b9c5094cd0616c8550e64fb37e4211..35d265014e1ec96c193bb302f9c94437e0c63a6e 100644 (file)
@@ -450,14 +450,19 @@ void __nvdimm_security_overwrite_query(struct nvdimm *nvdimm)
        else
                dev_dbg(&nvdimm->dev, "overwrite completed\n");
 
-       if (nvdimm->sec.overwrite_state)
-               sysfs_notify_dirent(nvdimm->sec.overwrite_state);
+       /*
+        * Mark the overwrite work done and update dimm security flags,
+        * then send a sysfs event notification to wake up userspace
+        * poll threads to picked up the changed state.
+        */
        nvdimm->sec.overwrite_tmo = 0;
        clear_bit(NDD_SECURITY_OVERWRITE, &nvdimm->flags);
        clear_bit(NDD_WORK_PENDING, &nvdimm->flags);
-       put_device(&nvdimm->dev);
        nvdimm->sec.flags = nvdimm_security_flags(nvdimm, NVDIMM_USER);
        nvdimm->sec.ext_flags = nvdimm_security_flags(nvdimm, NVDIMM_MASTER);
+       if (nvdimm->sec.overwrite_state)
+               sysfs_notify_dirent(nvdimm->sec.overwrite_state);
+       put_device(&nvdimm->dev);
 }
 
 void nvdimm_security_overwrite_query(struct work_struct *work)
This page took 0.057655 seconds and 4 git commands to generate.