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: <75456867-8993-4be4-bcdf-14df28fe92cc@linux.intel.com>
Date: Tue, 7 Jan 2025 13:54:00 +0800
From: Baolu Lu <baolu.lu@...ux.intel.com>
To: Nicolin Chen <nicolinc@...dia.com>
Cc: jgg@...dia.com, kevin.tian@...el.com, corbet@....net, will@...nel.org,
 joro@...tes.org, suravee.suthikulpanit@....com, robin.murphy@....com,
 dwmw2@...radead.org, shuah@...nel.org, linux-kernel@...r.kernel.org,
 iommu@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org,
 linux-kselftest@...r.kernel.org, linux-doc@...r.kernel.org,
 eric.auger@...hat.com, jean-philippe@...aro.org, mdf@...nel.org,
 mshavit@...gle.com, shameerali.kolothum.thodi@...wei.com,
 smostafa@...gle.com, ddutile@...hat.com, yi.l.liu@...el.com,
 patches@...ts.linux.dev
Subject: Re: [PATCH v4 14/14] iommu/arm-smmu-v3: Report events that belong to
 devices attached to vIOMMU

On 1/7/25 12:36, Nicolin Chen wrote:
> On Mon, Jan 06, 2025 at 10:46:21AM -0800, Nicolin Chen wrote:
>> On Mon, Jan 06, 2025 at 11:01:32AM +0800, Baolu Lu wrote:
>>> Nit: I think it would be more readable to add a check in the vevent
>>> reporting helper.
>>>
>>> diff --git a/drivers/iommu/iommufd/driver.c b/drivers/iommu/iommufd/driver.c
>>> index 77c34f8791ef..ccada0ada5ff 100644
>>> --- a/drivers/iommu/iommufd/driver.c
>>> +++ b/drivers/iommu/iommufd/driver.c
>>> @@ -86,6 +86,9 @@ int iommufd_viommu_report_event(struct iommufd_viommu
>>> *viommu,
>>>          if (WARN_ON_ONCE(!data_len || !event_data))
>>>                  return -EINVAL;
>>>
>>> +       if (WARN_ON_ONCE(type != IOMMU_VEVENTQ_TYPE_ARM_SMMUV3))
>>> +               return -EINVAL;
>>> +
>> Hmm, that's a good point I think.
>>
>>>          down_read(&viommu->veventqs_rwsem);
>>>
>>>          veventq = iommufd_viommu_find_veventq(viommu, type);
>> 		    ^
>> 		    |
>> We actually have been missing a type validation entirely, so the
>> type could have been rejected by this function. Perhaps we should
>> add a static list of supported types to struct iommufd_viommu_ops
>> for drivers to report so that then the core could reject from the
>> first place during a vEVENTQ allocation.
> I added something like this. Will send a v5.
> 
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c
> index 0c7a5894ba07..348179f3cf2a 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c
> @@ -399,9 +399,15 @@ static int arm_vsmmu_cache_invalidate(struct iommufd_viommu *viommu,
>   	return ret;
>   }
>   
> +static bool arm_vsmmu_supports_veventq(unsigned int type)
> +{
> +	return type == IOMMU_VIOMMU_TYPE_ARM_SMMUV3;

Do you need to check the hardware capabilities before reporting this? I
am not familiar with the ARM architecture, but typically it's better to
make it like this,

static bool arm_vsmmu_supports_veventq(struct iommufd_viommu *viommu,
                                        enum iommu_veventq_type type)
{
	if (type != IOMMU_VEVENTQ_TYPE_ARM_SMMUV3)
		return false;

	if (hardware_not_capable(viommu))
		return false;

	return true;
}

> +}
> +
>   static const struct iommufd_viommu_ops arm_vsmmu_ops = {
>   	.alloc_domain_nested = arm_vsmmu_alloc_domain_nested,
>   	.cache_invalidate = arm_vsmmu_cache_invalidate,
> +	.supports_veventq = arm_vsmmu_supports_veventq,
>   };

Others look good to me.

Thanks,
baolu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ