From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: Helge Deller <deller@kernel.org>,
qemu-stable@nongnu.org, Helge Deller <deller@gmx.de>,
Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PULL 01/14] linux-user: Fix setreuid and setregid to use direct syscalls
Date: Fri, 15 Nov 2024 12:58:36 -0800 [thread overview]
Message-ID: <20241115205849.266094-2-richard.henderson@linaro.org> (raw)
In-Reply-To: <20241115205849.266094-1-richard.henderson@linaro.org>
From: Helge Deller <deller@kernel.org>
The commit fd6f7798ac30 ("linux-user: Use direct syscalls for setuid(),
etc") added direct syscall wrappers for setuid(), setgid(), etc since the
system calls have different semantics than the libc functions.
Add and use the corresponding wrappers for setreuid and setregid which
were missed in that commit.
This fixes the build of the debian package of the uid_wrapper library
(https://cwrap.org/uid_wrapper.html) when running linux-user.
Cc: qemu-stable@nongnu.org
Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-ID: <Zyo2jMKqq8hG8Pkz@p100>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/syscall.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 59b2080b98..0279f23576 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7233,12 +7233,24 @@ static inline int tswapid(int id)
#else
#define __NR_sys_setgroups __NR_setgroups
#endif
+#ifdef __NR_sys_setreuid32
+#define __NR_sys_setreuid __NR_setreuid32
+#else
+#define __NR_sys_setreuid __NR_setreuid
+#endif
+#ifdef __NR_sys_setregid32
+#define __NR_sys_setregid __NR_setregid32
+#else
+#define __NR_sys_setregid __NR_setregid
+#endif
_syscall1(int, sys_setuid, uid_t, uid)
_syscall1(int, sys_setgid, gid_t, gid)
_syscall3(int, sys_setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
_syscall3(int, sys_setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
_syscall2(int, sys_setgroups, int, size, gid_t *, grouplist)
+_syscall2(int, sys_setreuid, uid_t, ruid, uid_t, euid);
+_syscall2(int, sys_setregid, gid_t, rgid, gid_t, egid);
void syscall_init(void)
{
@@ -11932,9 +11944,9 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
return get_errno(high2lowgid(getegid()));
#endif
case TARGET_NR_setreuid:
- return get_errno(setreuid(low2highuid(arg1), low2highuid(arg2)));
+ return get_errno(sys_setreuid(low2highuid(arg1), low2highuid(arg2)));
case TARGET_NR_setregid:
- return get_errno(setregid(low2highgid(arg1), low2highgid(arg2)));
+ return get_errno(sys_setregid(low2highgid(arg1), low2highgid(arg2)));
case TARGET_NR_getgroups:
{ /* the same code as for TARGET_NR_getgroups32 */
int gidsetsize = arg1;
@@ -12264,11 +12276,11 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
#endif
#ifdef TARGET_NR_setreuid32
case TARGET_NR_setreuid32:
- return get_errno(setreuid(arg1, arg2));
+ return get_errno(sys_setreuid(arg1, arg2));
#endif
#ifdef TARGET_NR_setregid32
case TARGET_NR_setregid32:
- return get_errno(setregid(arg1, arg2));
+ return get_errno(sys_setregid(arg1, arg2));
#endif
#ifdef TARGET_NR_getgroups32
case TARGET_NR_getgroups32:
--
2.43.0
next prev parent reply other threads:[~2024-11-15 20:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-15 20:58 [PULL 00/14] tcg + linux-user patch queue Richard Henderson
2024-11-15 20:58 ` Richard Henderson [this message]
2024-11-15 20:58 ` [PULL 02/14] accel/tcg: Fix user-only probe_access_internal plugin check Richard Henderson
2024-11-15 20:58 ` [PULL 03/14] linux-user: Tolerate CONFIG_LSM_MMAP_MIN_ADDR Richard Henderson
2024-11-15 20:58 ` [PULL 04/14] tests/tcg: Test that sigreturn() does not corrupt the signal mask Richard Henderson
2024-11-15 20:58 ` [PULL 05/14] target/i386: fix hang when using slow path for ptw_setl Richard Henderson
2024-11-15 20:58 ` [PULL 06/14] cpu: ensure we don't call start_exclusive from cpu_exec Richard Henderson
2024-11-15 20:58 ` [PULL 07/14] linux-user: Honor elf alignment when placing images Richard Henderson
2024-11-15 20:58 ` [PULL 08/14] linux-user: Drop image_info.alignment Richard Henderson
2024-11-15 20:58 ` [PULL 09/14] linux-user/aarch64: Reduce vdso alignment to 4k Richard Henderson
2024-11-15 20:58 ` [PULL 10/14] linux-user/arm: " Richard Henderson
2024-11-15 20:58 ` [PULL 11/14] linux-user/loongarch64: " Richard Henderson
2024-11-15 20:58 ` [PULL 12/14] linux-user/ppc: " Richard Henderson
2024-11-15 20:58 ` [PULL 13/14] linux-user/arm: Select vdso for be8 and be32 modes Richard Henderson
2024-11-15 20:58 ` [PULL 14/14] tcg: Allow top bit of SIMD_DATA_BITS to be set in simd_desc() Richard Henderson
2024-11-16 10:39 ` [PULL 00/14] tcg + linux-user patch queue Peter Maydell
2024-11-16 16:38 ` Richard Henderson
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=20241115205849.266094-2-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=deller@gmx.de \
--cc=deller@kernel.org \
--cc=iii@linux.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
/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).