linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: yvahkhfo.1df7f8c2@hashmail.org
To: linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: security@kernel.org
Subject: usb zero copy dma handling
Date: Thu, 8 Aug 2019 10:46:36 +0200	[thread overview]
Message-ID: <20190808084636.GB15080@priv-mua.localdomain> (raw)

[-- Attachment #1: Type: text/plain, Size: 1882 bytes --]

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




[-- Attachment #2: arm-usb-dma-v2.diff --]
[-- Type: text/plain, Size: 678 bytes --]

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;
 	}

             reply	other threads:[~2019-08-08  8:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-08  8:46 yvahkhfo.1df7f8c2 [this message]
2019-08-08  8:58 ` usb zero copy dma handling Greg KH
2019-08-08  9:46   ` Robin Murphy
2019-08-08 10:07     ` Greg KH
2019-08-08 10:43       ` Robin Murphy
2019-08-08 13:05       ` Greg KH
2019-08-08  9:59   ` Russell King - ARM Linux admin
2019-08-08 10:02     ` Oliver Neukum
2019-08-08 16:10 ` Christoph Hellwig
2019-08-08 16:12   ` Christoph Hellwig
2019-08-08 16:57   ` Russell King - ARM Linux admin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190808084636.GB15080@priv-mua.localdomain \
    --to=yvahkhfo.1df7f8c2@hashmail.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=security@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).