2017-11-03 09:18:41 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-04 11:24:41 +05:30
|
|
|
|
2016-10-28 17:16:36 -04:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-25 11:17:01 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2019-05-29 13:28:40 +03:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-04-24 23:21:52 +02:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-12-05 15:13:54 +01:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2014-12-05 15:13:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-12 16:31:51 +01:00
|
|
|
|
2014-12-05 15:13:54 +01:00
|
|
|
|
2023-06-12 16:31:51 +01:00
|
|
|
|
2014-12-05 15:13:54 +01:00
|
|
|
|
2023-06-12 16:31:51 +01:00
|
|
|
|
2014-12-05 15:13:54 +01:00
|
|
|
|
2023-06-12 16:31:51 +01:00
|
|
|
|
2014-12-05 15:13:54 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-19 12:06:41 +02:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-08-02 20:10:04 +02:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2013-08-02 20:10:04 +02:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-01-25 11:17:41 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-01-25 11:17:41 +01:00
|
|
|
|
2010-12-25 11:17:01 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2019-08-11 10:05:16 +02:00
|
|
|
|
2005-11-28 09:29:23 -08:00
|
|
|
|
|
|
|
|
|
2008-01-30 15:21:33 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2015-04-29 16:19:33 +05:30
|
|
|
|
2017-03-13 10:18:41 +08:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-12-25 11:17:01 +01:00
|
|
|
|
2007-01-25 11:17:41 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-19 12:06:41 +02:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-01-25 11:17:41 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-01-30 15:21:33 -08:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2016-02-16 16:10:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2008-01-30 15:21:33 -08:00
|
|
|
|
2018-08-05 21:28:08 -07:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-12-06 20:33:19 -08:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-01-25 11:17:41 +01:00
|
|
|
|
2010-12-25 11:17:01 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2005-10-21 03:21:58 -04:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-08-30 11:32:52 -04:00
|
|
|
|
2010-12-25 11:17:01 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2016-04-28 11:42:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-05-29 13:28:40 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2019-08-11 10:05:16 +02:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2007-01-25 11:17:41 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-25 11:17:01 +01:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2017-03-13 10:18:41 +08:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2007-01-25 11:17:41 +01:00
|
|
|
|
2010-12-25 11:17:01 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2010-12-25 11:17:01 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-08-30 11:32:52 -04:00
|
|
|
|
2010-12-25 11:17:01 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-05-29 13:28:40 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-11 10:05:16 +02:00
|
|
|
|
2007-01-25 11:17:41 +01:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-25 11:17:01 +01:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-13 10:18:41 +08:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
usb: usbfs: Enforce page requirements for mmap
The current implementation of usbdev_mmap uses usb_alloc_coherent to
allocate memory pages that will later be mapped into the user space.
Meanwhile, usb_alloc_coherent employs three different methods to
allocate memory, as outlined below:
* If hcd->localmem_pool is non-null, it uses gen_pool_dma_alloc to
allocate memory;
* If DMA is not available, it uses kmalloc to allocate memory;
* Otherwise, it uses dma_alloc_coherent.
However, it should be noted that gen_pool_dma_alloc does not guarantee
that the resulting memory will be page-aligned. Furthermore, trying to
map slab pages (i.e., memory allocated by kmalloc) into the user space
is not resonable and can lead to problems, such as a type confusion bug
when PAGE_TABLE_CHECK=y [1].
To address these issues, this patch introduces hcd_alloc_coherent_pages,
which addresses the above two problems. Specifically,
hcd_alloc_coherent_pages uses gen_pool_dma_alloc_align instead of
gen_pool_dma_alloc to ensure that the memory is page-aligned. To replace
kmalloc, hcd_alloc_coherent_pages directly allocates pages by calling
__get_free_pages.
Reported-by: syzbot+fcf1a817ceb50935ce99@syzkaller.appspotmail.comm
Closes: https://lore.kernel.org/lkml/000000000000258e5e05fae79fc1@google.com/ [1]
Fixes: f7d34b445abc ("USB: Add support for usbfs zerocopy.")
Fixes: ff2437befd8f ("usb: host: Fix excessive alignment restriction for local memory allocations")
Cc: stable@vger.kernel.org
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20230515130958.32471-2-lrh2000@pku.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-15 21:09:55 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|