Skip to contentSkip to conversation

There are no checks, virDomainChrSourceDefNew can return 0

PATCH In review Миронов Сергей Владимирович 2 participants 2 messages Sep 14, 2023

lore
Share & tools
lore
#0 lore raw

cover There are no checks, virDomainChrSourceDefNew can return 0

There are no checks, virDomainChrSourceDefNew can return 0.

Return value of a function 'virDomainChrSourceDefNew'

is dereferenced at qemu_hotplug.c without checking for NULL,

but it is usually checked for this function.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 1f85f0967b ("ci: jobs.sh: Add back '--no-suite syntax-check --print-errorlogs'")

---
src/qemu/qemu_hotplug.c | 2 ++

 1 file changed, 2 insertions(+)
src/qemu/qemu_hotplug.c +2 -1
index 177ca87d11..09e16c2c7e 100644
@@ -3207,6 +3207,8 @@ qemuDomainAttachFSDevice(virQEMUDriver *driver,
     qemuAssignDeviceFSAlias(vm->def, fs);
 
     chardev = virDomainChrSourceDefNew(priv->driver->xmlopt);
+    if (chardev == NULL)
+           goto cleanup;
     chardev->type = VIR_DOMAIN_CHR_TYPE_UNIX;
     chardev->data.nix.path = qemuDomainGetVHostUserFSSocketPath(priv, fs);
--

2.31.1

#1 lore raw

CC-ing qemu-devel with a patch solely for libvirt doesn't make sense.

Also 'libvirt-security' list is private and is is intended as a first contact list for stuff to be embargoed. It makes little sense to include it when posting to the public 'libvir-list'.

Quoted 1 line · Миронов Сергей Владимирович

There are no checks, virDomainChrSourceDefNew can return 0.

s/0/NULL

While very technically true, realistically that can't happen any more.

'virObjectNew' always returns a valid pointer or abort()s, and VIR_CLASS_NEW can return 0 on programming errors.

Thus this is not a security issue.

Quoted 5 lines

Return value of a function 'virDomainChrSourceDefNew'

is dereferenced at qemu_hotplug.c without checking for NULL,

but it is usually checked for this function.

Remove the extra empty lines please.

Quoted 6 lines

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 1f85f0967b ("ci: jobs.sh: Add back '--no-suite syntax-check --print-errorlogs'")

^^ This makes no sense. The commit you are referencing is changing a shell script.

Quoted 21 lines

---
src/qemu/qemu_hotplug.c | 2 ++

 1 file changed, 2 insertions(+)
src/qemu/qemu_hotplug.c +2 -1
index 177ca87d11..09e16c2c7e 100644
@@ -3207,6 +3207,8 @@ qemuDomainAttachFSDevice(virQEMUDriver *driver,
     qemuAssignDeviceFSAlias(vm->def, fs);
 
     chardev = virDomainChrSourceDefNew(priv->driver->xmlopt);
+    if (chardev == NULL)
+           goto cleanup;
     chardev->type = VIR_DOMAIN_CHR_TYPE_UNIX;
     chardev->data.nix.path = qemuDomainGetVHostUserFSSocketPath(priv, fs);
--

2.31.1