rpc.gssd: truncates 32-bit UIDs/GIDs to 16 bits architectures.
Subsystems (2)
PATCH 1/1 rpc.gssd: truncates 32-bit UIDs/GIDs to 16 bits architectures.
utils/gssd_proc.c uses SYS_setresuid and SYS_setresgid in change_identity when it should use SYS_setresuid32 and SYS_setresgid32 instead. This causes it to truncate UIDs/GIDs > 65536.
--- utils/gssd/gssd_proc.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
utils/gssd/gssd_proc.c +14 -4
@@ -434,6 +434,7 @@ static int change_identity(uid_t uid) {struct passwd *pw; +int res;/* drop list of supplimentary groups first */ if (syscall (SYS_setgroups,0 ,0 ) !=0 ) {
@@ -459,14 +460,23 @@ change_identity(uid_t uid)* send a signal to all other threads to synchronize the uid in all * other threads. To bypass this, we have to call syscall() directly. */ -if (syscall (SYS_setresgid, pw->pw_gid, pw->pw_gid, pw->pw_gid) !=0 ) { +#ifdef __NR_setresuid32 + res =syscall (SYS_setresgid32, pw->pw_gid, pw->pw_gid, pw->pw_gid); +#else + res =syscall (SYS_setresgid, pw->pw_gid, pw->pw_gid, pw->pw_gid); +#endif +if (res !=0 ) {printerr (0 ,"WARNING: failed to set gid to %u!\n" , pw->pw_gid);return errno; } -if (syscall (SYS_setresuid, uid, uid, uid) !=0 ) { -printerr (0 ,"WARNING: Failed to setuid for user with uid %u\n" , - uid); +#ifdef __NR_setresuid32 + res =syscall (SYS_setresuid32, uid, uid, uid); +#else + res =syscall (SYS_setresuid, uid, uid, uid); +#endif +if (res !=0 ) { +printerr (0 ,"WARNING: Failed to setuid for user with uid %u\n" , uid);return errno; }
Signature · 1 line
2.17.1
utils/gssd/gssd_proc.c change_identity(uid_t uid) · line 467
Quoted 6 lines
utils/gssd/gssd_proc.c +5
-1-if (syscall (SYS_setresgid, pw->pw_gid, pw->pw_gid, pw->pw_gid) !=0 ) { +#ifdef __NR_setresuid32 + res =syscall (SYS_setresgid32, pw->pw_gid, pw->pw_gid, pw->pw_gid); +#else + res =syscall (SYS_setresgid, pw->pw_gid, pw->pw_gid, pw->pw_gid); +#endif
I think you want to simply call setresuid/setresgid from glibcs, which will do the right thing instead of doing hand crafted syscalls.
Quoted 9 lines · Christoph Hellwig
utils/gssd/gssd_proc.c change_identity(uid_t uid) · line 467
Quoted 6 lines
utils/gssd/gssd_proc.c +5
-1-if (syscall (SYS_setresgid, pw->pw_gid, pw->pw_gid, pw->pw_gid) !=0 ) { +#ifdef __NR_setresuid32 + res =syscall (SYS_setresgid32, pw->pw_gid, pw->pw_gid, pw->pw_gid); +#else + res =syscall (SYS_setresgid, pw->pw_gid, pw->pw_gid, pw->pw_gid); +#endif I think you want to simply call setresuid/setresgid from glibcs, which will do the right thing instead of doing hand crafted syscalls.
Here is the comment above these calls
/* Switch the UIDs and GIDs. */
/* For the threaded version we have to set uid,gid per thread instead
* of per process. glibc setresuid() when called from a thread, it'll
* send a signal to all other threads to synchronize the uid in all
* other threads. To bypass this, we have to call syscall() directly. */
steved.
Quoted 11 lines · Steve Dickson
utils/gssd_proc.cusesSYS_setresuidandSYS_setresgidinchange_identitywhen it should useSYS_setresuid32andSYS_setresgid32instead. This causes it to truncate UIDs/GIDs > 65536.Tested-by James Ettle <[email protected]>Tested-by Sree <[email protected]>Signed-off-by Steve Dickson <[email protected]>
Committed...
steved.
Quoted 45 lines
--- utils/gssd/gssd_proc.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)utils/gssd/gssd_proc.c +14
-4@@ -434,6 +434,7 @@ static int change_identity(uid_t uid) {struct passwd *pw; +int res;/* drop list of supplimentary groups first */ if (syscall (SYS_setgroups,0 ,0 ) !=0 ) {@@ -459,14 +460,23 @@ change_identity(uid_t uid)* send a signal to all other threads to synchronize the uid in all * other threads. To bypass this, we have to call syscall() directly. */ -if (syscall (SYS_setresgid, pw->pw_gid, pw->pw_gid, pw->pw_gid) !=0 ) { +#ifdef __NR_setresuid32 + res =syscall (SYS_setresgid32, pw->pw_gid, pw->pw_gid, pw->pw_gid); +#else + res =syscall (SYS_setresgid, pw->pw_gid, pw->pw_gid, pw->pw_gid); +#endif +if (res !=0 ) {printerr (0 ,"WARNING: failed to set gid to %u!\n" , pw->pw_gid);return errno; } -if (syscall (SYS_setresuid, uid, uid, uid) !=0 ) { -printerr (0 ,"WARNING: Failed to setuid for user with uid %u\n" , - uid); +#ifdef __NR_setresuid32 + res =syscall (SYS_setresuid32, uid, uid, uid); +#else + res =syscall (SYS_setresuid, uid, uid, uid); +#endif +if (res !=0 ) { +printerr (0 ,"WARNING: Failed to setuid for user with uid %u\n" , uid);return errno; }