summaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/xhci-debugfs.c
diff options
context:
space:
mode:
authorMathias Nyman <mathias.nyman@linux.intel.com>2021-08-20 14:34:58 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-08-26 13:06:02 +0200
commitcbf286e8ef8337308c259ff5b9ce2e74d403be5a (patch)
tree479a55e4b2d6287bbeb785e4a129085995aa4cd3 /drivers/usb/host/xhci-debugfs.c
parentusb: gadget: f_hid: optional SETUP/SET_REPORT mode (diff)
downloadlinux-cbf286e8ef8337308c259ff5b9ce2e74d403be5a.tar.xz
linux-cbf286e8ef8337308c259ff5b9ce2e74d403be5a.zip
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 Cc: <stable@vger.kernel.org> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com> Link: https://lore.kernel.org/r/20210820123503.2605901-2-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/xhci-debugfs.c')
-rw-r--r--drivers/usb/host/xhci-debugfs.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugfs.c
index 2c0fda57869e..85c12f56b17c 100644
--- a/drivers/usb/host/xhci-debugfs.c
+++ b/drivers/usb/host/xhci-debugfs.c
@@ -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;
}