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=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 354EEC48BC2 for ; Mon, 7 Jun 2021 03:29:21 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D86FF61208 for ; Mon, 7 Jun 2021 03:29:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D86FF61208 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BADE56E0C4; Mon, 7 Jun 2021 03:29:19 +0000 (UTC) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 44B246E0C4 for ; Mon, 7 Jun 2021 03:29:18 +0000 (UTC) Received: by mail-il1-x12e.google.com with SMTP id b5so14797031ilc.12 for ; Sun, 06 Jun 2021 20:29:18 -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=zXJrYShxgIyQHo1wYCS3F9rVjXIqXzIl9+OOmY4aJuc=; b=lXhSyF7uZrXQiHjN4kEdhtrYYO4eYXTtv+MmIVlkaYfrDj3gFF3i6zdq9V6t5fEQPA Q41l6xsOf6kbnxwhiHTDBcVDInxTuXTZ4PeJVzQkTroJzwWh+Feq2JO3lXBrruik9rJE v5bJs9UlwmvhYXAJ0FNY04iCN48TAqVGzZPFU= 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=zXJrYShxgIyQHo1wYCS3F9rVjXIqXzIl9+OOmY4aJuc=; b=I0GwZuXz4JsAQSy4VDi0uL9hiho0sicYTCl8yN7HBxsSNxmzZ4MUpKWy/iX8cd1kLx kr0RmG0xrNdrcC1/zrXg+LcBcaE0BOT/1EYBHV1HY/75Yy9TMq/y4rpg0XuevOi/wCiS Q0kUr13HaTCagxdmtIXKfj+pS9zY74L4ARU+V6iziq6AveUNOYuvAATGBUBeEhpbaRIM ClNTAGlD7zFaTpbjxil6yFfT9ZluNWb8bdV7WH7xxH5ZqH+OyX/fMTQWXEvH2oIK9Qip HCSN63MEMToYdqMO8wnM0/eYxV6WEJMVLdNjPNgfu/VD2aKblwYaccj4N2J+kLookCp3 4LZg== X-Gm-Message-State: AOAM530FUcMK0mDsvuGpulhLiuWBoViXhMrHVOS+v+PPLoVm8fF+hK26 THS4spDGWzG45ldqcmfFBdE0EIySSMGaaw== X-Google-Smtp-Source: ABdhPJyFzZx9EVm73VbobKJfJ5nCBbLY4jNh3Um+d6wofQd1JDFvWTkre80lMhpoBYCdpISZDRhyhg== X-Received: by 2002:a05:6e02:8e9:: with SMTP id n9mr359977ilt.185.1623036557398; Sun, 06 Jun 2021 20:29:17 -0700 (PDT) Received: from mail-io1-f50.google.com (mail-io1-f50.google.com. [209.85.166.50]) by smtp.gmail.com with ESMTPSA id w25sm7911073iox.18.2021.06.06.20.29.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Jun 2021 20:29:16 -0700 (PDT) Received: by mail-io1-f50.google.com with SMTP id v9so16794746ion.11 for ; Sun, 06 Jun 2021 20:29:15 -0700 (PDT) X-Received: by 2002:a05:6e02:1a44:: with SMTP id u4mr1746214ilv.64.1623036543940; Sun, 06 Jun 2021 20:29:03 -0700 (PDT) MIME-Version: 1.0 References: <20210527125845.1852284-1-tientzu@chromium.org> <20210604174818.GC3703@willie-the-truck> In-Reply-To: <20210604174818.GC3703@willie-the-truck> From: Claire Chang Date: Mon, 7 Jun 2021 11:28:53 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v8 00/15] Restricted DMA To: Will Deacon Content-Type: text/plain; charset="UTF-8" X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: heikki.krogerus@linux.intel.com, thomas.hellstrom@linux.intel.com, peterz@infradead.org, dri-devel@lists.freedesktop.org, chris@chris-wilson.co.uk, grant.likely@arm.com, paulus@samba.org, Frank Rowand , mingo@kernel.org, Marek Szyprowski , sstabellini@kernel.org, Saravana Kannan , mpe@ellerman.id.au, Joerg Roedel , "Rafael J . Wysocki" , Christoph Hellwig , Bartosz Golaszewski , bskeggs@redhat.com, linux-pci@vger.kernel.org, xen-devel@lists.xenproject.org, Thierry Reding , intel-gfx@lists.freedesktop.org, matthew.auld@intel.com, linux-devicetree , Jianxiong Gao , Konrad Rzeszutek Wilk , airlied@linux.ie, Dan Williams , linuxppc-dev@lists.ozlabs.org, Rob Herring , rodrigo.vivi@intel.com, Bjorn Helgaas , boris.ostrovsky@oracle.com, Andy Shevchenko , jgross@suse.com, Nicolas Boichat , Greg KH , Randy Dunlap , lkml , Tomasz Figa , "list@263.net:IOMMU DRIVERS" , Jim Quinlan , xypron.glpk@gmx.de, Robin Murphy , bauerman@linux.ibm.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Sat, Jun 5, 2021 at 1:48 AM Will Deacon wrote: > > Hi Claire, > > On Thu, May 27, 2021 at 08:58:30PM +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 > > > > v8: > > - Fix reserved-memory.txt and add the reg property in example. > > - Fix sizeof for of_property_count_elems_of_size in > > drivers/of/address.c#of_dma_set_restricted_buffer. > > - Apply Will's suggestion to try the OF node having DMA configuration in > > drivers/of/address.c#of_dma_set_restricted_buffer. > > - Fix typo in the comment of drivers/of/address.c#of_dma_set_restricted_buffer. > > - Add error message for PageHighMem in > > kernel/dma/swiotlb.c#rmem_swiotlb_device_init and move it to > > rmem_swiotlb_setup. > > - Fix the message string in rmem_swiotlb_setup. > > Thanks for the v8. It works for me out of the box on arm64 under KVM, so: > > Tested-by: Will Deacon > > Note that something seems to have gone wrong with the mail threading, so > the last 5 patches ended up as a separate thread for me. Probably worth > posting again with all the patches in one place, if you can. Thanks for testing. Christoph also added some comments in v7, so I'll prepare v9. > > Cheers, > > Will