From patchwork Sun Jun 10 03:01:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138146 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2602216lji; Sat, 9 Jun 2018 20:54:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJNmArr8+93tJeEdS9xRyGhyrbnnMHA7bYO74cA1DmbMKHnM+wGqGj0rX7dWHI8TjwNUkGt X-Received: by 2002:a37:5105:: with SMTP id f5-v6mr10146023qkb.265.1528602883842; Sat, 09 Jun 2018 20:54:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602883; cv=none; d=google.com; s=arc-20160816; b=AvWQs7gIrY2eysPd+/nDnwR7OwBrr5q30qDxEl1EK3/onE++W9RT42KLWW1RKr/eOY vJ4b+p2kXx5me53mRI+diQMAP9JW5p5iCIa31v2ZPSqemw7gopDz7yVTk10sIqsGOsWv 99Wld6YMSY/MU276MC2TF2O9q5M4h3gkfzzh5MGvqgc239bVnCmS2tPTlQYHxZUvJa/G R2jxrnwHpIMQOPBt+loUAXjsR7H1kmqHjgnOzaEvu9k5xc3zCaztBhdSzGjJ77LtSOcF Lbu5k37EMNqwTK4MYLjiyPXLw1qndv0CXY6z5pE/RkCXSxfbBJfDJkdzUM63M4BnQqOx BKJQ== 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=Sk2fDlU0DnsE/sliHTdfILgkVOkFTcoylt1dgKwuElY=; b=Ywy8B3kkVXKA89TrMbLSRXrz06HkDDFHE3cxfMHEREZGIJnUn1mHNQa6ftEk3w0XNY CcFU4rQHCd0JUnQzs8L+cfnt/jh3hsFdvbyBWB5VyVuXLy/dBp7518NlDBSPaiaBJBCt LxONcFUvgIZKQhLL+Q/CxwD2dOh7QddSB0B5q2lJ+0pGdPxx2W8p6SRxmzjalOEW5WGD hb07JB8Gtzx6HArRmkA6/g29R/t+TNp29Oq6JYpVHTmC1SaHWNuT67Enxsuob35PA6r3 fVzrp8SqPhsTTFDYCoATEKumuhkee2uImbwffxibM0lq/UPy5hcUPr5Squlp7aIE5Nr7 lMtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=IPeriKnH; 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 r2-v6si6426146qtj.249.2018.06.09.20.54.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:54:43 -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=IPeriKnH; 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]:42455 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrRD-00070L-76 for patch@linaro.org; Sat, 09 Jun 2018 23:54:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41164) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfC-0003ov-Lh for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfB-0004Jp-IF for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:06 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:42385) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfB-0004Jf-CC for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:05 -0400 Received: by mail-pf0-x241.google.com with SMTP id w7-v6so8479182pfn.9 for ; Sat, 09 Jun 2018 20:05:05 -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=Sk2fDlU0DnsE/sliHTdfILgkVOkFTcoylt1dgKwuElY=; b=IPeriKnH1+mr5PezpknxXG6T+fjc6G4XX/B3Lc1oR3Ch5X69kDrhpj91+hQwThzoMT fxhtRNEl45dtL3frfFQniE6/nloHcRlDtABSKf6qjFlc4lEDF0U/PWd5cWpXC3kSBGCq WBIxDA2Bg/47PSAJiZ3AKoWU3Ai2yP2cndhUA= 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=Sk2fDlU0DnsE/sliHTdfILgkVOkFTcoylt1dgKwuElY=; b=KhIpeJTYdChQ/WRIb9DIHyOMj7nWsRuc635cakSHO/+3AtJNEj2q1tm3Z/+VA+OH49 xclYHBBgebStF+5LIQt/EMqMDD3pZRzHUxoPiq9LXIlyZi65CHsEvPVgg/TlvqvWP+49 YASsKuPKqT3g0ItK62at8rUHrPec/m9DnF4aXg4NBxX1hxL2n4jeCUstrzFpABNHg8nN WpPbeg9Ico9F7HAx8+jpIsX0zIWvYf9bl5q42rUQlWyp4q1sokPqXGe2VyCccLuTEfAs Lwx4jCNbvVoZs3s6bN2+Oluy9KoNwR420Yf9KI6Mwhj9OgwvOkb6Gyct0mD40g7OJOq0 T75g== X-Gm-Message-State: APt69E2i8LV3FSDbJxMh91n5RgIqO3Qgt9/5/kuKbTwCwF+bmjSB9sD0 iA+fhroCohRxeMyHZ1RxlW3Za7ShedQ= X-Received: by 2002:a62:e117:: with SMTP id q23-v6mr12255358pfh.75.1528599904183; Sat, 09 Jun 2018 20:05:04 -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.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:47 -1000 Message-Id: <20180610030220.3777-76-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:c00::241 Subject: [Qemu-devel] [PATCH v2 075/108] linux-user: Split out chown, getresgid, getresuid 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 | 94 +++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 37 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 75b869fb33..c55c414239 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7787,6 +7787,21 @@ IMPL(chmod) } #endif +#ifdef TARGET_NR_chown +IMPL(chown) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(chown(p, low2highuid(arg2), low2highgid(arg3))); + unlock_user(p, arg1, 0); + return ret; +} +#endif + IMPL(chroot) { char *p = lock_user_string(arg1); @@ -8588,6 +8603,38 @@ IMPL(getrandom) return ret; } +#ifdef TARGET_NR_getresgid +IMPL(getresgid) +{ + gid_t rgid, egid, sgid; + abi_long ret = get_errno(getresgid(&rgid, &egid, &sgid)); + + if (!is_error(ret) && + (put_user_id(high2lowgid(rgid), arg1) || + put_user_id(high2lowgid(egid), arg2) || + put_user_id(high2lowgid(sgid), arg3))) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + +#ifdef TARGET_NR_getresuid +IMPL(getresuid) +{ + uid_t ruid, euid, suid; + abi_long ret = get_errno(getresuid(&ruid, &euid, &suid)); + + if (!is_error(ret) && + (put_user_id(high2lowuid(ruid), arg1) || + put_user_id(high2lowuid(euid), arg2) || + put_user_id(high2lowuid(suid), arg3))) { + return -TARGET_EFAULT; + } + return ret; +} +#endif + IMPL(getrlimit) { int resource = target_to_host_resource(arg1); @@ -11547,42 +11594,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_getresuid - case TARGET_NR_getresuid: - { - uid_t ruid, euid, suid; - ret = get_errno(getresuid(&ruid, &euid, &suid)); - if (!is_error(ret)) { - if (put_user_id(high2lowuid(ruid), arg1) - || put_user_id(high2lowuid(euid), arg2) - || put_user_id(high2lowuid(suid), arg3)) - return -TARGET_EFAULT; - } - } - return ret; -#endif -#ifdef TARGET_NR_getresgid - case TARGET_NR_getresgid: - { - gid_t rgid, egid, sgid; - ret = get_errno(getresgid(&rgid, &egid, &sgid)); - if (!is_error(ret)) { - if (put_user_id(high2lowgid(rgid), arg1) - || put_user_id(high2lowgid(egid), arg2) - || put_user_id(high2lowgid(sgid), arg3)) - return -TARGET_EFAULT; - } - } - return ret; -#endif -#ifdef TARGET_NR_chown - case TARGET_NR_chown: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(chown(p, low2highuid(arg2), low2highgid(arg3))); - unlock_user(p, arg1, 0); - return ret; -#endif case TARGET_NR_setuid: return get_errno(sys_setuid(low2highuid(arg1))); case TARGET_NR_setgid: @@ -13080,10 +13091,13 @@ static impl_fn *syscall_table(unsigned num) SYSCALL(clone); SYSCALL(close); SYSCALL(chdir); - SYSCALL(chroot); #ifdef TARGET_NR_chmod SYSCALL(chmod); #endif +#ifdef TARGET_NR_chown + SYSCALL(chown); +#endif + SYSCALL(chroot); #ifdef TARGET_NR_connect SYSCALL(connect); #endif @@ -13169,6 +13183,12 @@ static impl_fn *syscall_table(unsigned num) #endif SYSCALL(getpriority); SYSCALL(getrandom); +#ifdef TARGET_NR_getresgid + SYSCALL(getresgid); +#endif +#ifdef TARGET_NR_getresuid + SYSCALL(getresuid); +#endif SYSCALL(getrlimit); SYSCALL(getrusage); SYSCALL(getsid);