Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1675666

[PATCH 4.4 17/26] USB: usbip: fix nonconforming hub descriptor

From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 4.4 17/26] USB: usbip: fix nonconforming hub descriptor
Date 2017-06-27 15:00 +0200
Message-ID <tWYg5-C4-91@gated-at.bofh.it> (permalink)
References <tWYg2-C4-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Johan Hovold <johan@kernel.org>

commit ec963b412a54aac8e527708ecad06a6988a86fb4 upstream.

Fix up the root-hub descriptor to accommodate the variable-length
DeviceRemovable and PortPwrCtrlMask fields, while marking all ports as
removable (and leaving the reserved bit zero unset).

Also add a build-time constraint on VHCI_HC_PORTS which must never be
greater than USB_MAXCHILDREN (but this was only enforced through a
KConfig constant).

This specifically fixes the descriptor layout whenever VHCI_HC_PORTS is
greater than seven (default is 8).

Fixes: 04679b3489e0 ("Staging: USB/IP: add client driver")
Cc: Takahiro Hirofuchi <hirofuchi@users.sourceforge.net>
Cc: Valentina Manea <valentina.manea.m@gmail.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Acked-by: Shuah Khan <shuahkh@osg.samsung.com>
[ johan: backport to v4.4, which uses VHCI_NPORTS ]
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/usb/usbip/vhci_hcd.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -215,14 +215,19 @@ done:
 
 static inline void hub_descriptor(struct usb_hub_descriptor *desc)
 {
+	int width;
+
 	memset(desc, 0, sizeof(*desc));
 	desc->bDescriptorType = USB_DT_HUB;
-	desc->bDescLength = 9;
 	desc->wHubCharacteristics = cpu_to_le16(
 		HUB_CHAR_INDV_PORT_LPSM | HUB_CHAR_COMMON_OCPM);
+
 	desc->bNbrPorts = VHCI_NPORTS;
-	desc->u.hs.DeviceRemovable[0] = 0xff;
-	desc->u.hs.DeviceRemovable[1] = 0xff;
+	BUILD_BUG_ON(VHCI_NPORTS > USB_MAXCHILDREN);
+	width = desc->bNbrPorts / 8 + 1;
+	desc->bDescLength = USB_DT_HUB_NONVAR_SIZE + 2 * width;
+	memset(&desc->u.hs.DeviceRemovable[0], 0, width);
+	memset(&desc->u.hs.DeviceRemovable[width], 0xff, width);
 }
 
 static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 4.4 00/26] 4.4.75-stable review Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-27 15:00 +0200
  [PATCH 4.4 01/26] fs/exec.c: account for argv/envp pointers Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-27 15:00 +0200
  [PATCH 4.4 10/26] time: Fix clock->read(clock) race around clocksource changes Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-27 15:00 +0200
  [PATCH 4.4 13/26] drm/radeon: add a PX quirk for another K53TK variant Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-27 15:00 +0200
  [PATCH 4.4 07/26] signal: Only reschedule timers on signals timers have sent Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-27 15:00 +0200
  [PATCH 4.4 14/26] drm/radeon: add a quirk for Toshiba Satellite L20-183 Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-27 15:00 +0200
  [PATCH 4.4 04/26] KVM: PPC: Book3S HV: Preserve userspace HTM state properly Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-27 15:00 +0200
  [PATCH 4.4 17/26] USB: usbip: fix nonconforming hub descriptor Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-27 15:00 +0200
  [PATCH 4.4 11/26] target: Fix kref->refcount underflow in transport_cmd_finish_abort Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-27 15:00 +0200
  [PATCH 4.4 05/26] CIFS: Improve readdir verbosity Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-27 15:00 +0200
  [PATCH 4.4 03/26] lib/cmdline.c: fix get_options() overflow while parsing ranges Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-27 15:00 +0200
    Re: [PATCH 4.4 03/26] lib/cmdline.c: fix get_options() overflow  while parsing ranges Ben Hutchings <ben.hutchings@codethink.co.uk> - 2017-06-29 20:30 +0200
  [PATCH 4.4 09/26] Input: i8042 - add Fujitsu Lifebook AH544 to notimeout list Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-27 15:00 +0200
  [PATCH 4.4 26/26] nvme: apply DELAY_BEFORE_CHK_RDY quirk at probe time too Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-27 15:00 +0200
  [PATCH 4.4 19/26] of: Add check to of_scan_flat_dt() before accessing initial_boot_params Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-27 15:00 +0200
  Re: [PATCH 4.4 00/26] 4.4.75-stable review Guenter Roeck <linux@roeck-us.net> - 2017-06-27 21:10 +0200
  Re: [PATCH 4.4 00/26] 4.4.75-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2017-06-28 16:00 +0200

csiph-web