linux-nvdimm.lists.01.org archive mirror
 help / color / mirror / Atom feed
From: Dave Jiang <dave.jiang@intel.com>
To: Jane Chu <jane.chu@oracle.com>,
	dan.j.williams@intel.com, vishal.l.verma@intel.com,
	ira.weiny@intel.com, jmoyer@redhat.com,
	linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] libnvdimm/security: ensure sysfs poll thread woke up and fetch updated attr
Date: Mon, 3 Aug 2020 13:42:08 -0700	[thread overview]
Message-ID: <b9957db2-c130-f2ae-14a1-e711a98c7c69@intel.com> (raw)
In-Reply-To: <1595606959-8516-2-git-send-email-jane.chu@oracle.com>



On 7/24/2020 9:09 AM, Jane Chu wrote:
> 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.
> 
> Cc: Dave Jiang <dave.jiang@intel.com>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Fixes: 7d988097c546 ("acpi/nfit, libnvdimm/security: Add security DSM overwrite support")
> Signed-off-by: Jane Chu <jane.chu@oracle.com>

Reviewed-by: Dave Jiang <dave.jiang@intel.com>

> ---
>   drivers/nvdimm/security.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/nvdimm/security.c b/drivers/nvdimm/security.c
> index 8f3971c..4b80150 100644
> --- a/drivers/nvdimm/security.c
> +++ b/drivers/nvdimm/security.c
> @@ -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)
> 
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

  reply	other threads:[~2020-08-03 20:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-24 16:09 [PATCH 1/2] libnvdimm/security: 'security' attr never show 'overwrite' state Jane Chu
2020-07-24 16:09 ` [PATCH 2/2] libnvdimm/security: ensure sysfs poll thread woke up and fetch updated attr Jane Chu
2020-08-03 20:42   ` Dave Jiang [this message]
2020-08-03 17:51 ` [PATCH 1/2] libnvdimm/security: 'security' attr never show 'overwrite' state Jane Chu
2020-08-03 20:41 ` Dave Jiang
2020-08-03 21:10   ` Jane Chu
2020-08-03 21:26     ` Dave Jiang
  -- strict thread matches above, loose matches on Subject: below --
2020-07-24  4:10 [PATCH 2/2] libnvdimm/security: ensure sysfs poll thread woke up and fetch updated attr Jane Chu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b9957db2-c130-f2ae-14a1-e711a98c7c69@intel.com \
    --to=dave.jiang@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=jane.chu@oracle.com \
    --cc=jmoyer@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvdimm@lists.01.org \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).