patch "xhci: fix unsafe memory usage in xhci tracing" added to usb-next
Subsystems (3)
This is a note to let you know that I've just added the patch titled
xhci: fix unsafe memory usage in xhci tracing
to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-next branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will also be merged in the next major kernel release during the merge window.
If you have any questions about this process, please let me know.
From cbf286e8ef8337308c259ff5b9ce2e74d403be5a Mon Sep 17 00:00:00 2001
From: Mathias Nyman <[email protected]>
Date: Fri, 20 Aug 2021 15:34:58 +0300
Subject: xhci: fix unsafe memory usage in xhci tracing
Removes static char buffer usage in the following decode functions:
xhci_decode_trb()
xhci_decode_ptortsc()
Caller must provide a buffer to use.
In tracing use __get_str() as recommended to pass buffer.
Minor chanes are needed in xhci debugfs code as these functions are also used there. Changes include moving XHCI_MSG_MAX definititon from xhci-trace.h to xhci.h
--- drivers/usb/host/xhci-debugfs.c | 6 ++-- drivers/usb/host/xhci-trace.h | 8 ++--- drivers/usb/host/xhci.h | 52 ++++++++++++++++++--------------- 3 files changed, 36 insertions(+), 30 deletions(-)
drivers/usb/host/xhci-debugfs.c +4 -2
@@ -198,12 +198,13 @@ static void xhci_ring_dump_segment(struct seq_file *s,int i;dma_addr_t dma;union xhci_trb *trb; +char str[XHCI_MSG_MAX ];for (i =0 ; i <TRBS_PER_SEGMENT ; i++) { trb = &seg->trbs[i]; dma = seg->dma + i *sizeof (*trb);seq_printf (s,"%pad: %s\n" , &dma, -xhci_decode_trb (le32_to_cpu (trb->generic.field[0 ]), +xhci_decode_trb (str,XHCI_MSG_MAX ,le32_to_cpu (trb->generic.field[0 ]),le32_to_cpu (trb->generic.field[1 ]),le32_to_cpu (trb->generic.field[2 ]),le32_to_cpu (trb->generic.field[3 ])));
@@ -341,9 +342,10 @@ static int xhci_portsc_show(struct seq_file *s, void *unused) {struct xhci_port *port = s->private;u32 portsc; +char str[XHCI_MSG_MAX ]; portsc =readl (port->addr); -seq_printf (s,"%s\n" ,xhci_decode_portsc (portsc)); +seq_printf (s,"%s\n" ,xhci_decode_portsc (str, portsc));return 0 ; }
drivers/usb/host/xhci-trace.h +4 -4
@@ -25,8 +25,6 @@#include "xhci.h" #include "xhci-dbgcap.h" -#define XHCI_MSG_MAX 500 - DECLARE_EVENT_CLASS(xhci_log_msg, TP_PROTO(struct va_format *vaf), TP_ARGS(vaf),
@@ -122,6 +120,7 @@ DECLARE_EVENT_CLASS(xhci_log_trb, __field(u32, field1) __field(u32, field2) __field(u32, field3) +__dynamic_array (char, str,XHCI_MSG_MAX ) ),TP_fast_assign ( __entry->type = ring->type;
@@ -131,7 +130,7 @@ DECLARE_EVENT_CLASS(xhci_log_trb, __entry->field3 =le32_to_cpu (trb->field[3 ]); ),TP_printk ("%s: %s" ,xhci_ring_type_string (__entry->type), -xhci_decode_trb (__entry->field0, __entry->field1, +xhci_decode_trb (__get_str (str),XHCI_MSG_MAX , __entry->field0, __entry->field1, __entry->field2, __entry->field3) ) );
@@ -523,6 +522,7 @@ DECLARE_EVENT_CLASS(xhci_log_portsc,TP_STRUCT__entry (__field (u32 ,portnum )__field (u32, portsc) +__dynamic_array (char, str,XHCI_MSG_MAX ) ),TP_fast_assign ( __entry->portnum = portnum;
@@ -530,7 +530,7 @@ DECLARE_EVENT_CLASS(xhci_log_portsc, ),TP_printk ("port-%d: %s" , __entry->portnum, -xhci_decode_portsc (__entry->portsc) +xhci_decode_portsc (__get_str (str), __entry->portsc) ) );
drivers/usb/host/xhci.h +28 -24
184 lines not on this page · raw message
Signature · 1 line
2.32.0