Skip to content

Commit 54b2792

Browse files
iii-irth7680
authored andcommitted
linux-user: Make TARGET_NR_setgroups affect only the current thread
Like TARGET_NR_setuid, TARGET_NR_setgroups should affect only the calling thread, and not the entire process. Therefore, implement it using a syscall, and not a libc call. Cc: [email protected] Fixes: 19b84f3 ("added setgroups and getgroups syscalls") Signed-off-by: Ilya Leoshkevich <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Message-Id: <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Signed-off-by: Richard Henderson <[email protected]>
1 parent 3b279f7 commit 54b2792

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

linux-user/syscall.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -7209,11 +7209,17 @@ static inline int tswapid(int id)
72097209
#else
72107210
#define __NR_sys_setresgid __NR_setresgid
72117211
#endif
7212+
#ifdef __NR_setgroups32
7213+
#define __NR_sys_setgroups __NR_setgroups32
7214+
#else
7215+
#define __NR_sys_setgroups __NR_setgroups
7216+
#endif
72127217

72137218
_syscall1(int, sys_setuid, uid_t, uid)
72147219
_syscall1(int, sys_setgid, gid_t, gid)
72157220
_syscall3(int, sys_setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
72167221
_syscall3(int, sys_setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
7222+
_syscall2(int, sys_setgroups, int, size, gid_t *, grouplist)
72177223

72187224
void syscall_init(void)
72197225
{
@@ -11891,7 +11897,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
1189111897
unlock_user(target_grouplist, arg2,
1189211898
gidsetsize * sizeof(target_id));
1189311899
}
11894-
return get_errno(setgroups(gidsetsize, grouplist));
11900+
return get_errno(sys_setgroups(gidsetsize, grouplist));
1189511901
}
1189611902
case TARGET_NR_fchown:
1189711903
return get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3)));
@@ -12227,7 +12233,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
1222712233
}
1222812234
unlock_user(target_grouplist, arg2, 0);
1222912235
}
12230-
return get_errno(setgroups(gidsetsize, grouplist));
12236+
return get_errno(sys_setgroups(gidsetsize, grouplist));
1223112237
}
1223212238
#endif
1223312239
#ifdef TARGET_NR_fchown32

0 commit comments

Comments
 (0)