linux-stable/include/linux/usb
Ruihan Li 0143d148d1 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: f7d34b445a ("USB: Add support for usbfs zerocopy.")
Fixes: ff2437befd ("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-29 16:14:28 +01:00
..
audio-v2.h USB: Follow-up to SPDX identifiers addition - remove now useless comments 2022-06-10 11:24:36 +02:00
audio-v3.h
audio.h USB: Follow-up to SPDX identifiers addition - remove now useless comments 2022-06-10 11:24:36 +02:00
c67x00.h USB: Follow-up to SPDX GPL-2.0+ identifiers addition - remove now useless comments 2022-06-10 11:24:37 +02:00
ccid.h
cdc-wdm.h USB: Follow-up to SPDX identifiers addition - remove now useless comments 2022-06-10 11:24:36 +02:00
cdc.h USB: Follow-up to SPDX identifiers addition - remove now useless comments 2022-06-10 11:24:36 +02:00
cdc_ncm.h net/cdc_ncm: Increase NTB max RX/TX values to 64kb 2022-07-21 13:20:28 +02:00
ch9.h headers/deps: USB: Optimize <linux/usb/ch9.h> dependencies, remove <linux/device.h> 2022-01-05 16:21:44 +01:00
chipidea.h usb: chipidea: Add support for VBUS control with PHY 2022-08-31 09:07:52 +02:00
composite.h usb: gadget: drop superfluous ':' in doc string 2023-05-13 18:04:59 +09:00
ehci-dbgp.h
ehci_def.h USB: Follow-up to SPDX GPL-2.0+ identifiers addition - remove now useless comments 2022-06-10 11:24:37 +02:00
ehci_pdriver.h USB: Follow-up to SPDX GPL-2.0+ identifiers addition - remove now useless comments 2022-06-10 11:24:37 +02:00
ezusb.h
functionfs.h
g_hid.h USB: Follow-up to SPDX GPL-2.0+ identifiers addition - remove now useless comments 2022-06-10 11:24:37 +02:00
gadget.h usb: gadget: Add function wakeup support 2023-03-29 10:27:01 +02:00
gadget_configfs.h
hcd.h usb: usbfs: Enforce page requirements for mmap 2023-05-29 16:14:28 +01:00
input.h USB: Follow-up to SPDX identifiers addition - remove now useless comments 2022-06-10 11:24:36 +02:00
iowarrior.h
irda.h
isp116x.h
isp1301.h USB: Follow-up to SPDX identifiers addition - remove now useless comments 2022-06-10 11:24:36 +02:00
isp1362.h
m66592.h USB: Follow-up to SPDX identifiers addition - remove now useless comments 2022-06-10 11:24:36 +02:00
musb-ux500.h USB: Follow-up to SPDX GPL-2.0+ identifiers addition - remove now useless comments 2022-06-10 11:24:37 +02:00
musb.h ARM: omap2: make functions static 2023-01-09 17:00:54 +01:00
net2280.h USB: Follow-up to SPDX GPL-2.0+ identifiers addition - remove now useless comments 2022-06-10 11:24:37 +02:00
of.h USB: Follow-up to SPDX identifiers addition - remove now useless comments 2022-06-10 11:24:36 +02:00
ohci_pdriver.h USB: Follow-up to SPDX GPL-2.0+ identifiers addition - remove now useless comments 2022-06-10 11:24:37 +02:00
onboard_hub.h usb: misc: Add onboard_usb_hub driver 2022-07-08 14:53:50 +02:00
otg-fsm.h USB: Follow-up to SPDX GPL-2.0+ identifiers addition - remove now useless comments 2022-06-10 11:24:37 +02:00
otg.h
pd.h usb: typec: Separate USB Power Delivery from USB Type-C 2022-06-12 06:49:47 +02:00
pd_ado.h
pd_bdo.h usb: typec: tcpm: Fix undefined behavior due to shift overflowing the constant 2022-04-21 18:33:56 +02:00
pd_ext_sdb.h
pd_vdo.h
phy.h
phy_companion.h USB: Follow-up to SPDX GPL-2.0+ identifiers addition - remove now useless comments 2022-06-10 11:24:37 +02:00
quirks.h
r8a66597.h USB: Follow-up to SPDX identifiers addition - remove now useless comments 2022-06-10 11:24:36 +02:00
r8152.h
renesas_usbhs.h
rndis_host.h USB: Follow-up to SPDX GPL-2.0+ identifiers addition - remove now useless comments 2022-06-10 11:24:37 +02:00
role.h usb: roles: fix include/linux/usb/role.h compile issue 2022-01-25 18:30:15 +01:00
rzv2m_usb3drd.h usb: gadget: Add support for RZ/V2M USB3DRD driver 2023-01-25 15:48:16 +01:00
serial.h USB: mark all struct bus_type as const 2023-03-23 13:22:00 +01:00
sl811.h
storage.h USB: Follow-up to SPDX identifiers addition - remove now useless comments 2022-06-10 11:24:36 +02:00
tcpci.h usb: typec: tcpci: Add callback for evaluating contaminant presence 2023-01-17 17:29:23 +01:00
tcpm.h usb: typec: tcpm: Add callbacks to mitigate wakeups due to contaminant 2023-01-17 17:29:23 +01:00
tegra_usb_phy.h USB: Follow-up to SPDX identifiers addition - remove now useless comments 2022-06-10 11:24:36 +02:00
typec.h usb: typec: Add partner PD object wrapper 2022-11-29 08:56:09 +01:00
typec_altmode.h usb: typec_altmode: add a missing "@" at a kernel-doc parameter 2022-06-29 21:00:16 +02:00
typec_dp.h usb: typec: altmodes/displayport: correct pin assignment for UFP receptacles 2022-08-18 21:20:07 +02:00
typec_mux.h usb: typec: mux: Add CONFIG guards for functions 2022-06-21 16:38:14 +02:00
typec_retimer.h usb: typec: Add support for retimers 2022-07-14 16:24:05 +02:00
typec_tbt.h
uas.h
ulpi.h USB: Follow-up to SPDX identifiers addition - remove now useless comments 2022-06-10 11:24:36 +02:00
usb338x.h USB: Follow-up to SPDX GPL-2.0+ identifiers addition - remove now useless comments 2022-06-10 11:24:37 +02:00
usb_phy_generic.h
usbnet.h SPDX changes for 6.0-rc1 2022-08-04 12:12:54 -07:00
uvc.h usb: uvc: use v4l2_fill_fmtdesc instead of open coded format name 2023-01-31 09:40:43 +01:00
webusb.h usb: gadget: Use correct APIs and data types for UUID handling 2023-01-31 10:37:29 +01:00
xhci-dbgp.h USB: Follow-up to SPDX identifiers addition - remove now useless comments 2022-06-10 11:24:36 +02:00