Linux USB
 help / color / mirror / Atom feed
* [RESEND PATCH] usbip: vudc: fix NULL pointer dereference in vep_dequeue()
@ 2026-07-02  8:12 raoxu
  2026-07-02  8:38 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: raoxu @ 2026-07-02  8:12 UTC (permalink / raw)
  To: valentina.manea.m; +Cc: shuah, gregkh, i, linux-usb, linux-kernel, raoxu

From: Xu Rao <raoxu@uniontech.com>

vep_alloc_request() zero-initializes struct vrequest but never assigns
vrequest::udc. vep_dequeue() then reads that field and dereferences it
while checking udc->driver. Consequently, any usb_ep_dequeue() call that
reaches the vUDC dequeue operation can crash the kernel.

The endpoint passed to ->dequeue() identifies both the request queue
being searched and the owning vUDC. Derive the controller from that
endpoint with ep_to_vudc(), as the other endpoint operations do.

After this change, vrequest::udc has no users. Remove the redundant
controller backpointer.

Fixes: b6a0ca111867 ("usbip: vudc: Add UDC specific ops")
Signed-off-by: Xu Rao <raoxu@uniontech.com>
---
 drivers/usb/usbip/vudc.h     | 1 -
 drivers/usb/usbip/vudc_dev.c | 4 +---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/usb/usbip/vudc.h b/drivers/usb/usbip/vudc.h
index faf61c9c6a98..5ef0e7d9b23a 100644
--- a/drivers/usb/usbip/vudc.h
+++ b/drivers/usb/usbip/vudc.h
@@ -38,7 +38,6 @@ struct vep {

 struct vrequest {
 	struct usb_request req;
-	struct vudc *udc;
 	struct list_head req_entry; /* Request queue */
 };

diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c
index c5f079c5a1ea..5ef88117965d 100644
--- a/drivers/usb/usbip/vudc_dev.c
+++ b/drivers/usb/usbip/vudc_dev.c
@@ -333,7 +333,6 @@ static int vep_queue(struct usb_ep *_ep, struct usb_request *_req,
 static int vep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 {
 	struct vep *ep;
-	struct vrequest *req;
 	struct vudc *udc;
 	struct vrequest *lst;
 	unsigned long flags;
@@ -343,8 +342,7 @@ static int vep_dequeue(struct usb_ep *_ep, struct usb_request *_req)
 		return ret;

 	ep = to_vep(_ep);
-	req = to_vrequest(_req);
-	udc = req->udc;
+	udc = ep_to_vudc(ep);

 	if (!udc->driver)
 		return -ESHUTDOWN;
--
2.50.1


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

end of thread, other threads:[~2026-07-02  8:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-02  8:12 [RESEND PATCH] usbip: vudc: fix NULL pointer dereference in vep_dequeue() raoxu
2026-07-02  8:38 ` Greg KH

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