Re: [PATCH] usb: xhci: fix missing null termination after copy_from_user()

From: Greg KH

Date: Sat Jan 17 2026 - 04:58:44 EST


On Sat, Jan 17, 2026 at 09:46:31AM +0000, Weigang He wrote:
> The buffer 'buf' is filled by copy_from_user() but is not properly
> null-terminated before being used with strncmp(). If userspace provides
> fewer than 10 bytes, strncmp() may read beyond the copied data into
> uninitialized stack memory.

But that's fine, it will not match the check, and so it will stop when
told, so no overflow happens anywhere.

> Add explicit null termination after copy_from_user() to ensure the
> buffer is always a valid C string before string operations.

It's ok, and is valid, and this is all debugging code. This isn't a
real bug, sorry.

> Fixes: 87a03802184c ("xhci: debugfs: add debugfs interface to enable compliance mode for a port")
> Cc: stable@xxxxxxxxxxxxxxx

Nope, this doesn't "fix" anything.

How was this bug found? What tool did you use for this? How was it tested?

thanks,

greg k-h