All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: Ruihan Li <lrh2000@pku.edu.cn>,
	syzbot+fcf1a817ceb50935ce99@syzkaller.appspotmail.com,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, pasha.tatashin@soleen.com,
	linux-usb@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: usbdev_mmap causes type confusion in page_table_check
Date: Tue, 9 May 2023 16:01:02 +0200	[thread overview]
Message-ID: <2023050934-launch-shifty-0bbb@gregkh> (raw)
In-Reply-To: <ZFpJ1rs+XinCYfPs@infradead.org>

On Tue, May 09, 2023 at 06:25:42AM -0700, Christoph Hellwig wrote:
> On Sun, May 07, 2023 at 09:58:44PM +0800, Ruihan Li wrote:
> > static int usbdev_mmap(struct file *file, struct vm_area_struct *vma)
> > {
> > 	// ...
> > 	mem = usb_alloc_coherent(ps->dev, size, GFP_USER | __GFP_NOWARN,
> > 			&dma_handle);
> > 	// ...
> > 	if (hcd->localmem_pool || !hcd_uses_dma(hcd)) {
> > 		if (remap_pfn_range(vma, vma->vm_start,
> > 				    virt_to_phys(usbm->mem) >> PAGE_SHIFT,
> 
> usb_alloc_coherent and up in the DMA coherent allocator (usually
> anyway), and you absolutely must never do a virt_to_phys or virt_to_page
> on that return value.  This code is a buggy as f**k.

Odd, you gave it a reviewed-by: in commit a0e710a7def4 ("USB: usbfs: fix
mmap dma mismatch") back in 2020 when it was merged as you said that was
the way to fix this up.  :)

Do you have a better way to do it now that is more correct?  Did some
DMA changes happen that missed this codepath getting fixed up?

thanks,

gre gk-h

  reply	other threads:[~2023-05-09 14:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-05  0:46 [syzbot] [mm?] kernel BUG in page_table_check_clear syzbot
2023-05-07 13:58 ` usbdev_mmap causes type confusion in page_table_check Ruihan Li
2023-05-08 21:27   ` Pasha Tatashin
2023-05-08 21:36     ` Matthew Wilcox
2023-05-08 21:48       ` Pasha Tatashin
2023-05-08 21:52         ` Matthew Wilcox
2023-05-08 21:55           ` Pasha Tatashin
2023-05-08 22:46             ` David Hildenbrand
2023-05-08 23:17               ` Pasha Tatashin
2023-05-08 23:21                 ` Pasha Tatashin
2023-05-08 23:37                   ` David Hildenbrand
2023-05-09  0:07                     ` Pasha Tatashin
2023-05-09  1:18                       ` Ruihan Li
2023-05-08 21:37     ` David Hildenbrand
2023-05-09 13:25   ` Christoph Hellwig
2023-05-09 14:01     ` Greg KH [this message]
2023-05-10 13:17       ` Christoph Hellwig

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=2023050934-launch-shifty-0bbb@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lrh2000@pku.edu.cn \
    --cc=pasha.tatashin@soleen.com \
    --cc=syzbot+fcf1a817ceb50935ce99@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.