[PATCH 1/4] nvme: guard nvme_strlen() against all-space strings

Nilay Shroff nilay at linux.ibm.com
Wed Dec 2 06:06:31 PST 2026


On 12/1/26 5:23 PM, Guixin Liu wrote:
> nvme_strlen() strips the space padding from Identify Controller string
> fields without checking the remaining length. A device returning an
> all-space Model Number or Firmware Revision, which the NVMe spec's
> space padding rules allow, drives the index below zero and reads memory
> before the start of the buffer; with an all-space serial number in
> front of the model the walk keeps going into the preceding fields. The
> negative length then reaches dev_err() as a %.*s precision, which the
> kernel clamps to zero, so the field also prints empty.
> 
> Stop the loop at the start of the string, like wwid_show() already
> does.
> 
> Fixes: 2f0dad1719cbb ("nvme: add bug report info for global duplicate id")
> Cc:stable at vger.kernel.org
> Signed-off-by: Guixin Liu<kanie at linux.alibaba.com>

Looks good to me:

Reviewed-by: Nilay Shroff <nilay at linux.ibm.com>



More information about the Linux-nvme mailing list