summaryrefslogtreecommitdiff
path: root/drivers/usb/early
diff options
context:
space:
mode:
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>2023-01-29 21:23:08 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-03-10 11:28:53 +0300
commitdf7c8aba7309f4dc55df94e06b67f576c0f52406 (patch)
tree0fda6559cfe8547b545a80ed5b5b531c98696caf /drivers/usb/early
parentf44b50c7700068db4d544b7f47bab33e324ba6c3 (diff)
downloadlinux-df7c8aba7309f4dc55df94e06b67f576c0f52406.tar.xz
usb: early: xhci-dbc: Fix a potential out-of-bound memory access
[ Upstream commit a4a97ab3db5c081eb6e7dba91306adefb461e0bd ] If xdbc_bulk_write() fails, the values in 'buf' can be anything. So the string is not guaranteed to be NULL terminated when xdbc_trace() is called. Reserve an extra byte, which will be zeroed automatically because 'buf' is a static variable, in order to avoid troubles, should it happen. Fixes: aeb9dd1de98c ("usb/early: Add driver for xhci debug capability") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/r/d6a7562c5e839a195cee85db6dc81817f9372cb1.1675016180.git.christophe.jaillet@wanadoo.fr Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/usb/early')
-rw-r--r--drivers/usb/early/xhci-dbc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c
index 797047154820..f3e23be227d4 100644
--- a/drivers/usb/early/xhci-dbc.c
+++ b/drivers/usb/early/xhci-dbc.c
@@ -874,7 +874,8 @@ retry:
static void early_xdbc_write(struct console *con, const char *str, u32 n)
{
- static char buf[XDBC_MAX_PACKET];
+ /* static variables are zeroed, so buf is always NULL terminated */
+ static char buf[XDBC_MAX_PACKET + 1];
int chunk, ret;
int use_cr = 0;