Skip to contentSkip to conversation

Backport to fix CVE-2026-23031 in 5.15

PATCH In review Ruohan Lan 2 participants 5 messages Apr 3 – Apr 8

Subsystems (2)
lore
Share & tools
lore

Ruohan Lan

author
#0 lore raw

v2 cover Backport to fix CVE-2026-23031 in 5.15

v1->v2: Append the following two commits suggested by Marc Kleine-Budde [email protected], thank you. :
79a6d1bfe114 ("can: gs_usb: gs_usb_receive_bulk_callback(): unanchor URL on usb_submit_urb() error") 494fc029f662 ("can: gs_usb: gs_usb_receive_bulk_callback(): fix error message")

Marc Kleine-Budde (3):
can: gs_usb: gs_usb_receive_bulk_callback(): fix URB memory leak
can: gs_usb: gs_usb_receive_bulk_callback(): unanchor URL on
usb_submit_urb() error
can: gs_usb: gs_usb_receive_bulk_callback(): fix error message

 drivers/net/can/usb/gs_usb.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
Signature · 1 line
2.43.0
author
#1 lore raw

PATCH v2 1/3 can: gs_usb: gs_usb_receive_bulk_callback(): fix URB memory leak

From: Marc Kleine-Budde <[email protected]>

[ Upstream commit 7352e1d5932a0e777e39fa4b619801191f57e603 ]

In gs_can_open(), the URBs for USB-in transfers are allocated, added to the parent->rx_submitted anchor and submitted. In the complete callback gs_usb_receive_bulk_callback(), the URB is processed and resubmitted. In gs_can_close() the URBs are freed by calling usb_kill_anchored_urbs(parent->rx_submitted).

However, this does not take into account that the USB framework unanchors the URB before the complete function is called. This means that once an in-URB has been completed, it is no longer anchored and is ultimately not released in gs_can_close().

Fix the memory leak by anchoring the URB in the gs_usb_receive_bulk_callback() to the parent->rx_submitted anchor.

Fixes d08e973a77d1 ("can: gs_usb: Added support for the GS_USB CAN devices")

[ The variable usbcan was renamed to parent in
commit b6980ad3a90c ("can: gs_usb: uniformly use "parent" as variable name for struct gs_usb") introduced in v6.6. To backport to v5.15, replace parent with usbcan. ]

---
 drivers/net/can/usb/gs_usb.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/can/usb/gs_usb.c +2 -0
index ffa2a4d92d01..acffe11a0ae1 100644
@@ -402,6 +402,8 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
 			  usbcan
 			  );
 
+	usb_anchor_urb(urb, &usbcan->rx_submitted);
+
 	rc = usb_submit_urb(urb, GFP_ATOMIC);
 
 	/* USB failure take down all interfaces */
Signature · 1 line
2.43.0
author
#2 lore raw

PATCH v2 2/3 can: gs_usb: gs_usb_receive_bulk_callback(): unanchor URL on usb_submit_urb() error

In reply to Ruohan Lan

From: Marc Kleine-Budde <[email protected]>

[ Upstream commit 79a6d1bfe1148bc921b8d7f3371a7fbce44e30f7 ]

In commit 7352e1d5932a ("can: gs_usb: gs_usb_receive_bulk_callback(): fix URB memory leak"), the URB was re-anchored before usb_submit_urb() in gs_usb_receive_bulk_callback() to prevent a leak of this URB during cleanup.

However, this patch did not take into account that usb_submit_urb() could fail. The URB remains anchored and usb_kill_anchored_urbs(&parent->rx_submitted) in gs_can_close() loops infinitely since the anchor list never becomes empty.

To fix the bug, unanchor the URB when an usb_submit_urb() error occurs, also print an info message.

---
 drivers/net/can/usb/gs_usb.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/net/can/usb/gs_usb.c +7 -0
index acffe11a0ae1..134f830508d9 100644
@@ -405,6 +405,10 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
 	usb_anchor_urb(urb, &usbcan->rx_submitted);
 
 	rc = usb_submit_urb(urb, GFP_ATOMIC);
+	if (!rc)
+		return;
+
+	usb_unanchor_urb(urb);
 
 	/* USB failure take down all interfaces */
 	if (rc == -ENODEV) {
@@ -413,6 +417,9 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
 			if (usbcan->canch[rc])
 				netif_device_detach(usbcan->canch[rc]->netdev);
 		}
+	} else if (rc != -ESHUTDOWN && net_ratelimit()) {
+		netdev_info(netdev, "failed to re-submit IN URB: %pe\n",
+			    ERR_PTR(urb->status));
 	}
 }
 
Signature · 1 line
2.43.0
author
#3 lore raw

PATCH v2 3/3 can: gs_usb: gs_usb_receive_bulk_callback(): fix error message

In reply to Ruohan Lan

From: Marc Kleine-Budde <[email protected]>

[ Upstream commit 494fc029f662c331e06b7c2031deff3c64200eed ]

Sinc commit 79a6d1bfe114 ("can: gs_usb: gs_usb_receive_bulk_callback():
unanchor URL on usb_submit_urb() error") a failing resubmit URB will print an info message.

In the case of a short read where netdev has not yet been assigned, initialize as NULL to avoid dereferencing an undefined value. Also report the error value of the failed resubmit.

---
 drivers/net/can/usb/gs_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/can/usb/gs_usb.c +2 -2
index 134f830508d9..fd9a06850c95 100644
@@ -297,7 +297,7 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
 {
 	struct gs_usb *usbcan = urb->context;
 	struct gs_can *dev;
-	struct net_device *netdev;
+	struct net_device *netdev = NULL;
 	int rc;
 	struct net_device_stats *stats;
 	struct gs_host_frame *hf = urb->transfer_buffer;
@@ -419,7 +419,7 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
 		}
 	} else if (rc != -ESHUTDOWN && net_ratelimit()) {
 		netdev_info(netdev, "failed to re-submit IN URB: %pe\n",
-			    ERR_PTR(urb->status));
+			    ERR_PTR(rc));
 	}
 }
 
Signature · 1 line
2.43.0
maintainer
#4 lore raw

Re: [PATCH 5.15.y v2 1/3] can: gs_usb: gs_usb_receive_bulk_callback(): fix URB memory leak

In reply to Ruohan Lan
Quoted 1 line

can: gs_usb: gs_usb_receive_bulk_callback(): fix URB memory leak

All 3 patches queued for 5.15, thanks.