Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp249039ybg; Tue, 28 Jul 2020 05:12:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3QMppSL1nWf7dM9YEzRgW2jX/tz5cissyQTJh/xaIYyObCr25FpNPPtI+bdLdK6JRJ3yh X-Received: by 2002:aa7:d802:: with SMTP id v2mr25628520edq.77.1595938342792; Tue, 28 Jul 2020 05:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595938342; cv=none; d=google.com; s=arc-20160816; b=JAyyy4B9tFwvRhDYWlu6cT/eBWBY6NNwchScTrxO/e9UyiHrpyhQCJcc4jFHrbzwsS gdBSgtmGb9cntq2X/KvtAkc4m1YtNtL4o12ljf/vbtz1S+KipWBPAuXxND63m/Nv9suD eEXrn2t06Nz2oXo4cfmgZ8nyTGv22IlxCy/qj53yONuuL+2X90wUorOfXE7FX4LflDCJ NpDzNkOEXAGZ37yus4iihZFyaT+SKYE7XBloJB6eMJNG1sh6stvYjRYxZ9Q1tz2jOlw2 aNmdasbFWKuLLZoP72+UYTm3zS104k1lhtewLNl1+2U9LMWZQQeicVQ17NH0m4hgmQZO D5Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Tl/xK5nksFGek4I0hJhjtnSKtWmsm7mD8uEP3H8tAJc=; b=ZWFQp9Eb4gtmBukBC0FVeByhN2R22DKpqJsV/gUsnqkZ749QRDy4AlK6GV4ugHQNpn YW+iapYvaVeYHKgqtbLiOnk6aQCWFgJmVAlYm76JwdPPBdq9uzdR98t4+7VopbiE/ZnS 5yyK6oyU6OQUPcw6eZ+i1tdpYxXKLfudRa8nJLHVVucrlZXvT31w+VpQMy/f8RiudtuI KM5G8z/hbGAVpIoybHSYxR8+KuueIHFbvjZQiseGQ8hUD7shJ2lOr2N4iafNAlz/5mJc 0WqmajrUwmRWheMBwtjNjMuu9k688uOJTpG1y2ujbgUNPmZKgebSEJEI9xK+I0ZEW7jB MPmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dKxVLScN; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lc15si7372014ejb.526.2020.07.28.05.12.00; Tue, 28 Jul 2020 05:12:22 -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=@chromium.org header.s=google header.b=dKxVLScN; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729310AbgG1L72 (ORCPT + 99 others); Tue, 28 Jul 2020 07:59:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729306AbgG1L70 (ORCPT ); Tue, 28 Jul 2020 07:59:26 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4C3AC0619D4 for ; Tue, 28 Jul 2020 04:59:26 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id l1so20399730ioh.5 for ; Tue, 28 Jul 2020 04:59:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Tl/xK5nksFGek4I0hJhjtnSKtWmsm7mD8uEP3H8tAJc=; b=dKxVLScNmH+IxfLYOJHi2FyLa1HeUI2rsPJTmMupKBaQWimNey/qP3/d62lN/wRW/l eQ4lrfidDx/qDiuCsBs8jqw6PRXawqwMoVVC3s9ak2gMfUMN+L9SwWpIE/lgtTa/OWao ZE7kRtmQ9VEQjfKvpIUMjvlPOFlq1JqJQiEEc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Tl/xK5nksFGek4I0hJhjtnSKtWmsm7mD8uEP3H8tAJc=; b=ayNVO+vKt8ky2FVH9aGbpYxLlrjeZ9c9DwZeR9fhAi8LuGLLVN9XFlSS1KCyDtcK0U f1h7fmkT3y0V3XZkLPcJGc0j2jLnrcEmN/oq+40eh/IMwJq2oUurr7VJIypP5mnzqnWQ lfJ8tDnLHYKz7YUnKS35z/FKJ4b6t5fFrAXvis0Ip+ye70DgjVS6TzG/AR4opyn5kCjK WIF9rKbTJIPx7ORFE4/cmnpojevcBUgc3Z6W9UWcD7hUsiQ/FDN2T2pItVeFRayYT2C9 SMCgpQIOqxy4n+21hNKptCvZhZ+ULJAzY8MMt0G+Z/cFpCwLUV1mXMbvhMb/3vsmPmKo xPYw== X-Gm-Message-State: AOAM53221QsxQLBIkGlkkmdqKMgFPMqV57/hxvrRjbq5wYAyAb/btbsg ouU7gCfGjkIVrw9Ek+50eGFMlOL7rBk= X-Received: by 2002:a02:b106:: with SMTP id r6mr29478069jah.9.1595937565694; Tue, 28 Jul 2020 04:59:25 -0700 (PDT) Received: from mail-io1-f53.google.com (mail-io1-f53.google.com. [209.85.166.53]) by smtp.gmail.com with ESMTPSA id r15sm5846743ilq.16.2020.07.28.04.59.23 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Jul 2020 04:59:24 -0700 (PDT) Received: by mail-io1-f53.google.com with SMTP id j8so8054250ioe.9 for ; Tue, 28 Jul 2020 04:59:23 -0700 (PDT) X-Received: by 2002:a02:6947:: with SMTP id e68mr17279172jac.3.1595937563294; Tue, 28 Jul 2020 04:59:23 -0700 (PDT) MIME-Version: 1.0 References: <20200728050140.996974-1-tientzu@chromium.org> In-Reply-To: <20200728050140.996974-1-tientzu@chromium.org> From: Claire Chang Date: Tue, 28 Jul 2020 19:59:12 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC v2 0/5] Restricted DMA To: Rob Herring , frowand.list@gmail.com, Christoph Hellwig , m.szyprowski@samsung.com, Robin Murphy Cc: treding@nvidia.com, Greg KH , Saravana Kannan , suzuki.poulose@arm.com, dan.j.williams@intel.com, heikki.krogerus@linux.intel.com, bgolaszewski@baylibre.com, devicetree@vger.kernel.org, lkml , iommu@lists.linux-foundation.org, Nicolas Boichat , tfiga@chromium.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It seems that I didn't rebase the patchset properly. There are some build test errors. Sorry about that. Please kindly ignore those rebase issues. I'll fix them in the next version. On Tue, Jul 28, 2020 at 1:01 PM 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 on one MTK platform 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. The > restricted DMA is implemented by per-device swiotlb and coherent memory > pools. 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. in ATF on some ARM > platforms). > > [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/ > > > Claire Chang (5): > swiotlb: Add io_tlb_mem struct > swiotlb: Add device swiotlb pool > swiotlb: Use device swiotlb pool if available > dt-bindings: of: Add plumbing for restricted DMA pool > of: Add plumbing for restricted DMA pool > > .../reserved-memory/reserved-memory.txt | 35 ++ > drivers/iommu/intel/iommu.c | 8 +- > drivers/of/address.c | 39 ++ > drivers/of/device.c | 3 + > drivers/of/of_private.h | 6 + > drivers/xen/swiotlb-xen.c | 4 +- > include/linux/device.h | 4 + > include/linux/dma-direct.h | 8 +- > include/linux/swiotlb.h | 49 +- > kernel/dma/direct.c | 8 +- > kernel/dma/swiotlb.c | 418 +++++++++++------- > 11 files changed, 393 insertions(+), 189 deletions(-) > > -- > v1: https://lore.kernel.org/patchwork/cover/1271660/ > Changes in v2: > - build on top of swiotlb > > 2.28.0.rc0.142.g3c755180ce-goog >