Skip to contentSkip to conversation

s390: fix setgid16/setuid16 handling of -1

PATCH In review Eugene Syromiatnikov 3 participants 5 messages Jan 15, 2018 s390

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390: fix setgid16/setuid16 handling of -1

For some reason, the implementation of these two 16-bit ID system calls used cast instead of low2highgid/low2highuid macros for converting [GU]IDs, which leads to incorrect handling of value of -1 (which ought to be considered invalid).

Discovered by strace test suite.

---
 arch/s390/kernel/compat_linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/kernel/compat_linux.c +2 -2
index f04db37..e48a31a 100644
@@ -110,7 +110,7 @@ COMPAT_SYSCALL_DEFINE2(s390_setregid16, u16, rgid, u16, egid)
 
 COMPAT_SYSCALL_DEFINE1(s390_setgid16, u16, gid)
 {
-	return sys_setgid((gid_t)gid);
+	return sys_setgid(low2highgid(gid));
 }
 
 COMPAT_SYSCALL_DEFINE2(s390_setreuid16, u16, ruid, u16, euid)
@@ -120,7 +120,7 @@ COMPAT_SYSCALL_DEFINE2(s390_setreuid16, u16, ruid, u16, euid)
 
 COMPAT_SYSCALL_DEFINE1(s390_setuid16, u16, uid)
 {
-	return sys_setuid((uid_t)uid);
+	return sys_setuid(low2highuid(uid));
 }
 
 COMPAT_SYSCALL_DEFINE3(s390_setresuid16, u16, ruid, u16, euid, u16, suid)
Signature · 1 line
2.9.3
#1 lore raw
Quoted 11 lines · Eugene Syromiatnikov

For some reason, the implementation of these two 16-bit ID system calls used cast instead of low2highgid/low2highuid macros for converting [GU]IDs, which leads to incorrect handling of value of -1 (which ought to be considered invalid).

Discovered by strace test suite.

---
 arch/s390/kernel/compat_linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Care to add a cc: stable on this?

thanks,

greg k-h

#2 lore raw
In reply to Eugene Syromiatnikov
Quoted 26 lines · Eugene Syromiatnikov

For some reason, the implementation of these two 16-bit ID system calls used cast instead of low2highgid/low2highuid macros for converting [GU]IDs, which leads to incorrect handling of value of -1 (which ought to be considered invalid).

Discovered by strace test suite.

---
 arch/s390/kernel/compat_linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/s390/kernel/compat_linux.c +1 -1
index f04db37..e48a31a 100644
@@ -110,7 +110,7 @@ COMPAT_SYSCALL_DEFINE2(s390_setregid16, u16, rgid, u16, egid)
 
 COMPAT_SYSCALL_DEFINE1(s390_setgid16, u16, gid)
 {
-	return sys_setgid((gid_t)gid);
+	return sys_setgid(low2highgid(gid));
 }
 
 COMPAT_SYSCALL_DEFINE2(s390_setreuid16, u16, ruid, u16, euid)

arch/s390/kernel/compat_linux.c COMPAT_SYSCALL_DEFINE2(s390_setreuid16, u16, ruid, u16, euid) · line 123

Quoted 5 lines
arch/s390/kernel/compat_linux.c +1 -1
@@ -120,7 +120,7 @@ COMPAT_SYSCALL_DEFINE2(s390_setreuid16, u16, ruid, u16, euid)
 
 COMPAT_SYSCALL_DEFINE1(s390_setuid16, u16, uid)
 {
-	return sys_setuid((uid_t)uid);
+	return sys_setuid(low2highuid(uid));

Thank you! Would you mind to fix this also for s390_setfsuid16 and s390_setfsgid16 within the same file, and resend?

#3 lore raw

PATCH v2 1/1 s390: fix handling of -1 in set{,fs}[gu]id16 syscalls

In reply to Eugene Syromiatnikov

For some reason, the implementation of some 16-bit ID system calls (namely, setuid16/setgid16 and setfsuid16/setfsgid16) used type cast instead of low2highgid/low2highuid macros for converting [GU]IDs, which led to incorrect handling of value of -1 (which ought to be considered invalid).

Discovered by strace test suite.

---
 arch/s390/kernel/compat_linux.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/s390/kernel/compat_linux.c +4 -4
index f04db37..9ba2ab2 100644
@@ -110,7 +110,7 @@ COMPAT_SYSCALL_DEFINE2(s390_setregid16, u16, rgid, u16, egid)
 
 COMPAT_SYSCALL_DEFINE1(s390_setgid16, u16, gid)
 {
-	return sys_setgid((gid_t)gid);
+	return sys_setgid(low2highgid(gid));
 }
 
 COMPAT_SYSCALL_DEFINE2(s390_setreuid16, u16, ruid, u16, euid)
@@ -120,7 +120,7 @@ COMPAT_SYSCALL_DEFINE2(s390_setreuid16, u16, ruid, u16, euid)
 
 COMPAT_SYSCALL_DEFINE1(s390_setuid16, u16, uid)
 {
-	return sys_setuid((uid_t)uid);
+	return sys_setuid(low2highuid(uid));
 }
 
 COMPAT_SYSCALL_DEFINE3(s390_setresuid16, u16, ruid, u16, euid, u16, suid)
@@ -173,12 +173,12 @@ COMPAT_SYSCALL_DEFINE3(s390_getresgid16, u16 __user *, rgidp,
 
 COMPAT_SYSCALL_DEFINE1(s390_setfsuid16, u16, uid)
 {
-	return sys_setfsuid((uid_t)uid);
+	return sys_setfsuid(low2highuid(uid));
 }
 
 COMPAT_SYSCALL_DEFINE1(s390_setfsgid16, u16, gid)
 {
-	return sys_setfsgid((gid_t)gid);
+	return sys_setfsgid(low2highgid(gid));
 }
 
 static int groups16_to_user(u16 __user *grouplist, struct group_info *group_info)
Signature · 1 line
2.9.3
#4 lore raw

Re: [PATCH v2] s390: fix handling of -1 in set{,fs}[gu]id16 syscalls

Quoted 6 lines · Eugene Syromiatnikov

For some reason, the implementation of some 16-bit ID system calls (namely, setuid16/setgid16 and setfsuid16/setfsgid16) used type cast instead of low2highgid/low2highuid macros for converting [GU]IDs, which led to incorrect handling of value of -1 (which ought to be considered invalid).

Quoted 7 lines

Discovered by strace test suite.

---
 arch/s390/kernel/compat_linux.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Applied, thanks!