cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
22c213
From 7a1860c83ff042f3e796c449e780ee0528107213 Mon Sep 17 00:00:00 2001
22c213
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
22c213
Date: Tue, 3 Mar 2020 18:43:08 +0000
22c213
Subject: [PATCH 12/18] virtiofsd: Remove fuse_req_getgroups
22c213
MIME-Version: 1.0
22c213
Content-Type: text/plain; charset=UTF-8
22c213
Content-Transfer-Encoding: 8bit
22c213
22c213
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
22c213
Message-id: <20200303184314.155564-2-dgilbert@redhat.com>
22c213
Patchwork-id: 94122
22c213
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 1/7] virtiofsd: Remove fuse_req_getgroups
22c213
Bugzilla: 1797064
22c213
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
22c213
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
22c213
RH-Acked-by: Ján Tomko <jtomko@redhat.com>
22c213
22c213
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
22c213
22c213
Remove fuse_req_getgroups that's unused in virtiofsd; it came in
22c213
from libfuse but we don't actually use it.  It was called from
22c213
fuse_getgroups which we previously removed (but had left it's header
22c213
in).
22c213
22c213
Coverity had complained about null termination in it, but removing
22c213
it is the easiest answer.
22c213
22c213
Fixes: Coverity CID: 1413117 (String not null terminated)
22c213
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
22c213
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
22c213
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
22c213
(cherry picked from commit 988717b46b6424907618cb845ace9d69062703af)
22c213
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
22c213
---
22c213
 tools/virtiofsd/fuse.h          | 20 -----------
22c213
 tools/virtiofsd/fuse_lowlevel.c | 77 -----------------------------------------
22c213
 tools/virtiofsd/fuse_lowlevel.h | 21 -----------
22c213
 3 files changed, 118 deletions(-)
22c213
22c213
diff --git a/tools/virtiofsd/fuse.h b/tools/virtiofsd/fuse.h
22c213
index 7a4c713..aba13fe 100644
22c213
--- a/tools/virtiofsd/fuse.h
22c213
+++ b/tools/virtiofsd/fuse.h
22c213
@@ -1007,26 +1007,6 @@ void fuse_exit(struct fuse *f);
22c213
 struct fuse_context *fuse_get_context(void);
22c213
 
22c213
 /**
22c213
- * Get the current supplementary group IDs for the current request
22c213
- *
22c213
- * Similar to the getgroups(2) system call, except the return value is
22c213
- * always the total number of group IDs, even if it is larger than the
22c213
- * specified size.
22c213
- *
22c213
- * The current fuse kernel module in linux (as of 2.6.30) doesn't pass
22c213
- * the group list to userspace, hence this function needs to parse
22c213
- * "/proc/$TID/task/$TID/status" to get the group IDs.
22c213
- *
22c213
- * This feature may not be supported on all operating systems.  In
22c213
- * such a case this function will return -ENOSYS.
22c213
- *
22c213
- * @param size size of given array
22c213
- * @param list array of group IDs to be filled in
22c213
- * @return the total number of supplementary group IDs or -errno on failure
22c213
- */
22c213
-int fuse_getgroups(int size, gid_t list[]);
22c213
-
22c213
-/**
22c213
  * Check if the current request has already been interrupted
22c213
  *
22c213
  * @return 1 if the request has been interrupted, 0 otherwise
22c213
diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c
22c213
index de2e2e0..01c418a 100644
22c213
--- a/tools/virtiofsd/fuse_lowlevel.c
22c213
+++ b/tools/virtiofsd/fuse_lowlevel.c
22c213
@@ -2667,83 +2667,6 @@ int fuse_lowlevel_is_virtio(struct fuse_session *se)
22c213
     return !!se->virtio_dev;
22c213
 }
22c213
 
22c213
-#ifdef linux
22c213
-int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[])
22c213
-{
22c213
-    char *buf;
22c213
-    size_t bufsize = 1024;
22c213
-    char path[128];
22c213
-    int ret;
22c213
-    int fd;
22c213
-    unsigned long pid = req->ctx.pid;
22c213
-    char *s;
22c213
-
22c213
-    sprintf(path, "/proc/%lu/task/%lu/status", pid, pid);
22c213
-
22c213
-retry:
22c213
-    buf = malloc(bufsize);
22c213
-    if (buf == NULL) {
22c213
-        return -ENOMEM;
22c213
-    }
22c213
-
22c213
-    ret = -EIO;
22c213
-    fd = open(path, O_RDONLY);
22c213
-    if (fd == -1) {
22c213
-        goto out_free;
22c213
-    }
22c213
-
22c213
-    ret = read(fd, buf, bufsize);
22c213
-    close(fd);
22c213
-    if (ret < 0) {
22c213
-        ret = -EIO;
22c213
-        goto out_free;
22c213
-    }
22c213
-
22c213
-    if ((size_t)ret == bufsize) {
22c213
-        free(buf);
22c213
-        bufsize *= 4;
22c213
-        goto retry;
22c213
-    }
22c213
-
22c213
-    ret = -EIO;
22c213
-    s = strstr(buf, "\nGroups:");
22c213
-    if (s == NULL) {
22c213
-        goto out_free;
22c213
-    }
22c213
-
22c213
-    s += 8;
22c213
-    ret = 0;
22c213
-    while (1) {
22c213
-        char *end;
22c213
-        unsigned long val = strtoul(s, &end, 0);
22c213
-        if (end == s) {
22c213
-            break;
22c213
-        }
22c213
-
22c213
-        s = end;
22c213
-        if (ret < size) {
22c213
-            list[ret] = val;
22c213
-        }
22c213
-        ret++;
22c213
-    }
22c213
-
22c213
-out_free:
22c213
-    free(buf);
22c213
-    return ret;
22c213
-}
22c213
-#else /* linux */
22c213
-/*
22c213
- * This is currently not implemented on other than Linux...
22c213
- */
22c213
-int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[])
22c213
-{
22c213
-    (void)req;
22c213
-    (void)size;
22c213
-    (void)list;
22c213
-    return -ENOSYS;
22c213
-}
22c213
-#endif
22c213
-
22c213
 void fuse_session_exit(struct fuse_session *se)
22c213
 {
22c213
     se->exited = 1;
22c213
diff --git a/tools/virtiofsd/fuse_lowlevel.h b/tools/virtiofsd/fuse_lowlevel.h
22c213
index 138041e..8f6d705 100644
22c213
--- a/tools/virtiofsd/fuse_lowlevel.h
22c213
+++ b/tools/virtiofsd/fuse_lowlevel.h
22c213
@@ -1705,27 +1705,6 @@ void *fuse_req_userdata(fuse_req_t req);
22c213
 const struct fuse_ctx *fuse_req_ctx(fuse_req_t req);
22c213
 
22c213
 /**
22c213
- * Get the current supplementary group IDs for the specified request
22c213
- *
22c213
- * Similar to the getgroups(2) system call, except the return value is
22c213
- * always the total number of group IDs, even if it is larger than the
22c213
- * specified size.
22c213
- *
22c213
- * The current fuse kernel module in linux (as of 2.6.30) doesn't pass
22c213
- * the group list to userspace, hence this function needs to parse
22c213
- * "/proc/$TID/task/$TID/status" to get the group IDs.
22c213
- *
22c213
- * This feature may not be supported on all operating systems.  In
22c213
- * such a case this function will return -ENOSYS.
22c213
- *
22c213
- * @param req request handle
22c213
- * @param size size of given array
22c213
- * @param list array of group IDs to be filled in
22c213
- * @return the total number of supplementary group IDs or -errno on failure
22c213
- */
22c213
-int fuse_req_getgroups(fuse_req_t req, int size, gid_t list[]);
22c213
-
22c213
-/**
22c213
  * Callback function for an interrupt
22c213
  *
22c213
  * @param req interrupted request
22c213
-- 
22c213
1.8.3.1
22c213