lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 14 Jul 2023 14:00:07 +0800
From:   Baolu Lu <baolu.lu@...ux.intel.com>
To:     "Tian, Kevin" <kevin.tian@...el.com>,
        Jacob Pan <jacob.jun.pan@...ux.intel.com>,
        LKML <linux-kernel@...r.kernel.org>,
        "iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
        Joerg Roedel <joro@...tes.org>,
        Jean-Philippe Brucker <jean-philippe@...aro.com>,
        Robin Murphy <robin.murphy@....com>
Cc:     baolu.lu@...ux.intel.com, Jason Gunthorpe <jgg@...dia.com>,
        Will Deacon <will@...nel.org>,
        "Liu, Yi L" <yi.l.liu@...el.com>,
        "Yu, Fenghua" <fenghua.yu@...el.com>,
        "Luck, Tony" <tony.luck@...el.com>
Subject: Re: [PATCH v10 6/7] iommu/vt-d: Add set_dev_pasid callback for dma
 domain

On 2023/7/14 11:50, Tian, Kevin wrote:
>> From: Baolu Lu <baolu.lu@...ux.intel.com>
>> Sent: Friday, July 14, 2023 11:34 AM
>>
>> On 2023/7/13 15:56, Tian, Kevin wrote:
>>>> From: Jacob Pan <jacob.jun.pan@...ux.intel.com>
>>>> Sent: Thursday, July 13, 2023 12:34 AM
>>>>
>>>>
>>>> -	/*
>>>> -	 * Should never reach here until we add support for attaching
>>>> -	 * non-SVA domain to a pasid.
>>>> -	 */
>>>> -	WARN_ON(1);
>>>> +	dmar_domain = to_dmar_domain(domain);
>>>> +	spin_lock_irqsave(&dmar_domain->lock, flags);
>>>> +	list_for_each_entry(curr, &dmar_domain->dev_pasids, link_domain)
>>>> {
>>>> +		if (curr->dev == dev && curr->pasid == pasid) {
>>>> +			list_del(&curr->link_domain);
>>>> +			dev_pasid = curr;
>>>> +			break;
>>>> +		}
>>>> +	}
>>>> +	spin_unlock_irqrestore(&dmar_domain->lock, flags);
>>>>
>>>
>>> what about no matching dev_pasid is find?
>>
>> kfree() can handle this gracefully.
> 
> but what about domain_detach_iommu()? Is it correct to adjust
> the refcnting when there is no matching dev_pasid?

You are right.

Logically, if we get a valid domain for a pasid, we should have a
dev_pasid allocated for it. Perhaps, adding a check in the code will
make the code more readable?

Best regards,
baolu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ