Skip to content

Commit 0556f5f

Browse files
iii-iMichael Tokarev
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]> (cherry picked from commit 54b2792) Signed-off-by: Michael Tokarev <[email protected]>
1 parent 7ee9552 commit 0556f5f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

linux-user/syscall.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7210,11 +7210,17 @@ static inline int tswapid(int id)
72107210
#else
72117211
#define __NR_sys_setresgid __NR_setresgid
72127212
#endif
7213+
#ifdef __NR_setgroups32
7214+
#define __NR_sys_setgroups __NR_setgroups32
7215+
#else
7216+
#define __NR_sys_setgroups __NR_setgroups
7217+
#endif
72137218

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

72197225
void syscall_init(void)
72207226
{
@@ -11892,7 +11898,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
1189211898
unlock_user(target_grouplist, arg2,
1189311899
gidsetsize * sizeof(target_id));
1189411900
}
11895-
return get_errno(setgroups(gidsetsize, grouplist));
11901+
return get_errno(sys_setgroups(gidsetsize, grouplist));
1189611902
}
1189711903
case TARGET_NR_fchown:
1189811904
return get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3)));
@@ -12228,7 +12234,7 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
1222812234
}
1222912235
unlock_user(target_grouplist, arg2, 0);
1223012236
}
12231-
return get_errno(setgroups(gidsetsize, grouplist));
12237+
return get_errno(sys_setgroups(gidsetsize, grouplist));
1223212238
}
1223312239
#endif
1223412240
#ifdef TARGET_NR_fchown32

0 commit comments

Comments
 (0)