diff --git a/patches.suse/usb-early-xhci-dbc-Fix-a-potential-out-of-bound-memo.patch b/patches.suse/usb-early-xhci-dbc-Fix-a-potential-out-of-bound-memo.patch new file mode 100644 index 0000000..c6d02e7 --- /dev/null +++ b/patches.suse/usb-early-xhci-dbc-Fix-a-potential-out-of-bound-memo.patch @@ -0,0 +1,41 @@ +From a4a97ab3db5c081eb6e7dba91306adefb461e0bd Mon Sep 17 00:00:00 2001 +From: Christophe JAILLET +Date: Sun, 29 Jan 2023 19:23:08 +0100 +Subject: [PATCH] usb: early: xhci-dbc: Fix a potential out-of-bound memory + access +Git-commit: a4a97ab3db5c081eb6e7dba91306adefb461e0bd +References: git-fixes +Patch-mainline: v6.3-rc1 + +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 +Link: https://lore.kernel.org/r/d6a7562c5e839a195cee85db6dc81817f9372cb1.1675016180.git.christophe.jaillet@wanadoo.fr +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Oliver Neukum +--- + drivers/usb/early/xhci-dbc.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +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 @@ static int xdbc_bulk_write(const char *bytes, int size) + + 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; + +-- +2.40.1 + diff --git a/series.conf b/series.conf index e81a719..88b369c 100644 --- a/series.conf +++ b/series.conf @@ -63237,6 +63237,7 @@ patches.suse/nfsd-fix-race-to-check-ls_layouts.patch patches.suse/tracing-Add-NULL-checks-for-buffer-in-ring_buffer_free_read_page.patch patches.suse/fotg210-udc-Add-missing-completion-handler.patch + patches.suse/usb-early-xhci-dbc-Fix-a-potential-out-of-bound-memo.patch patches.suse/applicom-Fix-PCI-device-refcount-leak-in-applicom_in.patch patches.suse/powerpc-powernv-ioda-Skip-unallocated-resources-when.patch patches.suse/powerpc-pseries-lpar-add-missing-RTAS-retry-status-h.patch