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: <Zr5coJScB7AM76Wi@Asurada-Nvidia>
Date: Thu, 15 Aug 2024 12:53:04 -0700
From: Nicolin Chen <nicolinc@...dia.com>
To: Jason Gunthorpe <jgg@...dia.com>
CC: <kevin.tian@...el.com>, <will@...nel.org>, <joro@...tes.org>,
	<suravee.suthikulpanit@....com>, <robin.murphy@....com>,
	<dwmw2@...radead.org>, <baolu.lu@...ux.intel.com>, <shuah@...nel.org>,
	<linux-kernel@...r.kernel.org>, <iommu@...ts.linux.dev>,
	<linux-arm-kernel@...ts.infradead.org>, <linux-kselftest@...r.kernel.org>
Subject: Re: [PATCH v1 05/16] iommufd/viommu: Add
 IOMMU_VIOMMU_SET/UNSET_VDEV_ID ioctl

On Thu, Aug 15, 2024 at 12:46:29PM -0700, Nicolin Chen wrote:
> > > +static struct device *
> > > +iommufd_viommu_find_device(struct iommufd_viommu *viommu, u64 id)
> > > +{
> > > +	struct iommufd_vdev_id *vdev_id;
> > > +
> > > +	xa_lock(&viommu->vdev_ids);
> > > +	vdev_id = xa_load(&viommu->vdev_ids, (unsigned long)id);
> > > +	xa_unlock(&viommu->vdev_ids);
> > 
> > This lock doesn't do anything
> > 
> > > +	if (!vdev_id || vdev_id->vdev_id != id)
> > > +		return NULL;
> > 
> > And this is unlocked
> > 
> > > +	return vdev_id->dev;
> > > +}
> > 
> > This isn't good.. We can't return the struct device pointer here as
> > there is no locking for it anymore. We can't even know it is still
> > probed to VFIO anymore.
> > 
> > It has to work by having the iommu driver directly access the xarray
> > and the entirely under the spinlock the iommu driver can translate the
> > vSID to the pSID and the let go and push the invalidation to HW. No
> > races.
> 
> Maybe the iommufd_viommu_invalidate ioctl handler should hold that
> xa_lock around the viommu->ops->cache_invalidate, and then add lock
> assert in iommufd_viommu_find_device?

xa_lock/spinlock might be too heavy. We can have a mutex to wrap
around viommu ioctl handlers..

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ