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-next>] [day] [month] [year] [list]
Date:	Wed, 20 Jul 2016 20:49:21 +0800
From:	<honghui.zhang@...iatek.com>
To:	<joro@...tes.org>, <treding@...dia.com>, <mark.rutland@....com>,
	<matthias.bgg@...il.com>, <robh@...nel.org>, <robin.murphy@....com>
CC:	<p.zabel@...gutronix.de>, <devicetree@...r.kernel.org>,
	<pebolle@...cali.nl>, <kendrick.hsu@...iatek.com>, <arnd@...db.de>,
	<srv_heupstream@...iatek.com>, <catalin.marinas@....com>,
	<will.deacon@....com>, <linux-kernel@...r.kernel.org>,
	<tfiga@...gle.com>, <iommu@...ts.linux-foundation.org>,
	<robh+dt@...nel.org>, <djkurtz@...gle.com>,
	<kernel@...gutronix.de>, <linux-mediatek@...ts.infradead.org>,
	<linux-arm-kernel@...ts.infradead.org>, <l.stach@...gutronix.de>,
	<yingjoe.chen@...iatek.com>, <eddie.huang@...iatek.com>,
	<youlin.pei@...iatek.com>, <erin.lo@...iatek.com>,
	Honghui Zhang <honghui.zhang@...iatek.com>
Subject: [RFC PATCH] iommu: create direct_mapping after device attached

From: Honghui Zhang <honghui.zhang@...iatek.com>

For mtk iommu, the domain_finalize was called in device attatch, the mtk
iommu iopgt ops was allocated and initialized in domain_finalize, the
iommu_group_create_direct_mappings would call the map interface to
implement the map. If it's earlier than device attach, there would be NULL
dereference. Move the iommu_group_create_direct_mappings call after device
attached.

Signed-off-by: Honghui Zhang <honghui.zhang@...iatek.com>
---
 drivers/iommu/iommu.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 3000051..24c671c 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -427,14 +427,19 @@ rename:
 
 	dev->iommu_group = group;
 
-	iommu_group_create_direct_mappings(group, dev);
-
 	mutex_lock(&group->mutex);
 	list_add_tail(&device->list, &group->devices);
 	if (group->domain)
 		__iommu_attach_device(group->domain, dev);
 	mutex_unlock(&group->mutex);
 
+	/*
+	 * For some iommu driver like mtk iommu, the map callback was assigned
+	 * after device attached. The direct_mappings would call iommu map and
+	 * dereference NULL if it's called earlier than attach_device.
+	 */
+	iommu_group_create_direct_mappings(group, dev);
+
 	/* Notify any listeners about change to group. */
 	blocking_notifier_call_chain(&group->notifier,
 				     IOMMU_GROUP_NOTIFY_ADD_DEVICE, dev);
-- 
1.8.1.1.dirty

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ