Linux USB
 help / color / mirror / Atom feed
* [PATCH] xen: fix potential shift out-of-bounds in xenhcd_hub_control()
@ 2023-06-25 16:42 Zhang Shurong
  2023-06-26  5:48 ` Jan Beulich
  0 siblings, 1 reply; 9+ messages in thread
From: Zhang Shurong @ 2023-06-25 16:42 UTC (permalink / raw)
  To: jgross; +Cc: gregkh, xen-devel, linux-usb, linux-kernel, Zhang Shurong

Fix potential shift out-of-bounds in xenhcd_hub_control()
ClearPortFeature handling and SetPortFeature handling.

wValue may be greater than 32 which can not be used for shifting.

similar patch:
https://patchwork.kernel.org/patch/12162547

Signed-off-by: Zhang Shurong <zhang_shurong@foxmail.com>
---
 drivers/usb/host/xen-hcd.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/xen-hcd.c b/drivers/usb/host/xen-hcd.c
index 46fdab940092..c0e7207d3857 100644
--- a/drivers/usb/host/xen-hcd.c
+++ b/drivers/usb/host/xen-hcd.c
@@ -456,6 +456,8 @@ static int xenhcd_hub_control(struct usb_hcd *hcd, __u16 typeReq, __u16 wValue,
 			info->ports[wIndex - 1].c_connection = false;
 			fallthrough;
 		default:
+			if (wValue >= 32)
+				goto error;
 			info->ports[wIndex - 1].status &= ~(1 << wValue);
 			break;
 		}
@@ -527,6 +529,8 @@ static int xenhcd_hub_control(struct usb_hcd *hcd, __u16 typeReq, __u16 wValue,
 			xenhcd_rhport_suspend(info, wIndex);
 			break;
 		default:
+			if (wValue >= 32)
+				goto error;
 			if (info->ports[wIndex-1].status & USB_PORT_STAT_POWER)
 				info->ports[wIndex-1].status |= (1 << wValue);
 		}
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-08-08 19:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-25 16:42 [PATCH] xen: fix potential shift out-of-bounds in xenhcd_hub_control() Zhang Shurong
2023-06-26  5:48 ` Jan Beulich
2023-06-26  5:52   ` Greg KH
2023-07-01 15:51     ` Zhang Shurong
     [not found]     ` <4825193.GXAFRqVoOG@localhost.localdomain>
2023-08-06 14:11       ` Zhang Shurong
2023-08-06 14:27         ` Greg KH
2023-08-06 15:15           ` Alan Stern
2023-08-08  8:26             ` Greg KH
2023-08-08 15:05               ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox