Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5580221img; Wed, 27 Mar 2019 11:05:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7U4eK/bibvU82pCunNizS6ffhaLV2zVhgWD+zFjcVf9r+w6x0BubM1QQeR7RxOJq4I7Xc X-Received: by 2002:a65:50cc:: with SMTP id s12mr35428681pgp.130.1553709907366; Wed, 27 Mar 2019 11:05:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553709907; cv=none; d=google.com; s=arc-20160816; b=r8YHoChaO+22WSsW3vNd36TTcUwUPaZlIRSgg2gxy7laGylqen2mJ4Z3eNoJnYAx93 U7Z76NrAqfy6/1YVhkJI4iPzVCX6gN1K5h5xDvFdtuTX7Ti3yhMGUiv/N3NON5u8krd0 dlaPcSNAKqn7uHbvx3Mf2/7wmSAyOJ04JC4aKqO9argdFrfBXOlmKlz21x2/9QVQOBfK AEkFQs9iwY+cSrpl1NNhUL8agDs4ngf6gfPwaXK/Hz0D7nz3HmeVlVJrW891sq+kGOPs Nn7hbUGUUe5zI6WIw/vX/HOAwrp9H37ZX0xzhl0HJruWApbHE8h0pwxpum9HfJUrKgbc LqCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=a/oPvAOqwev/ONHCvqdJVrOWnGiqO6FTpN41HI7iwhk=; b=mv7KW1lBrYF/3hM5i1xp6xigcB5AzqXcihZu1IJoBqcSqLmzLRDzgHv0Hbnp/AC6CB oHTq5KJ4PPFgGBJoneJbEv9H+5CN2GvqDNCv3xvILYZOGw1YGCEGUvqepHDwBXGwmsks retB/7lPFBWfrzHzhXzOP9FJdXOk0UxYnSg9HfUpcRL2WeHovP0oDiAx8EgJEY58XtMz 8IelsuAb96haI70hFhqaa0km9yRaM8Eks/pcpWR8KMT0y+HbFnCGBUtUEgHGsTLOq6+L IfJEjn8g4eT0gEtaQW3DR+QM+UEuHF7lFxC/0zUgpvmPpOvcxSAJdLqIIHnC6jFrgJmi CLlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ke3GjqPL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10si8514217pgj.576.2019.03.27.11.04.52; Wed, 27 Mar 2019 11:05:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ke3GjqPL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732695AbfC0SDk (ORCPT + 99 others); Wed, 27 Mar 2019 14:03:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:43946 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732659AbfC0SDi (ORCPT ); Wed, 27 Mar 2019 14:03:38 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B655A2075C; Wed, 27 Mar 2019 18:03:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709817; bh=gru6+zxB/qL5GRbcFnmiFmqZz3ht2VVv9COf8ZQJChE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ke3GjqPLebEyosi8xF85CZ0JdUuCdbMv93HiIfR0wkYsErxUeEc4T9FR014mMwp8I NkeXpVHDVY+SVdKMIF1JSprPcD2gzn2RBvFdhKd53MxTrPuDi+2Ul6iiL5fopJijJN uOEAsPxn4IeJDPNwmajntTsQStMwEfDwruHojlfA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lu Baolu , Jacob Pan , Mika Westerberg , Joerg Roedel , Sasha Levin , iommu@lists.linux-foundation.org Subject: [PATCH AUTOSEL 5.0 056/262] iommu/vt-d: Disable ATS support on untrusted devices Date: Wed, 27 Mar 2019 13:58:31 -0400 Message-Id: <20190327180158.10245-56-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lu Baolu [ Upstream commit d8b8591054575f33237556c32762d54e30774d28 ] Commit fb58fdcd295b9 ("iommu/vt-d: Do not enable ATS for untrusted devices") disables ATS support on the devices which have been marked as untrusted. Unfortunately this is not enough to fix the DMA attack vulnerabiltiies because IOMMU driver allows translated requests as long as a device advertises the ATS capability. Hence a malicious peripheral device could use this to bypass IOMMU. This disables the ATS support on untrusted devices by clearing the internal per-device ATS mark. As the result, IOMMU driver will block any translated requests from any device marked as untrusted. Cc: Jacob Pan Cc: Mika Westerberg Suggested-by: Kevin Tian Suggested-by: Ashok Raj Fixes: fb58fdcd295b9 ("iommu/vt-d: Do not enable ATS for untrusted devices") Signed-off-by: Lu Baolu Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/intel-iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 78188bf7e90d..dbd6824dfffa 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -2485,7 +2485,8 @@ static struct dmar_domain *dmar_insert_one_dev_info(struct intel_iommu *iommu, if (dev && dev_is_pci(dev)) { struct pci_dev *pdev = to_pci_dev(info->dev); - if (!pci_ats_disabled() && + if (!pdev->untrusted && + !pci_ats_disabled() && ecap_dev_iotlb_support(iommu->ecap) && pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_ATS) && dmar_find_matched_atsr_unit(pdev)) -- 2.19.1