android_kernel_samsung_a7y1.../drivers/usb/usbip
Malte Leip 164cfc5560 usb: usbip: fix isoc packet num validation in get_pipe
commit c409ca3be3c6ff3a1eeb303b191184e80d412862 upstream.

Backport of the upstream commit, which fixed c6688ef9f297.
c6688ef9f297 got backported as commit b6f826ba10dc, as the unavailable
function usb_endpoint_maxp_mult had to be replaced. The upstream commit
removed the call to this function, so the backport is straightforward.

Original commit message:

Change the validation of number_of_packets in get_pipe to compare the
number of packets to a fixed maximum number of packets allowed, set to
be 1024. This number was chosen due to it being used by other drivers as
well, for example drivers/usb/host/uhci-q.c

Background/reason:
The get_pipe function in stub_rx.c validates the number of packets in
isochronous mode and aborts with an error if that number is too large,
in order to prevent malicious input from possibly triggering large
memory allocations. This was previously done by checking whether
pdu->u.cmd_submit.number_of_packets is bigger than the number of packets
that would be needed for pdu->u.cmd_submit.transfer_buffer_length bytes
if all except possibly the last packet had maximum length, given by
usb_endpoint_maxp(epd) *  usb_endpoint_maxp_mult(epd). This leads to an
error if URBs with packets shorter than the maximum possible length are
submitted, which is allowed according to
Documentation/driver-api/usb/URB.rst and occurs for example with the
snd-usb-audio driver.

Fixes: b6f826ba10dc ("usbip: fix stub_rx: harden CMD_SUBMIT path to handle malicious input")
Signed-off-by: Malte Leip <malte@leip.net>
Cc: stable <stable@vger.kernel.org> # 4.4.x
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-04-06 16:42:34 +02:00
..
Kconfig A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
Makefile A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
README A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
stub_dev.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
stub_main.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
stub_rx.c usb: usbip: fix isoc packet num validation in get_pipe 2020-04-06 16:42:34 +02:00
stub_tx.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
stub.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
usbip_common.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
usbip_common.h usb: usbip: fix isoc packet num validation in get_pipe 2020-04-06 16:42:34 +02:00
usbip_event.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
usbip_protocol.txt A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
vhci_hcd.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
vhci_rx.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
vhci_sysfs.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
vhci_tx.c A750FXXU4CTBC 2020-03-27 21:51:54 +05:30
vhci.h A750FXXU4CTBC 2020-03-27 21:51:54 +05:30

TODO:
	- more discussion about the protocol
	- testing
	- review of the userspace interface
	- document the protocol

Please send patches for this code to Greg Kroah-Hartman <greg@kroah.com>