Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp455971pxj; Wed, 16 Jun 2021 06:24:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzN9VbmbkNpKTt4kYeIDlVIqRI8u5ZpV1JSZJugD3B2oQy+iB5BzfKDWMolZKxgdmmoYPmi X-Received: by 2002:a05:6402:40c3:: with SMTP id z3mr4144294edb.187.1623849841713; Wed, 16 Jun 2021 06:24:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623849841; cv=none; d=google.com; s=arc-20160816; b=Bve8IMztyVXN8P0CNP+lGMOLe+XwDiAunStvax9DvSmb5CU2oyWW8HvdF+QqxzLm0t AlHO8Pv5bYfCdp6TWBO4pfb422ayewvcG+nSgpqcYoyyggGwT2jd48SAoTNbFTjWeNvK KjSfMhRzF6aXdvjcfirezXrE/gcCO1D3P0U2lhCaXMfny7OYjl9S9O2/9czcLJaGC7aI FndvILjg49u2O8VOz69qV4ACoRiLtJBfu16H7lZM/luDSBMhdOvd6nAxuuOCFl5AUa5U hNx0V9yk3p7itUXRNh1wRGtwS8kJyma7J586DIhfrkBA1Jd4tiGzQcimf8E0ODOzLGK3 +gJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=HS1Vazj5sqFoKdW+6iW9X92uEY/3kgj6eez3AY/K4Eo=; b=LrwOO3PRjWyt6IjlFfCC2D3GJ2oTzbhYnQDiXh6AKNEZdQWPYOaj8UsHbA4UfiSgiq SsGmGkhtQ21tqPwA0uefo0fUeyzi7S2SUeFqa2YdYr767Oift9Eo3Vrm3FFob5S7V9bb 1vyZluEPC0Gn8WV7j2mosSD2+kWyuM5TzKhWLGXkJ+3dX7bT0oeGvqY4ugFwGMHYYGJi lx79t3cdAARz/O4ZovBDlUVuO4v0vaTbzFNJCvC/lxrwtNCe4/olQevGfM8yrimY/Dwt GtPHpf9TFXoA5NDbno/TEke4fMkL/NlYh01/cP86jSVHSLA0kBLO7xA/qPcQ+q7q+YA1 TsYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gNoqbf4B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id kl9si2270798ejc.603.2021.06.16.06.23.37; Wed, 16 Jun 2021 06:24:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gNoqbf4B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231311AbhFPMK5 (ORCPT + 99 others); Wed, 16 Jun 2021 08:10:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:45412 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbhFPMKz (ORCPT ); Wed, 16 Jun 2021 08:10:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CD51A61245; Wed, 16 Jun 2021 12:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623845329; bh=QlkI38WT3hL5S6bnBl68cYI3mNCvqwOg2BtN6RClOD8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gNoqbf4BoEB+mMSkF0LbPACcE8hfdhWziBuc3On0yCSF1OPpARGrphJEZzi5R8zhj EQBk9eSasfJ21LDYEs5fQgad/5i5kQ4hvjwr2VzkCT5qsBkbBa2YuO73damjDS9tPT gEWv6ceU59Ud8WyKcV32BLXCIyoDzCKKiI1Qx1b1D7h7TGQnS6Yc8Hh4jwg0vvdXHU 1ESCA6NJ9d+xly0Ts4XCXJSqpVE+kwtWKvwUzczVJ12VkVaF8vrrLoIIMNmcUpnUot CLEWTlb2HNfBG1sx2OnHpHCbJjguomfMTK9NnEnMModJku7GBFKFrxYfN57naGCL26 kwPvkXDDNtLyg== Date: Wed, 16 Jun 2021 13:08:38 +0100 From: Will Deacon To: Claire Chang Cc: Rob Herring , mpe@ellerman.id.au, Joerg Roedel , Frank Rowand , Konrad Rzeszutek Wilk , boris.ostrovsky@oracle.com, jgross@suse.com, Christoph Hellwig , Marek Szyprowski , benh@kernel.crashing.org, paulus@samba.org, "list@263.net:IOMMU DRIVERS" , sstabellini@kernel.org, Robin Murphy , grant.likely@arm.com, xypron.glpk@gmx.de, Thierry Reding , mingo@kernel.org, bauerman@linux.ibm.com, peterz@infradead.org, Greg KH , Saravana Kannan , "Rafael J . Wysocki" , heikki.krogerus@linux.intel.com, Andy Shevchenko , Randy Dunlap , Dan Williams , Bartosz Golaszewski , linux-devicetree , lkml , linuxppc-dev@lists.ozlabs.org, xen-devel@lists.xenproject.org, Nicolas Boichat , Jim Quinlan , tfiga@chromium.org, bskeggs@redhat.com, bhelgaas@google.com, chris@chris-wilson.co.uk, daniel@ffwll.ch, airlied@linux.ie, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, jani.nikula@linux.intel.com, jxgao@google.com, joonas.lahtinen@linux.intel.com, linux-pci@vger.kernel.org, maarten.lankhorst@linux.intel.com, matthew.auld@intel.com, rodrigo.vivi@intel.com, thomas.hellstrom@linux.intel.com Subject: Re: [PATCH v12 00/12] Restricted DMA Message-ID: <20210616120837.GA22783@willie-the-truck> References: <20210616062157.953777-1-tientzu@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210616062157.953777-1-tientzu@chromium.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Claire, On Wed, Jun 16, 2021 at 02:21:45PM +0800, Claire Chang wrote: > This series implements mitigations for lack of DMA access control on > systems without an IOMMU, which could result in the DMA accessing the > system memory at unexpected times and/or unexpected addresses, possibly > leading to data leakage or corruption. > > For example, we plan to use the PCI-e bus for Wi-Fi and that PCI-e bus is > not behind an IOMMU. As PCI-e, by design, gives the device full access to > system memory, a vulnerability in the Wi-Fi firmware could easily escalate > to a full system exploit (remote wifi exploits: [1a], [1b] that shows a > full chain of exploits; [2], [3]). > > To mitigate the security concerns, we introduce restricted DMA. Restricted > DMA utilizes the existing swiotlb to bounce streaming DMA in and out of a > specially allocated region and does memory allocation from the same region. > The feature on its own provides a basic level of protection against the DMA > overwriting buffer contents at unexpected times. However, to protect > against general data leakage and system memory corruption, the system needs > to provide a way to restrict the DMA to a predefined memory region (this is > usually done at firmware level, e.g. MPU in ATF on some ARM platforms [4]). > > [1a] https://googleprojectzero.blogspot.com/2017/04/over-air-exploiting-broadcoms-wi-fi_4.html > [1b] https://googleprojectzero.blogspot.com/2017/04/over-air-exploiting-broadcoms-wi-fi_11.html > [2] https://blade.tencent.com/en/advisories/qualpwn/ > [3] https://www.bleepingcomputer.com/news/security/vulnerabilities-found-in-highly-popular-firmware-for-wifi-chips/ > [4] https://github.com/ARM-software/arm-trusted-firmware/blob/master/plat/mediatek/mt8183/drivers/emi_mpu/emi_mpu.c#L132 > > v12: > Split is_dev_swiotlb_force into is_swiotlb_force_bounce (patch 06/12) and > is_swiotlb_for_alloc (patch 09/12) I took this for a spin in an arm64 KVM guest with virtio devices using the DMA API and it works as expected on top of swiotlb devel/for-linus-5.14, so: Tested-by: Will Deacon Thanks! Will