cryptospore / rpms / qemu-kvm

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