Skip to contentSkip to conversation

usb: host: xhci: use snprintf() in xhci_decode_trb()

PATCH In review Sergey Shtylyov 2 participants 3 messages Mar 16, 2022 – May 18, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: host: xhci: use snprintf() in xhci_decode_trb()

Commit cbf286e8ef83 ("xhci: fix unsafe memory usage in xhci tracing") apparently missed one sprintf() call in xhci_decode_trb() -- replace it with the snprintf() call as well...

Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.

Fixes cbf286e8ef83 ("xhci: fix unsafe memory usage in xhci tracing")

---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo.

 drivers/usb/host/xhci.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci.h +1 -1
Index: usb/drivers/usb/host/xhci.h
===================================================================
@@ -2391,7 +2391,7 @@ static inline const char *xhci_decode_tr
 			field3 & TRB_CYCLE ? 'C' : 'c');
 		break;
 	case TRB_STOP_RING:
-		sprintf(str,
+		snprintf(str, size,
 			"%s: slot %d sp %d ep %d flags %c",
 			xhci_trb_type_string(type),
 			TRB_TO_SLOT_ID(field3),
#1 lore raw

Hello!

Quoted 4 lines · Sergey Shtylyov

Commit cbf286e8ef83 ("xhci: fix unsafe memory usage in xhci tracing") apparently missed one sprintf() call in xhci_decode_trb() -- replace it with the snprintf() call as well...

Quoted 8 lines

Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.

Fixes cbf286e8ef83 ("xhci: fix unsafe memory usage in xhci tracing")

---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo.

Mathias, Greg, what's going on with this patch? It was posted 2 months ago
and seemingly ignored... :-/

MBR, Sergey

#2 lore raw
Quoted 14 lines · Sergey Shtylyov

Hello!

Quoted 10 lines · Sergey Shtylyov

Commit cbf286e8ef83 ("xhci: fix unsafe memory usage in xhci tracing") apparently missed one sprintf() call in xhci_decode_trb() -- replace it with the snprintf() call as well...

Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool.

Fixes cbf286e8ef83 ("xhci: fix unsafe memory usage in xhci tracing")
Quoted 7 lines
Quoted 2 lines

---
This patch is against the 'usb-next' branch of Greg KH's 'usb.git' repo.

Mathias, Greg, what's going on with this patch? It was posted 2 months ago
and seemingly ignored... :-/

MBR, Sergey

Must have missed it

I'll queue it up for 5.20 unless Greg still picks it up for 5.19. Not urgent.

-Mathias