Test report for [PATCH 6/6] usbip: vhci_sysfs: Use safer strscpy() instead of strcpy()
From: Ai Chao
Date: Wed Mar 25 2026 - 22:51:33 EST
Dear Shuah:
Environment:
Kernel Version: v6.12.76+ (with patch applied)
Hardware/QEMU: Thinkpad E15
Userspace Tools: usbip-utils 2.0
Config: CONFIG_USBIP_VHCI_HCD=m
Test Cases Executed:
Build Test: Compiled successfully , no sparse warnings.
Basic Functionality: Successfully /sys/bus/platform/drivers/vhci_hcd/vhci_hcd.0/status
Stress Test: N/A
Error Handling: N/A
Attached dmesg log showing successful enumeration and clean teardown.
[ 118.736416] usbcore: registered new device driver usbip-host
[ 128.833296] vhci_hcd vhci_hcd.0: USB/IP Virtual Host Controller
[ 128.833354] vhci_hcd vhci_hcd.0: new USB bus registered, assigned bus number 5
[ 128.833361] vhci_hcd: created sysfs vhci_hcd.0
[ 128.833381] usb usb5: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 6.12
[ 128.833383] usb usb5: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 128.833384] usb usb5: Product: USB/IP Virtual Host Controller
[ 128.833385] usb usb5: Manufacturer: Linux 6.12.76+ vhci_hcd
[ 128.833386] usb usb5: SerialNumber: vhci_hcd.0
[ 128.833449] hub 5-0:1.0: USB hub found
[ 128.833454] hub 5-0:1.0: 8 ports detected
[ 128.833569] vhci_hcd vhci_hcd.0: USB/IP Virtual Host Controller
[ 128.833601] vhci_hcd vhci_hcd.0: new USB bus registered, assigned bus number 6
[ 128.833613] usb usb6: We don't know the algorithms for LPM for this host, disabling LPM.
[ 128.833622] usb usb6: New USB device found, idVendor=1d6b, idProduct=0003, bcdDevice= 6.12
[ 128.833624] usb usb6: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[ 128.833625] usb usb6: Product: USB/IP Virtual Host Controller
[ 128.833626] usb usb6: Manufacturer: Linux 6.12.76+ vhci_hcd
[ 128.833626] usb usb6: SerialNumber: vhci_hcd.0
[ 128.833687] hub 6-0:1.0: USB hub found
[ 128.833691] hub 6-0:1.0: 8 ports detected
(Optional) Attached kmemleak output showing no leaks.
Code:
#define MAX_STATUS_NAME 16
struct status_attr {
struct device_attribute attr;
char name[MAX_STATUS_NAME+1];
};
static struct status_attr *status_attrs;
struct status_attr *status;
First:
strcpy(status->name, "status");
strscpy(status->name, "status");
aichao@PC:vhci_hcd.0$ cat status
hub port sta spd dev sockfd local_busid
hs 0000 004 000 00000000 000000 0-0
... ...
ss 0015 004 000 00000000 000000 0-0
Second:
strcpy(status->name, "status-abcdefghijklmnopqrstuvwxyz1234567890");
aichao@PC:vhci_hcd.0$ cat status-abcdefghijklmnopqrstuvwxyz1234567890
hub port sta spd dev sockfd local_busid
hs 0000 004 000 00000000 000000 0-0
... ...
ss 0015 004 000 00000000 000000 0-0
Third:
strscpy(status->name, "status-abcdefghijklmnopqrstuvwxyz1234567890");
aichao@PC:vhci_hcd.0$ cat status-abcdefghi
hub port sta spd dev sockfd local_busid
hs 0000 004 000 00000000 000000 0-0
... ...
ss 0015 004 000 00000000 000000 0-0
Conclusion:
The longth of the name is MAX_STATUS_NAME+1 = 17, used the strcpy copy "status-abcdefghijklmnopqrstuvwxyz1234567890" in name and used strscpy copy "status-abcdefghi" in name.
Tested-by: Aichao@xxxxxxxxxx
thanks.
--