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:	Wed, 13 May 2015 16:06:47 +1000
From:	Gavin Shan <gwshan@...ux.vnet.ibm.com>
To:	Alexey Kardashevskiy <aik@...abs.ru>
Cc:	linuxppc-dev@...ts.ozlabs.org,
	David Gibson <david@...son.dropbear.id.au>,
	Benjamin Herrenschmidt <benh@...nel.crashing.org>,
	Paul Mackerras <paulus@...ba.org>,
	Alex Williamson <alex.williamson@...hat.com>,
	Gavin Shan <gwshan@...ux.vnet.ibm.com>,
	Wei Yang <weiyang@...ux.vnet.ibm.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH kernel v10 07/34] vfio: powerpc/spapr: Check that IOMMU
 page is fully contained by system page

On Tue, May 12, 2015 at 01:38:56AM +1000, Alexey Kardashevskiy wrote:
>This checks that the TCE table page size is not bigger that the size of
>a page we just pinned and going to put its physical address to the table.
>
>Otherwise the hardware gets unwanted access to physical memory between
>the end of the actual page and the end of the aligned up TCE page.
>
>Since compound_order() and compound_head() work correctly on non-huge
>pages, there is no need for additional check whether the page is huge.
>
>Signed-off-by: Alexey Kardashevskiy <aik@...abs.ru>
>[aw: for the vfio related changes]
>Acked-by: Alex Williamson <alex.williamson@...hat.com>
>Reviewed-by: David Gibson <david@...son.dropbear.id.au>

Reviewed-by: Gavin Shan <gwshan@...ux.vnet.ibm.com>

Thanks,
Gavin

>---
>Changes:
>v8: changed subject
>
>v6:
>* the helper is simplified to one line
>
>v4:
>* s/tce_check_page_size/tce_page_is_contained/
>---
> drivers/vfio/vfio_iommu_spapr_tce.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
>diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c
>index b95fa2b..735b308 100644
>--- a/drivers/vfio/vfio_iommu_spapr_tce.c
>+++ b/drivers/vfio/vfio_iommu_spapr_tce.c
>@@ -47,6 +47,16 @@ struct tce_container {
> 	bool enabled;
> };
>
>+static bool tce_page_is_contained(struct page *page, unsigned page_shift)
>+{
>+	/*
>+	 * Check that the TCE table granularity is not bigger than the size of
>+	 * a page we just found. Otherwise the hardware can get access to
>+	 * a bigger memory chunk that it should.
>+	 */
>+	return (PAGE_SHIFT + compound_order(compound_head(page))) >= page_shift;
>+}
>+
> static int tce_iommu_enable(struct tce_container *container)
> {
> 	int ret = 0;
>@@ -189,6 +199,12 @@ static long tce_iommu_build(struct tce_container *container,
> 			ret = -EFAULT;
> 			break;
> 		}
>+
>+		if (!tce_page_is_contained(page, tbl->it_page_shift)) {
>+			ret = -EPERM;
>+			break;
>+		}
>+
> 		hva = (unsigned long) page_address(page) + offset;
>
> 		ret = iommu_tce_build(tbl, entry + i, hva, direction);
>-- 
>2.4.0.rc3.8.gfb3e7d5
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ