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: 25960 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f200.google.com (mail-qc0-f200.google.com [209.85.216.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 84B222055F for ; Mon, 10 Mar 2014 12:26:00 +0000 (UTC) Received: by mail-qc0-f200.google.com with SMTP id i17sf17364346qcy.3 for ; Mon, 10 Mar 2014 05:26:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=j/N5i5iSswVPXUhcpTI0HxhYdb7U7lkqtp2Vnz99uiY=; b=ELpBOKrDtca9qiINSA2Ad6ywQs0nbZbpfdcvrSXtPmXBhyBshyx5oz4NtFdGhc8OUB 8Ami7S5xmj1/9rJFxd92C69Yp7uo8KjuBtdBY2ro+7scOxDMZRZWxBgcF5cYEVeXmmsZ pK9zuZ2PoR4BcGGjpP8cfOmbiR1529hz9Y/pRRWnVP0Qux/1lm8ByLwsmoKrLwslOwbq 0YCVUSrV67+i2AkN7JNRjpk69A8Rt/oxibBq8IF/Pozr3+ZhjyO7tRLo378CEiNbH0/z 5Ry6iR11JdFjxP3dyJDzO/wxmCO8lte0a5nbZmk6oC/yr9iWsxXVgVeCA4UoGzgsh67R ZW6A== X-Gm-Message-State: ALoCoQk3H2KAWtvwCgO+CBZBpKc6pKsOmIVQhrK2p0EDBJupi7fZ6TVTAwtenYXdoWoNL7ZAyrF8 X-Received: by 10.52.103.103 with SMTP id fv7mr1621160vdb.3.1394454360305; Mon, 10 Mar 2014 05:26:00 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.50.115 with SMTP id r106ls639186qga.73.gmail; Mon, 10 Mar 2014 05:26:00 -0700 (PDT) X-Received: by 10.221.22.71 with SMTP id qv7mr52444vcb.34.1394454360162; Mon, 10 Mar 2014 05:26:00 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id qi7si4658587veb.72.2014.03.10.05.26.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Mar 2014 05:26:00 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id oz11so6864667veb.6 for ; Mon, 10 Mar 2014 05:26:00 -0700 (PDT) X-Received: by 10.221.29.137 with SMTP id ry9mr1176881vcb.6.1394454360079; Mon, 10 Mar 2014 05:26:00 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp114729vck; Mon, 10 Mar 2014 05:25:59 -0700 (PDT) X-Received: by 10.140.102.215 with SMTP id w81mr925276qge.109.1394454359534; Mon, 10 Mar 2014 05:25:59 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q1si9306735qab.31.2014.03.10.05.25.59 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 10 Mar 2014 05:25:59 -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; Received: from localhost ([::1]:48412 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WMzHL-0007a0-2v for patch@linaro.org; Mon, 10 Mar 2014 08:25:59 -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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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; } }