summaryrefslogtreecommitdiffstats
path: root/linux-user
diff options
context:
space:
mode:
authorPeter Maydell2014-03-02 20:36:41 +0100
committerRiku Voipio2014-03-03 22:03:31 +0100
commit76ca310a19463e9883e2e55a88ac8be1fc171eea (patch)
treefc0a0e5c90094c920021d4204735865b692f94aa /linux-user
parentlinux-user: Don't use UID16 on AArch64 (diff)
downloadqemu-76ca310a19463e9883e2e55a88ac8be1fc171eea.tar.gz
qemu-76ca310a19463e9883e2e55a88ac8be1fc171eea.tar.xz
qemu-76ca310a19463e9883e2e55a88ac8be1fc171eea.zip
linux-user: Fix getresuid, getresgid if !USE_UID16
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> Signed-off-by: Riku Voipio <riku.voipio@linaro.org> Reviewed-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/syscall.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 1407b7a546..ccdbc4e321 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;
}
}