udevadm_info incorrectly splits string

Bug #1895021 reported by Sergey Bykov
30
This bug affects 3 people
Affects Status Importance Assigned to Milestone
curtin
Fix Released
Undecided
Unassigned

Bug Description

In udevadm_info the below code is called to split output lines:
    key, value = line.split('=', 2)

It can lead to unhandled exception if there are more than one equal sign in the string as split will return array of three or more elements. The correct way to get only two elements is
to use maxsplit=1:
        key, value = line.split('=', 1)

For example:
    >>> line = "1='2=3'"
    >>> line.split('=', 2)
    ['1', "'2", "3'"]
    >>> key, value = line.split('=', 2)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ValueError: too many values to unpack

Related branches

Revision history for this message
Sergey Bykov (sbykov) wrote :
Ryan Harper (raharper)
Changed in curtin:
status: New → Confirmed
Revision history for this message
Ryan Harper (raharper) wrote :

Hi Sergey,

Thanks for the bug and the fix!

Would you be interested in contributing the fix? If so:

https://curtin.readthedocs.io/en/latest/topics/hacking.html

I'm also interested in if you have actual udevadm info output that includes multiple '=' in a line.
The fix is 100% correct, just wondering if you ran into a real device with that included.

Revision history for this message
Sergey Bykov (sbykov) wrote :

Hi Ryan,

Thanks for your reply. I have submmited a merge request for this issue.

Yes, we ran into the issue when we were qualifying Ubuntu 20.04 to run on our platform. Our SCSI adapter advertises SCSI_IDENT_TARGET_VENDOR as "clusterid='<CLUSTER_ID>'", where <CLUSTER_ID> is unique cluster identifier.

Example of udevadm output:
~$ udevadm info --query=property --export /dev/sda
DEVPATH='/devices/pci0000:00/0000:00:04.0/virtio1/host2/target2:0:0/2:0:0:0/block/sda'
DEVNAME='/dev/sda'
DEVTYPE='disk'
MAJOR='8'
MINOR='0'
SUBSYSTEM='block'
USEC_INITIALIZED='1614194'
SCSI_TPGS='1'
SCSI_TYPE='disk'
SCSI_VENDOR='NUTANIX'
SCSI_VENDOR_ENC='NUTANIX\x20'
SCSI_MODEL='VDISK'
SCSI_MODEL_ENC='VDISK\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'
SCSI_REVISION='0'
ID_SCSI='1'
ID_SCSI_INQUIRY='1'
ID_VENDOR='NUTANIX'
ID_VENDOR_ENC='NUTANIX\x20'
ID_MODEL='VDISK'
ID_MODEL_ENC='VDISK\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'
ID_REVISION='0'
ID_TYPE='disk'
SCSI_IDENT_SERIAL='NFS_3_0_464_e4ff5521_9a50_444b_ae4d_9d1f5108191b'
SCSI_IDENT_LUN_T10='NUTANIX_NFS_3_0_464_e4ff5521_9a50_444b_ae4d_9d1f5108191b'
SCSI_IDENT_LUN_NAME='naa.6506b8d2899f7fecf37a44e190e462f0'
SCSI_IDENT_TARGET_VENDOR='clusterid=92901' <<<<<<<<<<<<<<<<<<<<<<
ID_BUS='scsi'
ID_SERIAL='8naa.6506b8d2899f7fecf37a44e190e462f0'
ID_SERIAL_SHORT='naa.6506b8d2899f7fecf37a44e190e462f0'
MPATH_SBIN_PATH='/sbin'
DM_MULTIPATH_DEVICE_PATH='0'
ID_PATH='pci-0000:00:04.0-scsi-0:0:0:0'
ID_PATH_TAG='pci-0000_00_04_0-scsi-0_0_0_0'
ID_PART_TABLE_UUID='597dafc9-bb9b-44c4-9fa6-5b3d303c6ceb'
ID_PART_TABLE_TYPE='gpt'
DEVLINKS='/dev/disk/by-id/scsi-1NUTANIX_NFS_3_0_464_e4ff5521_9a50_444b_ae4d_9d1f5108191b /dev/disk/by-path/pci-0000:00:04.0-scsi-0:0:0:0 /dev/disk/by-id/scsi-SNUTANIX_VDISK_NFS_3_0_464_e4ff5521_9a50_444b_ae4d_9d1f5108191b /dev/disk/by-id/scsi-8naa.6506b8d2899f7fecf37a44e190e462f0'
TAGS=':systemd:'

Due to this issue, Ubuntu 20.04 cannot be installed on our hypervisor until we either stop providing vendor-specific id on SCSI adapter or we bypass (use different disk type/bus) SCSI adaptor. I attach screenshot with the error message we get during installation (I feel super ashamed to attach screenshot and not a text log, but I didn't have a chance to collect the logs).

Thanks.

BR,
Sergey

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

This bug is fixed with commit 37275770 to curtin on branch master.
To view that commit see the following URL:
https://git.launchpad.net/curtin/commit/?id=37275770

Changed in curtin:
status: Confirmed → Fix Committed
Sergey Bykov (sbykov)
Changed in curtin:
status: Fix Committed → Fix Released
status: Fix Released → Fix Committed
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote : Fixed in curtin version 21.1.

This bug is believed to be fixed in curtin in version 21.1. If this is still a problem for you, please make a comment and set the state back to New

Thank you.

Changed in curtin:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.