From patchwork Mon Mar 10 12:22:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 328548 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5BF262C00DE for ; Mon, 10 Mar 2014 23:25:33 +1100 (EST) Received: from localhost ([::1]:48403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMzGs-00065y-6N for incoming@patchwork.ozlabs.org; Mon, 10 Mar 2014 08:25:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41911) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMzEc-0002oq-FT for qemu-devel@nongnu.org; Mon, 10 Mar 2014 08:23:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WMzEU-00084C-W0 for qemu-devel@nongnu.org; Mon, 10 Mar 2014 08:23:10 -0400 Received: from afflict.kos.to ([92.243.29.197]:50041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMzEU-00083k-Oa for qemu-devel@nongnu.org; Mon, 10 Mar 2014 08:23:02 -0400 Received: from localhost.localdomain (afflict [92.243.29.197]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id BF69026564; Mon, 10 Mar 2014 13:23:01 +0100 (CET) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Mon, 10 Mar 2014 14:22:56 +0200 Message-Id: <76ca310a19463e9883e2e55a88ac8be1fc171eea.1394453724.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: peter.maydell@linaro.org Subject: [Qemu-devel] [PATCH 4/8] linux-user: Fix getresuid, getresgid if !USE_UID16 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 From: Peter Maydell The size of the UID/GID types depends on whether USE_UID16 is defined. Define a new put_user_id() which writes a uid/gid type to guest memory. This fixes getresuid and getresgid, which were always storing 16 bits even if the uid type was 32 bits. Reported-by: Michael Matz Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio Reviewed-by: Andreas Färber Reviewed-by: Richard Henderson --- linux-user/syscall.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1407b7a..ccdbc4e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4528,6 +4528,9 @@ static inline int tswapid(int id) { return tswap16(id); } + +#define put_user_id(x, gaddr) put_user_u16(x, gaddr) + #else /* !USE_UID16 */ static inline int high2lowuid(int uid) { @@ -4549,6 +4552,9 @@ static inline int tswapid(int id) { return tswap32(id); } + +#define put_user_id(x, gaddr) put_user_u32(x, gaddr) + #endif /* USE_UID16 */ void syscall_init(void) @@ -7805,9 +7811,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, uid_t ruid, euid, suid; ret = get_errno(getresuid(&ruid, &euid, &suid)); if (!is_error(ret)) { - if (put_user_u16(high2lowuid(ruid), arg1) - || put_user_u16(high2lowuid(euid), arg2) - || put_user_u16(high2lowuid(suid), arg3)) + if (put_user_id(high2lowuid(ruid), arg1) + || put_user_id(high2lowuid(euid), arg2) + || put_user_id(high2lowuid(suid), arg3)) goto efault; } } @@ -7826,9 +7832,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, gid_t rgid, egid, sgid; ret = get_errno(getresgid(&rgid, &egid, &sgid)); if (!is_error(ret)) { - if (put_user_u16(high2lowgid(rgid), arg1) - || put_user_u16(high2lowgid(egid), arg2) - || put_user_u16(high2lowgid(sgid), arg3)) + if (put_user_id(high2lowgid(rgid), arg1) + || put_user_id(high2lowgid(egid), arg2) + || put_user_id(high2lowgid(sgid), arg3)) goto efault; } }