iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Lu Baolu <baolu.lu@linux.intel.com>
To: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>,
	iommu@lists.linux-foundation.org
Cc: Ashok Raj <ashok.raj@intel.com>,
	Will Deacon <will.deacon@arm.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH V4 2/3] iommu: Take lock before reading iommu group default domain type
Date: Mon, 8 Jun 2020 09:50:17 +0800	[thread overview]
Message-ID: <106b9809-0cb1-77c7-61c0-c870ed6abf16@linux.intel.com> (raw)
In-Reply-To: <379b0d7307bb76699e2438a21f6c8259a7538ef7.1591290586.git.sai.praneeth.prakhya@intel.com>

On 6/5/20 9:32 AM, Sai Praneeth Prakhya wrote:
> "/sys/kernel/iommu_groups/<grp_id>/type" file could be read to find out the
> default domain type of an iommu group. The default domain of an iommu group
> doesn't change after booting and hence could be read directly. But,
> after addding support to dynamically change iommu group default domain, the
> above assumption no longer stays valid.
> 
> iommu group default domain type could be changed at any time by writing to
> "/sys/kernel/iommu_groups/<grp_id>/type". So, take group mutex before
> reading iommu group default domain type so that the user wouldn't see stale
> values or iommu_group_show_type() doesn't try to derefernce stale pointers.
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: Ashok Raj <ashok.raj@intel.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Lu Baolu <baolu.lu@linux.intel.com>

Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>

Best regards,
baolu

> Cc: Sohil Mehta <sohil.mehta@intel.com>
> Cc: Robin Murphy <robin.murphy@arm.com>
> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Signed-off-by: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
> ---
>   drivers/iommu/iommu.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index b023f06f12d6..eb133ee5c13a 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -501,6 +501,7 @@ static ssize_t iommu_group_show_type(struct iommu_group *group,
>   {
>   	char *type = "unknown\n";
>   
> +	mutex_lock(&group->mutex);
>   	if (group->default_domain) {
>   		switch (group->default_domain->type) {
>   		case IOMMU_DOMAIN_BLOCKED:
> @@ -517,6 +518,7 @@ static ssize_t iommu_group_show_type(struct iommu_group *group,
>   			break;
>   		}
>   	}
> +	mutex_unlock(&group->mutex);
>   	strcpy(buf, type);
>   
>   	return strlen(type);
> 
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2020-06-08  1:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05  1:32 [PATCH V4 0/3] iommu: Add support to change default domain of an iommu group Sai Praneeth Prakhya
2020-06-05  1:32 ` [PATCH V4 1/3] " Sai Praneeth Prakhya
2020-06-08  1:49   ` Lu Baolu
2020-06-30  9:16   ` Joerg Roedel
2020-07-01  3:04     ` Prakhya, Sai Praneeth
2020-07-14 18:23       ` Prakhya, Sai Praneeth
2020-07-22 13:52         ` Joerg Roedel
2020-07-22 17:14           ` Prakhya, Sai Praneeth
2020-06-05  1:32 ` [PATCH V4 2/3] iommu: Take lock before reading iommu group default domain type Sai Praneeth Prakhya
2020-06-08  1:50   ` Lu Baolu [this message]
2020-06-05  1:32 ` [PATCH V4 3/3] iommu: Document usage of "/sys/kernel/iommu_groups/<grp_id>/type" file Sai Praneeth Prakhya
2020-06-08  1:50   ` Lu Baolu
2020-06-26 21:34 ` [PATCH V4 0/3] iommu: Add support to change default domain of an iommu group Prakhya, Sai Praneeth

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=106b9809-0cb1-77c7-61c0-c870ed6abf16@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=ashok.raj@intel.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=robin.murphy@arm.com \
    --cc=sai.praneeth.prakhya@intel.com \
    --cc=will.deacon@arm.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).