* [sdl-qemu] [PATCH 0/1] There are no checks, virDomainChrSourceDefNew can return 0
@ 2023-09-14 9:44 Миронов Сергей Владимирович
2023-09-14 10:17 ` Peter Krempa
0 siblings, 1 reply; 2+ messages in thread
From: Миронов Сергей Владимирович @ 2023-09-14 9:44 UTC (permalink / raw)
To: libvirt-security@redhat.com, qemu-devel@nongnu.org,
libvir-list@redhat.com
Cc: sdl.qemu@linuxtesting.org
[-- Attachment #1: Type: text/plain, Size: 1060 bytes --]
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'")
Signed-off-by: Sergey Mironov <mironov@fintech.ru>
---
src/qemu/qemu_hotplug.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 177ca87d11..09e16c2c7e 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -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
[-- Attachment #2: Type: text/html, Size: 8802 bytes --]
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [sdl-qemu] [PATCH 0/1] There are no checks, virDomainChrSourceDefNew can return 0
2023-09-14 9:44 [sdl-qemu] [PATCH 0/1] There are no checks, virDomainChrSourceDefNew can return 0 Миронов Сергей Владимирович
@ 2023-09-14 10:17 ` Peter Krempa
0 siblings, 0 replies; 2+ messages in thread
From: Peter Krempa @ 2023-09-14 10:17 UTC (permalink / raw)
To: Миронов Сергей Владимирович
Cc: libvirt-security@redhat.com, qemu-devel@nongnu.org,
libvir-list@redhat.com, sdl.qemu@linuxtesting.org
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'.
On Thu, Sep 14, 2023 at 09:44:13 +0000, Миронов Сергей Владимирович wrote:
> 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.
> 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.
>
>
> 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.
>
> Signed-off-by: Sergey Mironov <mironov@fintech.ru>
>
> ---
> src/qemu/qemu_hotplug.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 177ca87d11..09e16c2c7e 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-09-14 12:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-14 9:44 [sdl-qemu] [PATCH 0/1] There are no checks, virDomainChrSourceDefNew can return 0 Миронов Сергей Владимирович
2023-09-14 10:17 ` Peter Krempa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).