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