render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
dc2b6e
From c70b1a8d8a4bc34bcbf9ef4bccac678257b8c494 Mon Sep 17 00:00:00 2001
dc2b6e
Message-Id: <c70b1a8d8a4bc34bcbf9ef4bccac678257b8c494@dist-git>
dc2b6e
From: Vasiliy Ulyanov <vulyanov@suse.de>
dc2b6e
Date: Wed, 2 Feb 2022 17:28:17 +0100
dc2b6e
Subject: [PATCH] qemu: gpu: Get pid without binary validation
dc2b6e
dc2b6e
The binary validation in virPidFileReadPathIfAlive may fail with EACCES
dc2b6e
if the calling process does not have CAP_SYS_PTRACE capability.
dc2b6e
Therefore instead do only the check that the pidfile is locked by the
dc2b6e
correct process.
dc2b6e
dc2b6e
Fixes the same issue as with swtpm.
dc2b6e
dc2b6e
Signed-off-by: Vasiliy Ulyanov <vulyanov@suse.de>
dc2b6e
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
dc2b6e
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
dc2b6e
(cherry picked from commit e3dfa52d260da8a41a0ec35767d08e37c825824a)
dc2b6e
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2152188
dc2b6e
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
dc2b6e
---
dc2b6e
 src/qemu/qemu_vhost_user_gpu.c | 9 +++------
dc2b6e
 1 file changed, 3 insertions(+), 6 deletions(-)
dc2b6e
dc2b6e
diff --git a/src/qemu/qemu_vhost_user_gpu.c b/src/qemu/qemu_vhost_user_gpu.c
dc2b6e
index ef198a4820..f7d444e851 100644
dc2b6e
--- a/src/qemu/qemu_vhost_user_gpu.c
dc2b6e
+++ b/src/qemu/qemu_vhost_user_gpu.c
dc2b6e
@@ -54,7 +54,6 @@ qemuVhostUserGPUCreatePidFilename(const char *stateDir,
dc2b6e
 
dc2b6e
 /*
dc2b6e
  * qemuVhostUserGPUGetPid:
dc2b6e
- * @binpath: path of executable associated with the pidfile
dc2b6e
  * @stateDir: the directory where vhost-user-gpu writes the pidfile into
dc2b6e
  * @shortName: short name of the domain
dc2b6e
  * @alias: video device alias
dc2b6e
@@ -65,8 +64,7 @@ qemuVhostUserGPUCreatePidFilename(const char *stateDir,
dc2b6e
  * set to -1;
dc2b6e
  */
dc2b6e
 static int
dc2b6e
-qemuVhostUserGPUGetPid(const char *binPath,
dc2b6e
-                       const char *stateDir,
dc2b6e
+qemuVhostUserGPUGetPid(const char *stateDir,
dc2b6e
                        const char *shortName,
dc2b6e
                        const char *alias,
dc2b6e
                        pid_t *pid)
dc2b6e
@@ -76,7 +74,7 @@ qemuVhostUserGPUGetPid(const char *binPath,
dc2b6e
     if (!(pidfile = qemuVhostUserGPUCreatePidFilename(stateDir, shortName, alias)))
dc2b6e
         return -1;
dc2b6e
 
dc2b6e
-    if (virPidFileReadPathIfAlive(pidfile, pid, binPath) < 0)
dc2b6e
+    if (virPidFileReadPathIfLocked(pidfile, pid) < 0)
dc2b6e
         return -1;
dc2b6e
 
dc2b6e
     return 0;
dc2b6e
@@ -253,8 +251,7 @@ qemuExtVhostUserGPUSetupCgroup(virQEMUDriver *driver,
dc2b6e
     if (!shortname)
dc2b6e
         return -1;
dc2b6e
 
dc2b6e
-    rc = qemuVhostUserGPUGetPid(video->driver->vhost_user_binary,
dc2b6e
-                                cfg->stateDir, shortname, video->info.alias, &pid;;
dc2b6e
+    rc = qemuVhostUserGPUGetPid(cfg->stateDir, shortname, video->info.alias, &pid;;
dc2b6e
     if (rc < 0 || (rc == 0 && pid == (pid_t)-1)) {
dc2b6e
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
dc2b6e
                        _("Could not get process id of vhost-user-gpu"));
dc2b6e
-- 
dc2b6e
2.39.0
dc2b6e