From patchwork Sun Mar 2 19:36:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 25580 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f69.google.com (mail-pb0-f69.google.com [209.85.160.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 302F720E7B for ; Sun, 2 Mar 2014 19:36:49 +0000 (UTC) Received: by mail-pb0-f69.google.com with SMTP id md12sf8384323pbc.0 for ; Sun, 02 Mar 2014 11:36:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=u2z/7+JEyMg9vymnGc+ZN2i7j49ZbTyLmb4mcLSB81M=; b=QNCwzFk6gEp+sCFk54jLcBmzjxQnKyl/O+TJYZZEdXdBD+foCoovjpQ9y6tOWnaGFW jUxY8dXKjLdw9+2/g3pKcF+3TFxWkam3cslaxUfYvET/SCkhkRrEqjvfeThM4+gwm25U nYEx15oasF9J7XfFmgaGOA4DKeHmdlmOWKRdHBRtVsJRpQgHWajqAYTX7uXu5uek7OBw wY0E9+iVqLjWJqcKvPKr/dLMZv2DtD1UASNx23R6+IjYwUMPcG0OGDgKMuzkiiTrsqmn UpaR3PU6MUA0+y48EXkftevLWW37dYQghOxB4mv5pG0ps3zixTOsEYZzY+c0r+BSs0iX /RXA== X-Gm-Message-State: ALoCoQncpp5dJDQg3EilmIX6tgWWu8BVzIf2kn7yykolCd5A1nG4CJi+GjlZ3opd8wGEXQ/1ShOU X-Received: by 10.66.137.8 with SMTP id qe8mr6567111pab.46.1393789008144; Sun, 02 Mar 2014 11:36:48 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.106.165 with SMTP id e34ls1983276qgf.29.gmail; Sun, 02 Mar 2014 11:36:47 -0800 (PST) X-Received: by 10.58.161.46 with SMTP id xp14mr80355veb.37.1393789007883; Sun, 02 Mar 2014 11:36:47 -0800 (PST) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id ry8si2777524vdc.136.2014.03.02.11.36.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Mar 2014 11:36:47 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.173 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.173; Received: by mail-ve0-f173.google.com with SMTP id oy12so734511veb.18 for ; Sun, 02 Mar 2014 11:36:47 -0800 (PST) X-Received: by 10.58.132.203 with SMTP id ow11mr13771854veb.1.1393789007817; Sun, 02 Mar 2014 11:36:47 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.130.193 with SMTP id u1csp8760vcs; Sun, 2 Mar 2014 11:36:47 -0800 (PST) X-Received: by 10.152.202.7 with SMTP id ke7mr11610616lac.30.1393789005410; Sun, 02 Mar 2014 11:36:45 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id x2si18195094lad.42.2014.03.02.11.36.44 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 02 Mar 2014 11:36:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WKCBm-0007nx-MY; Sun, 02 Mar 2014 19:36:42 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Alexander Graf , Michael Matz , Andreas Schwab , Riku Voipio Subject: [PATCH 4/5] linux-user: Fix getresuid, getresgid if !USE_UID16 Date: Sun, 2 Mar 2014 19:36:41 +0000 Message-Id: <1393789002-29960-5-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1393789002-29960-1-git-send-email-peter.maydell@linaro.org> References: <1393789002-29960-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.173 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 Reviewed-by: Andreas Färber --- The SuSE 1.6 tree has a fix for this bug (hence the reported-by:) but I preferred to fix it in a different way to avoid introducing more ifdefs. --- 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; } }