qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: Andreas Schwab <schwab@suse.de>, Riku Voipio <riku.voipio@iki.fi>,
	Michael Matz <matz@suse.de>, Alexander Graf <agraf@suse.de>,
	patches@linaro.org
Subject: [Qemu-devel] [PATCH 4/5] linux-user: Fix getresuid, getresgid if !USE_UID16
Date: Sun,  2 Mar 2014 19:36:41 +0000	[thread overview]
Message-ID: <1393789002-29960-5-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1393789002-29960-1-git-send-email-peter.maydell@linaro.org>

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 <matz@suse.de>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
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;
             }
         }
-- 
1.9.0

  parent reply	other threads:[~2014-03-02 19:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-02 19:36 [Qemu-devel] [PATCH 0/5] linux-user: various fixes for AArch64 Peter Maydell
2014-03-02 19:36 ` [Qemu-devel] [PATCH 1/5] linux-user/signal.c: Fix AArch64 big-endian FP register restore Peter Maydell
2014-03-02 19:36 ` [Qemu-devel] [PATCH 2/5] linux-user: AArch64: Implement SA_RESTORER for signal handlers Peter Maydell
2014-03-02 19:36 ` [Qemu-devel] [PATCH 3/5] linux-user: Don't use UID16 on AArch64 Peter Maydell
2014-03-02 19:36 ` Peter Maydell [this message]
2014-03-02 21:05   ` [Qemu-devel] [PATCH 4/5] linux-user: Fix getresuid, getresgid if !USE_UID16 Andreas Färber
2014-03-02 19:36 ` [Qemu-devel] [PATCH 5/5] linux-user: Implement sendmmsg syscall Peter Maydell
2014-03-03 16:33 ` [Qemu-devel] [PATCH 0/5] linux-user: various fixes for AArch64 Richard Henderson
2014-03-03 21:10 ` Riku Voipio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393789002-29960-5-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=agraf@suse.de \
    --cc=matz@suse.de \
    --cc=patches@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).