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: <Zdj4y7nqF2LHq2IH@Asurada-Nvidia>
Date: Fri, 23 Feb 2024 11:58:03 -0800
From: Nicolin Chen <nicolinc@...dia.com>
To: Will Deacon <will@...nel.org>, Michael Kelley <mhklinux@...look.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"kernel-team@...roid.com" <kernel-team@...roid.com>, "iommu@...ts.linux.dev"
	<iommu@...ts.linux.dev>, Christoph Hellwig <hch@....de>, Marek Szyprowski
	<m.szyprowski@...sung.com>, Robin Murphy <robin.murphy@....com>, Petr Tesarik
	<petr.tesarik1@...wei-partners.com>, Dexuan Cui <decui@...rosoft.com>
Subject: Re: [PATCH v4 5/5] iommu/dma: Force swiotlb_max_mapping_size on an
 untrusted device

On Wed, Feb 21, 2024 at 11:39:29PM +0000, Michael Kelley wrote:
> From: Will Deacon <will@...nel.org> Sent: Wednesday, February 21, 2024 3:35 AM
> > +static size_t iommu_dma_max_mapping_size(struct device *dev)
> > +{
> > +     if (is_swiotlb_active(dev) && dev_is_untrusted(dev))
> > +             return swiotlb_max_mapping_size(dev);
> > +     return SIZE_MAX;
> > +}
> > +
> 
> In this [1] email, Nicolin had a version of this function that incorporated
> the IOMMU granule.  For granules bigger than 4K, I think that's needed
> so that when IOMMU code sets the swiotlb alloc_align_mask to the
> IOMMU granule - 1, the larger offset plus the size won't exceed the
> max number of slots.  swiotlb_max_mapping_size() by itself may
> return a value that's too big when alloc_align_mask is used.
> 
> Michael
> 
> [1] https://lore.kernel.org/linux-iommu/SN6PR02MB415727E61B5295C259CCB268D4512@SN6PR02MB4157.namprd02.prod.outlook.com/T/#m14dd359c5a4dd13e6cb0c35cf94f8d746257ae48

Yea, I just confirmed that with 64KB PAGE_SIZE the alloc_size
can be over swiotlb_max_mapping_size, i.e. 256KB > 252KB. Yet,
the max size corresponding to the max number of slots should
be 256KB. So, I feel that this is marginally safe?

With that being said, there seems to be a 4KB size waste, due
to aligning with the iommu_domain granule, in this particular
alloc_size=256KB case?

On the other hand, if swiotlb_max_mapping_size was subtracted
by 64KB (granule=64KB), i.e. alloc_size=192KB, which seems to
generate more swiotlb fragments?

Thanks
Nicolin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ