From patchwork Sun Jun 10 03:01:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138148 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2602418lji; Sat, 9 Jun 2018 20:55:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKZfxpCyYSEX9+q/BQ1WapWmzhS9gNx+LBEneVyPcUXB/104eSyNjcPKu4dxNPK+JE6a3vr X-Received: by 2002:aed:2a2e:: with SMTP id c43-v6mr11894656qtd.36.1528602908323; Sat, 09 Jun 2018 20:55:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602908; cv=none; d=google.com; s=arc-20160816; b=dumTSY5+H/uihavTuQMgQN78rm03CcxQFpAOuch+e3ww14x4A8rve0P1ANWhgyH1i3 QzX5AslCqUxMe0qY+yOg6ZQWSF56Iy6ftx2isYctvmSrCDeXs9e96WS7Eh0w0b0S8XXv ovamxdAJC/bstl+DTlCjhfhPTCu2ZBlscjcaUtPaVuCQgUwPVu+joLiIHBbB6xpc2LwH UfQEfT694oevC9IRYz6b6LUIy5YPK2OiqmTIAXkyVPNyuvq8/BhjdYWE6CJVWNK+glSU ERmM61wAyMLvA3mct+PTgXc+KaEaA4RJh2wEQDwhNe9LMLx4x3tOo8IzTllHfgDXoTr0 MO8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=IkrY1Z2tJmo6hGZdiQt8/HqWJyCtyMCObOLqWroRbt8=; b=UjE47ZHlUQlSQlsgo8T5qfFdloLZ5UJH7qzFRPGOQTvXG+a/rHi52W0yasoUUXZVTf 4vbrs2e40yrSylEkbYFmutXBcSqZzYYxG74zx/SS9BsRD/6qgmjvqevUfzXxVm9da9Wl q6zQFSyqART1ngTrewGkdgi8aaMA4NDc3DwYKcdWdcS2t97XRP9hnYAhjOi9D1LiRieS B8RlNMn43+sm9rB2NxRPJTJhav1+pEif3VTC+RCkHgHl7IImSkT4cWHtPAHTa/wr2oNs op0hKUGnGxg7R+O2cwUbdGL5/Sm053PsOnweDzFqs1k6+e38B0dmtaZ9lkpEr9AI2JPl ugXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OIHLNUwB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id a26-v6si1748939qtj.326.2018.06.09.20.55.08 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:55:08 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OIHLNUwB; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42460 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrRb-0007PB-Ox for patch@linaro.org; Sat, 09 Jun 2018 23:55:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfM-0003zf-UR for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfL-0004Mg-R5 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:16 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:33746) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfL-0004MN-Ir for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:15 -0400 Received: by mail-pl0-x242.google.com with SMTP id n10-v6so10391995plp.0 for ; Sat, 09 Jun 2018 20:05:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IkrY1Z2tJmo6hGZdiQt8/HqWJyCtyMCObOLqWroRbt8=; b=OIHLNUwBgc1Vq5Zv+E4Toa9YTbpwobYoYW3gqtBfZUI+y/tspfO23UjvSecRMNa3mA 0MUCgVgqe96hJ20OOqB0MwQFBaNfWcvScgKHDy1gW2PGLPMD45R0t0h+8I7ty4BcxU5o dVhxC/nIfUUxgfMb+2uciyjNLmmaES2+e0qOM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IkrY1Z2tJmo6hGZdiQt8/HqWJyCtyMCObOLqWroRbt8=; b=NVgBNkMysLOsLT4t1POuRS4gb5CGiSf3TviAo/MlKCwnfx8LGY47N6QkdGtXrpG6Xm tC8inZh8NGjlhCTK4tNXj/Q19ryoBOTW526r0AF+o0PuDbxXnzoJcd+spSX/torjOWFU CaGA3HRMLfUFjRXtow3aDdLK24eOjjfTYfah9dSi/HKQ1oYLIeaTKmZF1hQ8cz8CkizV y6fXMi+F0GBXQ5OUiiCU6+AHSMm7K7T/UGuFBCKH2+2kL2JIIP+U8Rb882DMAEZRogKM UVFyaAESNjqPjfWPBwcEbZPos8OaELWW++r2fYoZbk2w1VSReGrzyKcl19L2n8nbOCYv wvNg== X-Gm-Message-State: APt69E0p06EChDOr1A6XwN/iIRgVYf6nCGF+s9z0u49S3csUQBgYxQVE GFIBAnw7lKG7TBYl+q4j1050QYX9SGo= X-Received: by 2002:a17:902:1007:: with SMTP id b7-v6mr12796138pla.88.1528599914405; Sat, 09 Jun 2018 20:05:14 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:52 -1000 Message-Id: <20180610030220.3777-81-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PATCH v2 080/108] linux-user: Split out fchown32, getgroups32, setgroups32 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 114 +++++++++++++++++++++++++------------------ 1 file changed, 67 insertions(+), 47 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c8bd13092e..031033c0ea 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8123,6 +8123,13 @@ IMPL(fchown) return get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3))); } +#ifdef TARGET_NR_fchown32 +IMPL(fchown32) +{ + return get_errno(fchown(arg1, arg2, arg3)); +} +#endif + IMPL(fchownat) { char *p = lock_user_string(arg2); @@ -8543,6 +8550,33 @@ IMPL(getgroups) return ret; } +#ifdef TARGET_NR_getgroups32 +IMPL(getgroups32) +{ + int gidsetsize = arg1; + gid_t *grouplist; + abi_long ret; + + grouplist = alloca(gidsetsize * sizeof(gid_t)); + ret = get_errno(getgroups(gidsetsize, grouplist)); + + if (!is_error(ret) && gidsetsize != 0) { + uint32_t *target_gl; + int i; + + target_gl = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0); + if (!target_gl) { + return -TARGET_EFAULT; + } + for (i = 0; i < ret; i++) { + target_gl[i] = tswap32(grouplist[i]); + } + unlock_user(target_gl, arg2, gidsetsize * 4); + } + return ret; +} +#endif + IMPL(getitimer) { struct itimerval value; @@ -10783,6 +10817,30 @@ IMPL(setgroups) return get_errno(setgroups(gidsetsize, grouplist)); } +#ifdef TARGET_NR_setgroups32 +IMPL(setgroups32) +{ + int gidsetsize = arg1; + gid_t *grouplist = NULL; + + if (gidsetsize) { + uint32_t *target_gl; + int i; + + grouplist = alloca(gidsetsize * sizeof(gid_t)); + target_gl = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1); + if (!target_gl) { + return -TARGET_EFAULT; + } + for (i = 0; i < gidsetsize; i++) { + grouplist[i] = tswap32(target_gl[i]); + } + unlock_user(target_gl, arg2, 0); + } + return get_errno(setgroups(gidsetsize, grouplist)); +} +#endif + IMPL(sethostname) { char *p = lock_user_string(arg1); @@ -11840,53 +11898,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_getgroups32 - case TARGET_NR_getgroups32: - { - int gidsetsize = arg1; - uint32_t *target_grouplist; - gid_t *grouplist; - int i; - - grouplist = alloca(gidsetsize * sizeof(gid_t)); - ret = get_errno(getgroups(gidsetsize, grouplist)); - if (gidsetsize == 0) - return ret; - if (!is_error(ret)) { - target_grouplist = lock_user(VERIFY_WRITE, arg2, gidsetsize * 4, 0); - if (!target_grouplist) { - return -TARGET_EFAULT; - } - for(i = 0;i < ret; i++) - target_grouplist[i] = tswap32(grouplist[i]); - unlock_user(target_grouplist, arg2, gidsetsize * 4); - } - } - return ret; -#endif -#ifdef TARGET_NR_setgroups32 - case TARGET_NR_setgroups32: - { - int gidsetsize = arg1; - uint32_t *target_grouplist; - gid_t *grouplist; - int i; - - grouplist = alloca(gidsetsize * sizeof(gid_t)); - target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 4, 1); - if (!target_grouplist) { - return -TARGET_EFAULT; - } - for(i = 0;i < gidsetsize; i++) - grouplist[i] = tswap32(target_grouplist[i]); - unlock_user(target_grouplist, arg2, 0); - return get_errno(setgroups(gidsetsize, grouplist)); - } -#endif -#ifdef TARGET_NR_fchown32 - case TARGET_NR_fchown32: - return get_errno(fchown(arg1, arg2, arg3)); -#endif #ifdef TARGET_NR_setresuid32 case TARGET_NR_setresuid32: return get_errno(sys_setresuid(arg1, arg2, arg3)); @@ -13144,6 +13155,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(fchmod); SYSCALL(fchmodat); SYSCALL(fchown); +#ifdef TARGET_NR_fchown32 + SYSCALL(fchown32); +#endif SYSCALL(fchownat); #ifdef TARGET_NR_fcntl SYSCALL(fcntl); @@ -13199,6 +13213,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(getgid32); #endif SYSCALL(getgroups); +#ifdef TARGET_NR_getgroups32 + SYSCALL(getgroups32); +#endif SYSCALL(getitimer); #ifdef TARGET_NR_getpeername SYSCALL(getpeername); @@ -13463,6 +13480,9 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(setfsuid); SYSCALL(setgid); SYSCALL(setgroups); +#ifdef TARGET_NR_setgroups32 + SYSCALL(setgroups32); +#endif SYSCALL(sethostname); SYSCALL(setitimer); SYSCALL(setpgid);