From nobody Wed Feb 11 01:09:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528602975117309.0100713627795; Sat, 9 Jun 2018 20:56:15 -0700 (PDT) Received: from localhost ([::1]:42467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrSg-0000oP-6f for importer@patchew.org; Sat, 09 Jun 2018 23:56:14 -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) 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) 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-Google-Smtp-Source: ADUXVKKzJv+9xa+RaB46r+jDBF25IHaxdsjuo3CP6eQyEevA8Gx+G2WhbhAuzdDAd1xJlxkD3RKhqw== X-Received: by 2002:a62:e117:: with SMTP id q23-v6mr12255358pfh.75.1528599904183; Sat, 09 Jun 2018 20:05:04 -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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson --- linux-user/syscall.c | 94 +++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 37 deletions(-) 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 =20 +#ifdef TARGET_NR_chown +IMPL(chown) +{ + char *p =3D lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret =3D get_errno(chown(p, low2highuid(arg2), low2highgid(arg3))); + unlock_user(p, arg1, 0); + return ret; +} +#endif + IMPL(chroot) { char *p =3D lock_user_string(arg1); @@ -8588,6 +8603,38 @@ IMPL(getrandom) return ret; } =20 +#ifdef TARGET_NR_getresgid +IMPL(getresgid) +{ + gid_t rgid, egid, sgid; + abi_long ret =3D 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 =3D 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 =3D target_to_host_resource(arg1); @@ -11547,42 +11594,6 @@ static abi_long do_syscall1(void *cpu_env, unsigne= d num, abi_long arg1, void *p; =20 switch(num) { -#ifdef TARGET_NR_getresuid - case TARGET_NR_getresuid: - { - uid_t ruid, euid, suid; - ret =3D 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 =3D 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 =3D lock_user_string(arg1))) - return -TARGET_EFAULT; - ret =3D 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); --=20 2.17.1