Linux IOMMU Development
 help / color / mirror / Atom feed
From: Lu Baolu <baolu.lu@linux.intel.com>
To: Torsten Hilbrich <torsten.hilbrich@secunet.com>,
	Joerg Roedel <jroedel@suse.de>
Cc: iommu@lists.linux-foundation.org
Subject: Re: [Regression] [PATCH] iommu: Avoid crash in init_no_remapping_devices if iommu is NULL
Date: Wed, 2 Sep 2020 10:45:08 +0800	[thread overview]
Message-ID: <175fe2a7-922e-1800-298e-1481b648c6d8@linux.intel.com> (raw)
In-Reply-To: <1eafacd8-8cdb-d6ae-130c-dca66dbe3598@secunet.com>

hi Torsten,

On 9/1/20 10:41 PM, Torsten Hilbrich wrote:
> On 01.09.20 04:02, Lu Baolu wrote:
> [...]
>> This looks more like a generic issue, used-before-allocated, and should
>> be fixed in iommu.c instead of VT-d driver. How about
>>
>> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
>> index 8fd93a5b8764..a599da87eb60 100644
>> --- a/drivers/iommu/iommu.c
>> +++ b/drivers/iommu/iommu.c
>> @@ -190,6 +190,28 @@ static void dev_iommu_free(struct device *dev)
>>          dev->iommu = NULL;
>>   }
>>
>> +void *dev_iommu_priv_get(struct device *dev)
>> +{
>> +       struct dev_iommu *param = dev_iommu_get(dev);
>> +
>> +       if (WARN_ON(!param))
>> +               return ERR_PTR(-ENOMEM);
>> +
>> +        return param->priv;
>> +}
>> +EXPORT_SYMBOL_GPL(dev_iommu_priv_get);
>> +
>> +void dev_iommu_priv_set(struct device *dev, void *priv)
>> +{
>> +       struct dev_iommu *param = dev_iommu_get(dev);
>> +
>> +       if (WARN_ON(!param))
>> +               return;
>> +
>> +        param->priv = priv;
>> +}
>> +EXPORT_SYMBOL_GPL(dev_iommu_priv_set);
>> +
> 
> This fix would work in my case. I tested it with slight modification to
> replace the inline routines in include/linux/iommu.h.
> 
> The WARN_ON was not triggered during my tests. However, looking at the
> definition of dev_iommu_get this is to be expected.

So I suppose you will post a new version. :-)

Best regards,
baolu
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2020-09-02  2:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31 11:03 [Regression] [PATCH] iommu: Avoid crash in init_no_remapping_devices if iommu is NULL Torsten Hilbrich
2020-09-01  2:02 ` Lu Baolu
2020-09-01 14:41   ` Torsten Hilbrich
2020-09-02  2:45     ` Lu Baolu [this message]
2020-09-02  5:32       ` [PATCH] iommu: Allocate dev_iommu before accessing priv data Torsten Hilbrich
2020-09-02 11:31         ` Robin Murphy
2020-09-03  6:46           ` Lu Baolu
2020-09-02  2:45     ` [Regression] [PATCH] iommu: Avoid crash in init_no_remapping_devices if iommu is NULL Lu Baolu

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=175fe2a7-922e-1800-298e-1481b648c6d8@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jroedel@suse.de \
    --cc=torsten.hilbrich@secunet.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