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]
Message-ID: <5d056fea-ee52-b7f8-a8c1-095f695ac805@arm.com>
Date:   Fri, 15 Jul 2022 10:28:48 +0100
From:   Robin Murphy <robin.murphy@....com>
To:     Joerg Roedel <joro@...tes.org>,
        Yang Yingliang <yangyingliang@...wei.com>
Cc:     linux-kernel@...r.kernel.org, iommu@...ts.linux.dev,
        iommu@...ts.linux-foundation.org, will@...nel.org,
        yf.wang@...iatek.com
Subject: Re: [PATCH -next] iommu/dma: Fix missing mutex_init() in
 iommu_get_msi_cookie()

On 2022-07-15 08:49, Joerg Roedel wrote:
> Adding Robin.
> 
> On Mon, Jun 27, 2022 at 04:55:33PM +0800, Yang Yingliang wrote:
>> cookie_alloc() is called by iommu_get_dma_cookie() and iommu_get_msi_cookie(),
>> but the mutex is only initialized in iommu_get_dma_cookie(), move mutex_init()
>> into cookie_alloc() to make sure the mutex will be initialized.

The mutex is only used in iommu_dma_init_domain(), which is only called 
by iommu_setup_dma_ops() for IOMMU_DOMAIN_DMA domains. How is there a 
problem here?

Robin.

>> Fixes: ac9a5d522bb8 ("iommu/dma: Fix race condition during iova_domain initialization")
>> Reported-by: Hulk Robot <hulkci@...wei.com>
>> Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
>> ---
>>   drivers/iommu/dma-iommu.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
>> index 1910f4f1612b..e29157380c48 100644
>> --- a/drivers/iommu/dma-iommu.c
>> +++ b/drivers/iommu/dma-iommu.c
>> @@ -294,6 +294,7 @@ static struct iommu_dma_cookie *cookie_alloc(enum iommu_dma_cookie_type type)
>>   	if (cookie) {
>>   		INIT_LIST_HEAD(&cookie->msi_page_list);
>>   		cookie->type = type;
>> +		mutex_init(&cookie->mutex);
>>   	}
>>   	return cookie;
>>   }
>> @@ -311,7 +312,6 @@ int iommu_get_dma_cookie(struct iommu_domain *domain)
>>   	if (!domain->iova_cookie)
>>   		return -ENOMEM;
>>   
>> -	mutex_init(&domain->iova_cookie->mutex);
>>   	return 0;
>>   }
>>   
>> -- 
>> 2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ