Skip to content

Commit b348d7d

Browse files
ignatkgregkh
authored andcommitted
USB: usbip: fix potential out-of-bounds write
Fix potential out-of-bounds write to urb->transfer_buffer usbip handles network communication directly in the kernel. When receiving a packet from its peer, usbip code parses headers according to protocol. As part of this parsing urb->actual_length is filled. Since the input for urb->actual_length comes from the network, it should be treated as untrusted. Any entity controlling the network may put any value in the input and the preallocated urb->transfer_buffer may not be large enough to hold the data. Thus, the malicious entity is able to write arbitrary data to kernel memory. Signed-off-by: Ignat Korchagin <ignat.korchagin@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8ef34aa commit b348d7d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Diff for: drivers/usb/usbip/usbip_common.c

+11
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,17 @@ int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb)
741741
if (!(size > 0))
742742
return 0;
743743

744+
if (size > urb->transfer_buffer_length) {
745+
/* should not happen, probably malicious packet */
746+
if (ud->side == USBIP_STUB) {
747+
usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);
748+
return 0;
749+
} else {
750+
usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
751+
return -EPIPE;
752+
}
753+
}
754+
744755
ret = usbip_recv(ud->tcp_socket, urb->transfer_buffer, size);
745756
if (ret != size) {
746757
dev_err(&urb->dev->dev, "recv xbuf, %d\n", ret);

0 commit comments

Comments
 (0)