All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] fsdev: Don't ignore setfsuid/setfsgid return values
@ 2012-10-05  8:36 M. Mohan Kumar
  2012-10-05 11:52 ` Eric Blake
  0 siblings, 1 reply; 2+ messages in thread
From: M. Mohan Kumar @ 2012-10-05  8:36 UTC (permalink / raw)
  To: qemu-devel, aneesh.kumar, stefanha, eblake; +Cc: M. Mohan Kumar

From: "M. Mohan Kumar" <mohan@in.ibm.com>

In current implementation of setfsuid/setfsgid there is no way to know
if it failed by checking the return value. This patch assumes
setfsuid/setfsgid returns -1 in case of error. Eventually kernel code
needs to be fixed.

Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
---
 fsdev/virtfs-proxy-helper.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
index f9a8270..ed5eede 100644
--- a/fsdev/virtfs-proxy-helper.c
+++ b/fsdev/virtfs-proxy-helper.c
@@ -290,9 +290,12 @@ static int setfsugid(int uid, int gid)
         CAP_DAC_OVERRIDE,
     };
 
-    setfsgid(gid);
-    setfsuid(uid);
-
+    if (setfsgid(gid) < 0) {
+        return -errno;
+    }
+    if (setfsuid(uid) < 0) {
+        return -errno;
+    }
     if (uid != 0 || gid != 0) {
         return do_cap_set(cap_list, ARRAY_SIZE(cap_list), 0);
     }
-- 
1.7.11.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-10-05 11:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-05  8:36 [Qemu-devel] [PATCH] fsdev: Don't ignore setfsuid/setfsgid return values M. Mohan Kumar
2012-10-05 11:52 ` Eric Blake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.