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=-5.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 768EAC433FF for ; Thu, 8 Aug 2019 08:46:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 47F1A2173C for ; Thu, 8 Aug 2019 08:46:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rbzYLX6O"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=hashmail.org header.i=@hashmail.org header.b="Ypnxougu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 47F1A2173C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hashmail.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: MIME-Version:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=BpR97BmibAktcFal02Kd10/q5uscMv1sPcDVKOQUMUo=; b=rbz YLX6OHXF9xuDsnQjK+jyl7vhs/wsuciAHXQ33sxQFnOb0VJHbcHaNolkHuAstJgVHsBl92gADB0KY eA7cU2VvjiWXMQgtt+0lFd6IVTucgUogQq6DUTI7BM0Q87A5xUynDEBvyIonRaFSOYOhh2h/X6S+B talIvihU9/IcaH3qJ82mKW25DGHXQWuSGSwJm1+o0DEeKhKEIQzLbgb9QU6DkeLikrdC5DXkUo0Dr QM3yglSO6tsyhzafNjrvzflbRAnz1S4VI9sJ0uX1yzipgsAXze12DMHmUfAMcFVc2pfw9SOnp6qjN qdXW0j2ntDOJJDMA/JqplzWQqcMW8Lw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hve4P-00076n-J4; Thu, 08 Aug 2019 08:46:49 +0000 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::12]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hve4L-000763-5M for linux-arm-kernel@lists.infradead.org; Thu, 08 Aug 2019 08:46:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1565254001; s=strato-dkim-0002; d=hashmail.org; h=Message-ID:Subject:Cc:To:From:Date:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=2zgjnksGmQ/ZAqwgmVBQpCI5NujcSeTtpImhQoYcKR0=; b=YpnxougucLY79fPObRYzPxzHpW6wVWfyLNBQGj6xF5mF2RqDCjc7VaBU11Wz5lb87e 5usNp2RKXjvNH7dxuKkZZtklLlbfRoo0VvRMHft+eZiDy1QajqSUBVb9n2Yi26kUxuee q7ZPxyFy0FZjJc+zGy8s3n3niBlh/RmtM6EepGvqMKyPp2ytX0oVrjVJ5+RdM5kKByrm kgNjOf9veL4/ZEFybucQ6Xz35hdBfW25Qdn3WpDFI/kpa80niTJUHHm7LtAcCxsYcYym SZ+qIjcBzxZ8FmuNR3zBlq467G6RTFNNnzWwAN8PftAWL6u4Xw/b7cEISLYWWdsrpgNX Zj4w== X-RZG-AUTH: ":O2kGeEG7b/pS1F+/SC3i33Z09cEcHcRBAtqtGgRBDGeSaUqOsX4glAsBpQEeWZN4DOM7" X-RZG-CLASS-ID: mo00 Received: from localhost by smtp.strato.de (RZmta 44.24 DYNA|AUTH) with ESMTPSA id f0aa24v788kcir9 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Thu, 8 Aug 2019 10:46:38 +0200 (CEST) Date: Thu, 8 Aug 2019 10:46:36 +0200 From: yvahkhfo.1df7f8c2@hashmail.org To: linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: usb zero copy dma handling Message-ID: <20190808084636.GB15080@priv-mua.localdomain> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="ZPt4rx8FFjLCG7dd" Content-Disposition: inline User-Agent: Mutt/1.11.3 (2019-02-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190808_014645_807814_4841E050 X-CRM114-Status: GOOD ( 10.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: security@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello linux-usb and linux-arm. Ccing security@ because "the kernel dma code is mapping randomish kernel/user mem to a user process" seems to have security implications even though i didnt research that aspect past "its a 100% reliable way to crash a raspi from userspace". tried submitting this through linux-arm-kernel ~2 weeks ago but the only "response" i got was phishing-spam. tried to follow up through raspi-internals chat, they suggested i try linux-usb instead, but otoh the original reporter was deflected from -usb to "try some other mls, they might care". https://www.spinics.net/lists/linux-usb/msg173277.html if i am not following some arcane ritual or indenting convention required by regular users of these lists i apologize in advance, but i am not a kernel developer, i am just here as a user with a bug and a patch. (and the vger FAQ link 404s...) i rediffed against HEAD even though the two weeks old patch still applied cleanly with +2 offset. # stepping off soap box # actual technical content starts here # this is a followup to that thread from 2018-11: https://www.spinics.net/lists/arm-kernel/msg685598.html the issue was discussed in more detail than i can claim to fully understand back then, but no fix ever merged. but i would really like to use rtl_433 on a raspi without having to build a custom-patched kernel first. the attached patch is my stripdown/cleanup of a devel-diff provided to me by the original reporter Steve Markgraf. credits to him for the good parts, blame to me for the bad parts. this does not cover the additional case of "PIO-based usb controllers" mainly because i dont understand what that means (or how to handle it) and if its broken right now (as the thread indicates) it might as well stay broken until someone who understands cares enough. could you please get this on track for merging? regards, x23 --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="arm-usb-dma-v2.diff" diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index b265ab5405f9..69594c2169ea 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -238,9 +238,14 @@ static int usbdev_mmap(struct file *file, struct vm_area_struct *vma) usbm->vma_use_count = 1; INIT_LIST_HEAD(&usbm->memlist); +#ifdef CONFIG_X86 if (remap_pfn_range(vma, vma->vm_start, virt_to_phys(usbm->mem) >> PAGE_SHIFT, size, vma->vm_page_prot) < 0) { +#else /* !CONFIG_X86 */ + if (dma_mmap_coherent(ps->dev->bus->sysdev, + vma, mem, dma_handle, size) < 0) { +#endif /* !CONFIG_X86 */ dec_usb_memory_use_count(usbm, &usbm->vma_use_count); return -EAGAIN; } --ZPt4rx8FFjLCG7dd Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --ZPt4rx8FFjLCG7dd--