From patchwork Wed Sep 19 15:09:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Karol Lewandowski X-Patchwork-Id: 185251 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D05AC2C007C for ; Thu, 20 Sep 2012 10:06:35 +1000 (EST) Received: from localhost ([::1]:41488 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TETpk-0008Db-Kx for incoming@patchwork.ozlabs.org; Wed, 19 Sep 2012 19:37:32 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TELtx-0007CO-91 for qemu-devel@nongnu.org; Wed, 19 Sep 2012 11:09:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TELtu-0001aU-Ql for qemu-devel@nongnu.org; Wed, 19 Sep 2012 11:09:21 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:21993) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TELtu-0001ZG-FW for qemu-devel@nongnu.org; Wed, 19 Sep 2012 11:09:18 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MAL00CU0RFC9P70@mailout3.samsung.com> for qemu-devel@nongnu.org; Thu, 20 Sep 2012 00:09:14 +0900 (KST) X-AuditID: cbfee61a-b7f726d000000ec7-af-5059e01a4498 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 83.38.03783.A10E9505; Thu, 20 Sep 2012 00:09:14 +0900 (KST) Received: from amdc402.digital.local ([106.116.147.46]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MAL00LOKRF85F70@mmp2.samsung.com> for qemu-devel@nongnu.org; Thu, 20 Sep 2012 00:09:14 +0900 (KST) From: Karol Lewandowski To: qemu-devel@nongnu.org Date: Wed, 19 Sep 2012 17:09:05 +0200 Message-id: <1348067345-13633-1-git-send-email-k.lewandowsk@samsung.com> X-Mailer: git-send-email 1.7.10.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNJMWRmVeSWpSXmKPExsVy+t9jQV2pB5EBBlP6xS2O9+5gcWD0eHJt M1MAYxSXTUpqTmZZapG+XQJXxsGNWxkLmoQq7j9byNTAeJOvi5GTQ0LAROLZgRnMELaYxIV7 69m6GLk4hASmM0qs/NzKDuEsZJI4NHcJK0gVm4CRxLdDG8A6RAQkJX53nQazmQVcJH4vnsIG YgsLeEqsvnOJBcRmEVCVaFi+kB3E5hXwkOg71cQOsU1RovvZBLYJjNwLGBlWMYqmFiQXFCel 5xrqFSfmFpfmpesl5+duYgR78ZnUDsaVDRaHGAU4GJV4eDcciQgQYk0sK67MPcQowcGsJML7 Y29kgBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXFe4U+BAUIC6YklqdmpqQWpRTBZJg5OqQbGxveR vL97xbLDAr5MT57/82asu+C5aaerJmmZ+ZUFP0zb/Kw7rGr9uv5JBl/3nfmrb9PvE35t+uWM 56//mvenhZaYq+xZJzozTU7QkZnLeFKRz9v939J8J2UWGNiuUls5JX3Xrxy+5syfGRlKkmrp H1jufPReY7eT8VP7XF7xHc8+33zkv0dZiaU4I9FQi7moOBEAuhZVQ94BAAA= X-detected-operating-system: by eggs.gnu.org: Solaris 10 (1203?) X-Received-From: 203.254.224.33 X-Mailman-Approved-At: Wed, 19 Sep 2012 19:37:17 -0400 Cc: riku.voipio@iki.fi, Karol Lewandowski Subject: [Qemu-devel] [PATCH] linux-user: Add naive implementation of capget() syscall X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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 #include #include +#include //#include #include #include @@ -97,6 +98,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base, #include #include #include +#include #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: