linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] s390: fix setgid16/setuid16 handling of -1
@ 2018-01-15 11:52 Eugene Syromiatnikov
  2018-01-15 12:06 ` Greg Kroah-Hartman
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Eugene Syromiatnikov @ 2018-01-15 11:52 UTC (permalink / raw)
  To: linux-s390
  Cc: Martin Schwidefsky, Heiko Carstens, Paul Gortmaker,
	Philippe Ombredanne, Greg Kroah-Hartman, Kate Stewart,
	Thomas Gleixner, Eugene Syromiatnikov, linux-kernel

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.

Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
---
 arch/s390/kernel/compat_linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index f04db37..e48a31a 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -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)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] s390: fix setgid16/setuid16 handling of -1
  2018-01-15 11:52 [PATCH] s390: fix setgid16/setuid16 handling of -1 Eugene Syromiatnikov
@ 2018-01-15 12:06 ` Greg Kroah-Hartman
  2018-01-15 15:19 ` Heiko Carstens
  2018-01-15 19:38 ` [PATCH v2] s390: fix handling of -1 in set{,fs}[gu]id16 syscalls Eugene Syromiatnikov
  2 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2018-01-15 12:06 UTC (permalink / raw)
  To: Eugene Syromiatnikov
  Cc: linux-s390, Martin Schwidefsky, Heiko Carstens, Paul Gortmaker,
	Philippe Ombredanne, Kate Stewart, Thomas Gleixner, linux-kernel

On Mon, Jan 15, 2018 at 12:52:42PM +0100, Eugene Syromiatnikov wrote:
> 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.
> 
> Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] s390: fix setgid16/setuid16 handling of -1
  2018-01-15 11:52 [PATCH] s390: fix setgid16/setuid16 handling of -1 Eugene Syromiatnikov
  2018-01-15 12:06 ` Greg Kroah-Hartman
@ 2018-01-15 15:19 ` Heiko Carstens
  2018-01-15 19:38 ` [PATCH v2] s390: fix handling of -1 in set{,fs}[gu]id16 syscalls Eugene Syromiatnikov
  2 siblings, 0 replies; 5+ messages in thread
From: Heiko Carstens @ 2018-01-15 15:19 UTC (permalink / raw)
  To: Eugene Syromiatnikov
  Cc: linux-s390, Martin Schwidefsky, Paul Gortmaker,
	Philippe Ombredanne, Greg Kroah-Hartman, Kate Stewart,
	Thomas Gleixner, linux-kernel

On Mon, Jan 15, 2018 at 12:52:42PM +0100, Eugene Syromiatnikov wrote:
> 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.
> 
> Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
> ---
>  arch/s390/kernel/compat_linux.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
> index f04db37..e48a31a 100644
> --- a/arch/s390/kernel/compat_linux.c
> +++ b/arch/s390/kernel/compat_linux.c
> @@ -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));

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] s390: fix handling of -1 in set{,fs}[gu]id16 syscalls
  2018-01-15 11:52 [PATCH] s390: fix setgid16/setuid16 handling of -1 Eugene Syromiatnikov
  2018-01-15 12:06 ` Greg Kroah-Hartman
  2018-01-15 15:19 ` Heiko Carstens
@ 2018-01-15 19:38 ` Eugene Syromiatnikov
  2018-01-15 22:36   ` Heiko Carstens
  2 siblings, 1 reply; 5+ messages in thread
From: Eugene Syromiatnikov @ 2018-01-15 19:38 UTC (permalink / raw)
  To: linux-s390
  Cc: Martin Schwidefsky, Heiko Carstens, Paul Gortmaker,
	Philippe Ombredanne, Greg Kroah-Hartman, Kate Stewart,
	Thomas Gleixner, Eugene Syromiatnikov, linux-kernel

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.

Cc: stable@vger.kernel.org
Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
---
 arch/s390/kernel/compat_linux.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c
index f04db37..9ba2ab2 100644
--- a/arch/s390/kernel/compat_linux.c
+++ b/arch/s390/kernel/compat_linux.c
@@ -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)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] s390: fix handling of -1 in set{,fs}[gu]id16 syscalls
  2018-01-15 19:38 ` [PATCH v2] s390: fix handling of -1 in set{,fs}[gu]id16 syscalls Eugene Syromiatnikov
@ 2018-01-15 22:36   ` Heiko Carstens
  0 siblings, 0 replies; 5+ messages in thread
From: Heiko Carstens @ 2018-01-15 22:36 UTC (permalink / raw)
  To: Eugene Syromiatnikov
  Cc: linux-s390, Martin Schwidefsky, Paul Gortmaker,
	Philippe Ombredanne, Greg Kroah-Hartman, Kate Stewart,
	Thomas Gleixner, linux-kernel

On Mon, Jan 15, 2018 at 08:38:17PM +0100, Eugene Syromiatnikov wrote:
> 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.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Eugene Syromiatnikov <esyr@redhat.com>
> ---
>  arch/s390/kernel/compat_linux.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Applied, thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-15 22:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-15 11:52 [PATCH] s390: fix setgid16/setuid16 handling of -1 Eugene Syromiatnikov
2018-01-15 12:06 ` Greg Kroah-Hartman
2018-01-15 15:19 ` Heiko Carstens
2018-01-15 19:38 ` [PATCH v2] s390: fix handling of -1 in set{,fs}[gu]id16 syscalls Eugene Syromiatnikov
2018-01-15 22:36   ` Heiko Carstens

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).