All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: Add naive implementation of capget() syscall
@ 2012-09-19 15:09 Karol Lewandowski
  2012-09-22 12:07 ` Blue Swirl
  0 siblings, 1 reply; 6+ messages in thread
From: Karol Lewandowski @ 2012-09-19 15:09 UTC (permalink / raw)
  To: qemu-devel; +Cc: riku.voipio, Karol Lewandowski

libcap, library used to manipulate posix file capabilities uses
getcap() to query version of capabilities supported by running
kernel. Information obtained from this syscall is then used to
initialize data structures that can be used to set process
or/and file capabilities.

Providing capget() alone makes it possible to set posix file
capabilities under qemu (using setcap(8)).

Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com>
---
 linux-user/syscall.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 6257a04..bcd7a05 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -56,6 +56,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
 #include <utime.h>
 #include <sys/sysinfo.h>
 #include <sys/utsname.h>
+#include <sys/capability.h>
 //#include <sys/user.h>
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
@@ -97,6 +98,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
 #include <linux/fb.h>
 #include <linux/vt.h>
 #include <linux/dm-ioctl.h>
+#include <linux/capability.h>
 #include "linux_loop.h"
 #include "cpu-uname.h"
 
@@ -328,6 +330,11 @@ static int sys_getcwd1(char *buf, size_t size)
   return strlen(buf)+1;
 }
 
+static int sys_capget(struct __user_cap_header_struct *hdr, struct __user_cap_data_struct *data)
+{
+  return (capget(hdr, data));
+}
+
 #ifdef CONFIG_ATFILE
 /*
  * Host system seems to have atfile syscall stubs available.  We
@@ -7436,7 +7443,18 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         unlock_user(p, arg1, ret);
         break;
     case TARGET_NR_capget:
-        goto unimplemented;
+    {
+	void *p2 = NULL;
+	if (!(p = lock_user(VERIFY_WRITE, arg1, sizeof(struct __user_cap_header_struct), 0)))
+	    goto efault;
+	if (arg2 && !(p2 = lock_user(VERIFY_WRITE, arg2, sizeof(struct __user_cap_data_struct), 0)))
+	    goto efault;
+	ret = get_errno(sys_capget(p, p2));
+	unlock_user(p, arg1, sizeof(struct __user_cap_header_struct));
+	if (arg2)
+	     unlock_user(p, arg2, sizeof(struct __user_cap_data_struct));
+	break;
+    }
     case TARGET_NR_capset:
         goto unimplemented;
     case TARGET_NR_sigaltstack:
-- 
1.7.5.4

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

end of thread, other threads:[~2012-09-25 14:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-19 15:09 [Qemu-devel] [PATCH] linux-user: Add naive implementation of capget() syscall Karol Lewandowski
2012-09-22 12:07 ` Blue Swirl
2012-09-22 23:23   ` Erik de Castro Lopo
2012-09-23 16:02     ` Blue Swirl
2012-09-24 13:47       ` Peter Maydell
2012-09-25 14:09   ` Karol Lewandowski

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.