[systemd-devel] usb_id gets bogus serial and makes a mess
Robert Milasan
rmilasan at suse.com
Sun Feb 10 02:12:09 PST 2013
On Thu, 7 Feb 2013 15:52:20 +0100
"Robert Milasan" <RMilasan at suse.com> wrote:
> Hi, seems that using some strange usb devices with really bogus serial
> numbers usb_id creates links with junk strings in it:
>
> /dev/disk/by-id/usb-TSSTcorp_BDDVDW_SE-506AB_㡒䍌䜶䉗ぁㄴ㌴†ँ-0:0
>
> Initially was believed that usb_id is to blame, then the kernel, but
> it turns out that really the usb cd/dvd drive has this bogus serial
> number:
>
> output from dmesg:
> [ 538.200160] usb 1-2: new high-speed USB device number 5 using
> ehci_hcd [ 538.335067] usb 1-2: New USB device found, idVendor=0e8d,
> idProduct=1956 [ 538.335080] usb 1-2: New USB device strings: Mfr=1,
> Product=2, SerialNumber=3 [ 538.335089] usb 1-2: Product: MT1956
> [ 538.335097] usb 1-2: Manufacturer: MediaTek Inc
> [ 538.335105] usb 1-2: SerialNumber:
> \xffffffe3\xffffffa1\xffffff92\xffffffe4\xffffff8d\xffffff8c\xffffffe4\xffffff9c\xffffffb6\xffffffe4\xffffff89\xffffff97\xffffffe3\xffffff81\xffffff81\xffffffe3\xffffff84\xffffffb4\xffffffe3\xffffff8c\xffffffb4\xffffffe2\xffffff80\xffffffa0\xffffffe0\xffffffa4\xffffff81
> [ 538.337540] scsi6 : usb-storage 1-2:1.0 [ 539.341385] scsi
> 6:0:0:0: CD-ROM TSSTcorp BDDVDW SE-506AB TS00 PQ: 0 ANSI:
> 0 [ 539.354240] sr0: scsi3-mmc drive: 0x/24x writer dvd-ram cd/rw
> xa/form2 cdda tray [ 539.354777] sr 6:0:0:0: Attached scsi CD-ROM sr0
> [ 539.355122] sr 6:0:0:0: Attached scsi generic sg2 type 5
>
> output of command: udevadm test-builtin usb_id /block/sr0
> udev_device_new_from_syspath: device 0x9c84d58 has devpath
> '/devices/pci0000:00/0000:00:1d.7/usb1/1-2' udev_builtin_add_property:
> ID_VENDOR=TSSTcorp udev_builtin_add_property: ID_VENDOR_ENC=TSSTcorp
> udev_builtin_add_property: ID_VENDOR_ID=0e8d
> udev_builtin_add_property: ID_MODEL=BDDVDW_SE-506AB
> udev_builtin_add_property: ID_MODEL_ENC=BDDVDW\x20SE-506AB\x20
> udev_builtin_add_property: ID_MODEL_ID=1956
> udev_builtin_add_property: ID_REVISION=TS00
> udev_builtin_add_property:
> ID_SERIAL=TSSTcorp_BDDVDW_SE-506AB_㡒䍌䜶䉗ぁㄴ㌴†ँ-0:0
> udev_builtin_add_property: ID_SERIAL_SHORT=㡒䍌䜶䉗ぁㄴ㌴†ँ
> udev_builtin_add_property: ID_TYPE=cd udev_builtin_add_property:
> ID_INSTANCE=0:0 udev_builtin_add_property: ID_BUS=usb
> udev_builtin_add_property: ID_USB_INTERFACES=:080250:
> udev_builtin_add_property: ID_USB_INTERFACE_NUM=00
> udev_builtin_add_property: ID_USB_DRIVER=usb-storage
>
> Wouldn't be a good idea to add a string validator for the serial
> number and if it doesn't fall into the valid options, then just set
> the serial to 000000000000000000000 or something like this?
>
> I'm not sure, but don't think from the usb_id point the serial matters
> too much.
>
> Was thinking that this function:
>
> static bool valid_string(const char *serial)
> {
> const char *s;
>
> if (!serial)
> return false;
> for (s = serial; *s != '\0'; s++) {
> if ((*s >= 'a' && *s <= 'z') ||
> (*s >= 'A' && *s <= 'Z') ||
> (*s >= '0' && *s <= '9') ||
> *s == '-' || *s == '_')
> continue;
> else
> return false;
> }
> return true;
> }
>
> Could be added to usb_id and then use it to validated serial_str and
> serial.
>
Here is a simple patch, just don't use the serial if it's bogus.
--
Robert Milasan
L3 Support Engineer
SUSE Linux (http://www.suse.com)
email: rmilasan at suse.com
GPG fingerprint: B6FE F4A8 0FA3 3040 3402 6FE7 2F64 167C 1909 6D1A
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-usb_id-some-strange-devices-have-a-very-bogus-or-strage-serial.patch
Type: text/x-patch
Size: 1873 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20130210/efcbad94/attachment.bin>
More information about the systemd-devel
mailing list