From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5EE50C433E0 for ; Fri, 15 May 2020 12:44:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 41C902074D for ; Fri, 15 May 2020 12:44:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726144AbgEOMov (ORCPT ); Fri, 15 May 2020 08:44:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726141AbgEOMov (ORCPT ); Fri, 15 May 2020 08:44:51 -0400 X-Greylist: delayed 1423 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 15 May 2020 05:44:51 PDT Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C0C2C061A0C for ; Fri, 15 May 2020 05:44:51 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id E6751379; Fri, 15 May 2020 14:44:49 +0200 (CEST) Date: Fri, 15 May 2020 14:44:48 +0200 From: Joerg Roedel To: Rajat Jain Cc: Bjorn Helgaas , ashok.raj@intel.com, lalithambika.krishnakumar@intel.com, Bjorn Helgaas , linux-pci , Mika Westerberg , Jean-Philippe Brucker , Prashant Malani , Benson Leung , Todd Broch , Alex Levin , Mattias Nissler , Zubin Mithra , Rajat Jain , Bernie Keany , Aaron Durbin , Diego Rivas , Duncan Laurie , Furquan Shaikh , Jesse Barnes , Christian Kellner , Alex Williamson Subject: Re: [RFC] Restrict the untrusted devices, to bind to only a set of "whitelisted" drivers Message-ID: <20200515124448.GW18353@8bytes.org> References: <20200513151929.GA38418@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org On Wed, May 13, 2020 at 02:26:18PM -0700, Rajat Jain wrote: > * A driver could be double fetching the memory, causing it to do > different things than intended. E.g. > * A driver could be (negligently) passing some kernel addresses to the device. > * A driver could be using (for memory dereferencing, for e.g.) the > address/indices, given by the device, without enough validation. > * A driver may negligently be sharing the DMA memory with some other > driver data in the same PAGE. Since the IOMMU restrictions are PAGE > granular, this might give device access to that driver data. The Intel IOMMU driver has a solution for that problem as it has iommu based bounce-buffer dma ops. This means that a driver can't accidentially share sensitive information on the same page with a device. This idea should be generalized and made available for all iommu-drivers in the form of integrating it into the dma-iommu code, or have a separate generic dma-ops implementation, which does: 1) Give the device direct access to DMA buffers if they are IOMMU-page aligned (both start and size). 2) Use bounce buffering for DMA buffers that don't align with iommu page-size. This would at least eliminate this type of attack made possible by uncautious drivers. Regards, Joerg