]> xenbits.xensource.com Git - libvirt.git/commit
conf: Fix rawio/sgio checks for non-scsi hostdev devices
authorRayhan Faizel <rayhan.faizel@gmail.com>
Tue, 2 Jul 2024 14:57:13 +0000 (20:27 +0530)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 3 Jul 2024 07:54:43 +0000 (09:54 +0200)
commit70e826ec6a8930f37f80cd6b29cac9f53afe36d5
tree5e1e0b635bda5fc0c90c2d5eb75ed62949d781dc
parent738b201aad48dd0f1af8465adbda0d056213d521
conf: Fix rawio/sgio checks for non-scsi hostdev devices

The current hostdev parsing logic sets rawio or sgio even if the hostdev type
is not 'scsi'. The rawio field in virDomainHostdevSubsysSCSI overlaps with
wwpn field in virDomainHostdevSubsysSCSIVHost, consequently setting a bogus
pointer value such as 0x1 or 0x2 from virDomainHostdevSubsysSCSIVHost's
point of view. This leads to a segmentation fault when it attempts to free
wwpn.

While setting sgio does not appear to crash, it shares the same flawed logic
as setting rawio.

Instead, we ensure these are set only after the hostdev type check succeeds.
This patch also adds two test cases to exercise both scenarios.

Fixes: bdb95b520c53f9bacc6504fc51381bac4813be38
Signed-off-by: Rayhan Faizel <rayhan.faizel@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c
tests/qemuxmlconfdata/hostdev-scsi-vhost-rawio-invalid.x86_64-latest.err [new file with mode: 0644]
tests/qemuxmlconfdata/hostdev-scsi-vhost-rawio-invalid.xml [new file with mode: 0644]
tests/qemuxmlconfdata/hostdev-scsi-vhost-sgio-invalid.x86_64-latest.err [new file with mode: 0644]
tests/qemuxmlconfdata/hostdev-scsi-vhost-sgio-invalid.xml [new file with mode: 0644]
tests/qemuxmlconftest.c