Return-Path: Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Heiko Carstens" , "Martin Schwidefsky" , "Eugene Syromiatnikov" Date: Wed, 30 May 2018 11:52:41 +0100 Message-ID: Subject: [PATCH 3.2 060/153] s390: fix handling of -1 in set{,fs}[gu]id16 syscalls In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-ID: 3.2.102-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Eugene Syromiatnikov commit 6dd0d2d22aa363fec075cb2577ba273ac8462e94 upstream. 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. Signed-off-by: Eugene Syromiatnikov Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings --- arch/s390/kernel/compat_linux.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/arch/s390/kernel/compat_linux.c +++ b/arch/s390/kernel/compat_linux.c @@ -114,7 +114,7 @@ asmlinkage long sys32_setregid16(u16 rgi asmlinkage long sys32_setgid16(u16 gid) { - return sys_setgid((gid_t)gid); + return sys_setgid(low2highgid(gid)); } asmlinkage long sys32_setreuid16(u16 ruid, u16 euid) @@ -124,7 +124,7 @@ asmlinkage long sys32_setreuid16(u16 rui asmlinkage long sys32_setuid16(u16 uid) { - return sys_setuid((uid_t)uid); + return sys_setuid(low2highuid(uid)); } asmlinkage long sys32_setresuid16(u16 ruid, u16 euid, u16 suid) @@ -163,12 +163,12 @@ asmlinkage long sys32_getresgid16(u16 __ asmlinkage long sys32_setfsuid16(u16 uid) { - return sys_setfsuid((uid_t)uid); + return sys_setfsuid(low2highuid(uid)); } asmlinkage long sys32_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)