From patchwork Fri Oct 5 08:36:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: fsdev: Don't ignore setfsuid/setfsgid return values X-Patchwork-Submitter: Mohan Kumar M X-Patchwork-Id: 189449 Message-Id: <1349426179-16712-1-git-send-email-mohan@in.ibm.com> To: qemu-devel@nongnu.org, aneesh.kumar@linux.vnet.ibm.com, stefanha@gmail.com, eblake@redhat.com Cc: "M. Mohan Kumar" Date: Fri, 5 Oct 2012 14:06:19 +0530 From: "M. Mohan Kumar" List-Id: From: "M. Mohan Kumar" 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 Tested-by: Eric Blake --- 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); }