Name: Get Rid of 32-bit Group Operations Wrappers Author: Rusty Russell Status: Untested D: IA64, Sparc64 and S390 all have their own "sys32_getgroups16" and D: "sys32_setgroups16" which are identical to the kernel/uid16.c D: versions (probably because uid16.c didn't exist at the time). D: Simply substitute them, and set CONFIG_UID16 if needed diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .13005-linux-2.6.0-test5-bk9/arch/ia64/Kconfig .13005-linux-2.6.0-test5-bk9.updated/arch/ia64/Kconfig --- .13005-linux-2.6.0-test5-bk9/arch/ia64/Kconfig 2003-09-23 00:39:34.000000000 +1000 +++ .13005-linux-2.6.0-test5-bk9.updated/arch/ia64/Kconfig 2003-09-23 16:16:40.000000000 +1000 @@ -394,6 +394,10 @@ config COMPAT depends on IA32_SUPPORT default y +config UID16 + bool + depends on IA32_SUPPORT + config PERFMON bool "Performance monitor support" help diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .13005-linux-2.6.0-test5-bk9/arch/ia64/ia32/ia32_entry.S .13005-linux-2.6.0-test5-bk9.updated/arch/ia64/ia32/ia32_entry.S --- .13005-linux-2.6.0-test5-bk9/arch/ia64/ia32/ia32_entry.S 2003-09-22 10:26:21.000000000 +1000 +++ .13005-linux-2.6.0-test5-bk9.updated/arch/ia64/ia32/ia32_entry.S 2003-09-23 16:13:52.000000000 +1000 @@ -266,8 +266,8 @@ ia32_syscall_table: data8 compat_sys_getrusage data8 sys32_gettimeofday data8 sys32_settimeofday - data8 sys32_getgroups16 /* 80 */ - data8 sys32_setgroups16 + data8 sys_getgroups16 /* 80 */ + data8 sys_setgroups16 data8 sys32_old_select data8 sys_symlink data8 sys32_ni_syscall diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .13005-linux-2.6.0-test5-bk9/arch/ia64/ia32/sys_ia32.c .13005-linux-2.6.0-test5-bk9.updated/arch/ia64/ia32/sys_ia32.c --- .13005-linux-2.6.0-test5-bk9/arch/ia64/ia32/sys_ia32.c 2003-09-23 00:39:34.000000000 +1000 +++ .13005-linux-2.6.0-test5-bk9.updated/arch/ia64/ia32/sys_ia32.c 2003-09-23 16:13:52.000000000 +1000 @@ -2424,46 +2424,6 @@ sys32_lseek (unsigned int fd, int offset return sys_lseek(fd, offset, whence); } -extern asmlinkage long sys_getgroups (int gidsetsize, gid_t *grouplist); - -asmlinkage long -sys32_getgroups16 (int gidsetsize, short *grouplist) -{ - mm_segment_t old_fs = get_fs(); - gid_t gl[NGROUPS]; - int ret, i; - - set_fs(KERNEL_DS); - ret = sys_getgroups(gidsetsize, gl); - set_fs(old_fs); - - if (gidsetsize && ret > 0 && ret <= NGROUPS) - for (i = 0; i < ret; i++, grouplist++) - if (put_user(gl[i], grouplist)) - return -EFAULT; - return ret; -} - -extern asmlinkage long sys_setgroups (int gidsetsize, gid_t *grouplist); - -asmlinkage long -sys32_setgroups16 (int gidsetsize, short *grouplist) -{ - mm_segment_t old_fs = get_fs(); - gid_t gl[NGROUPS]; - int ret, i; - - if ((unsigned) gidsetsize > NGROUPS) - return -EINVAL; - for (i = 0; i < gidsetsize; i++, grouplist++) - if (get_user(gl[i], grouplist)) - return -EFAULT; - set_fs(KERNEL_DS); - ret = sys_setgroups(gidsetsize, gl); - set_fs(old_fs); - return ret; -} - asmlinkage long sys32_truncate64 (unsigned int path, unsigned int len_lo, unsigned int len_hi) { diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .13005-linux-2.6.0-test5-bk9/arch/s390/Kconfig .13005-linux-2.6.0-test5-bk9.updated/arch/s390/Kconfig --- .13005-linux-2.6.0-test5-bk9/arch/s390/Kconfig 2003-09-22 10:27:55.000000000 +1000 +++ .13005-linux-2.6.0-test5-bk9.updated/arch/s390/Kconfig 2003-09-23 16:16:17.000000000 +1000 @@ -26,7 +26,7 @@ config ARCH_S390 config UID16 bool default y - depends on ARCH_S390X = 'n' + depends on ARCH_S390X = 'n' || S390_SUPPORT = 'y' source "init/Kconfig" diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .13005-linux-2.6.0-test5-bk9/arch/s390/kernel/compat_linux.c .13005-linux-2.6.0-test5-bk9.updated/arch/s390/kernel/compat_linux.c --- .13005-linux-2.6.0-test5-bk9/arch/s390/kernel/compat_linux.c 2003-09-22 10:26:23.000000000 +1000 +++ .13005-linux-2.6.0-test5-bk9.updated/arch/s390/kernel/compat_linux.c 2003-09-23 16:13:52.000000000 +1000 @@ -189,42 +189,6 @@ asmlinkage long sys32_setfsgid16(u16 gid return sys_setfsgid((gid_t)gid); } -asmlinkage long sys32_getgroups16(int gidsetsize, u16 *grouplist) -{ - u16 groups[NGROUPS]; - int i,j; - - if (gidsetsize < 0) - return -EINVAL; - i = current->ngroups; - if (gidsetsize) { - if (i > gidsetsize) - return -EINVAL; - for(j=0;jgroups[j]; - if (copy_to_user(grouplist, groups, sizeof(u16)*i)) - return -EFAULT; - } - return i; -} - -asmlinkage long sys32_setgroups16(int gidsetsize, u16 *grouplist) -{ - u16 groups[NGROUPS]; - int i; - - if (!capable(CAP_SETGID)) - return -EPERM; - if ((unsigned) gidsetsize > NGROUPS) - return -EINVAL; - if (copy_from_user(groups, grouplist, gidsetsize * sizeof(u16))) - return -EFAULT; - for (i = 0 ; i < gidsetsize ; i++) - current->groups[i] = (gid_t)groups[i]; - current->ngroups = gidsetsize; - return 0; -} - asmlinkage long sys32_getuid16(void) { return high2lowuid(current->uid); diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .13005-linux-2.6.0-test5-bk9/arch/s390/kernel/compat_wrapper.S .13005-linux-2.6.0-test5-bk9.updated/arch/s390/kernel/compat_wrapper.S --- .13005-linux-2.6.0-test5-bk9/arch/s390/kernel/compat_wrapper.S 2003-09-22 10:08:17.000000000 +1000 +++ .13005-linux-2.6.0-test5-bk9.updated/arch/s390/kernel/compat_wrapper.S 2003-09-23 16:13:52.000000000 +1000 @@ -344,13 +344,13 @@ sys32_settimeofday_wrapper: sys32_getgroups16_wrapper: lgfr %r2,%r2 # int llgtr %r3,%r3 # __kernel_old_gid_emu31_t * - jg sys32_getgroups16 # branch to system call + jg sys_getgroups16 # branch to system call .globl sys32_setgroups16_wrapper sys32_setgroups16_wrapper: lgfr %r2,%r2 # int llgtr %r3,%r3 # __kernel_old_gid_emu31_t * - jg sys32_setgroups16 # branch to system call + jg sys_setgroups16 # branch to system call .globl sys32_symlink_wrapper sys32_symlink_wrapper: diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .13005-linux-2.6.0-test5-bk9/arch/sparc64/Kconfig .13005-linux-2.6.0-test5-bk9.updated/arch/sparc64/Kconfig --- .13005-linux-2.6.0-test5-bk9/arch/sparc64/Kconfig 2003-09-23 00:39:35.000000000 +1000 +++ .13005-linux-2.6.0-test5-bk9.updated/arch/sparc64/Kconfig 2003-09-23 16:15:07.000000000 +1000 @@ -379,6 +379,10 @@ config COMPAT depends on SPARC32_COMPAT default y +config UID16 + bool + depends on SPARC32_COMPAT + config BINFMT_ELF32 tristate "Kernel support for 32-bit ELF binaries" depends on SPARC32_COMPAT diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .13005-linux-2.6.0-test5-bk9/arch/sparc64/kernel/sys_sparc32.c .13005-linux-2.6.0-test5-bk9.updated/arch/sparc64/kernel/sys_sparc32.c --- .13005-linux-2.6.0-test5-bk9/arch/sparc64/kernel/sys_sparc32.c 2003-09-22 10:27:56.000000000 +1000 +++ .13005-linux-2.6.0-test5-bk9.updated/arch/sparc64/kernel/sys_sparc32.c 2003-09-23 16:13:52.000000000 +1000 @@ -206,42 +206,6 @@ asmlinkage long sys32_setfsgid16(u16 gid return sys_setfsgid((gid_t)gid); } -asmlinkage long sys32_getgroups16(int gidsetsize, u16 *grouplist) -{ - u16 groups[NGROUPS]; - int i,j; - - if (gidsetsize < 0) - return -EINVAL; - i = current->ngroups; - if (gidsetsize) { - if (i > gidsetsize) - return -EINVAL; - for(j=0;jgroups[j]; - if (copy_to_user(grouplist, groups, sizeof(u16)*i)) - return -EFAULT; - } - return i; -} - -asmlinkage long sys32_setgroups16(int gidsetsize, u16 *grouplist) -{ - u16 groups[NGROUPS]; - int i; - - if (!capable(CAP_SETGID)) - return -EPERM; - if ((unsigned) gidsetsize > NGROUPS) - return -EINVAL; - if (copy_from_user(groups, grouplist, gidsetsize * sizeof(u16))) - return -EFAULT; - for (i = 0 ; i < gidsetsize ; i++) - current->groups[i] = (gid_t)groups[i]; - current->ngroups = gidsetsize; - return 0; -} - asmlinkage long sys32_getuid16(void) { return high2lowuid(current->uid); diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .13005-linux-2.6.0-test5-bk9/arch/sparc64/kernel/systbls.S .13005-linux-2.6.0-test5-bk9.updated/arch/sparc64/kernel/systbls.S --- .13005-linux-2.6.0-test5-bk9/arch/sparc64/kernel/systbls.S 2003-09-22 10:27:56.000000000 +1000 +++ .13005-linux-2.6.0-test5-bk9.updated/arch/sparc64/kernel/systbls.S 2003-09-23 16:13:52.000000000 +1000 @@ -34,8 +34,8 @@ sys_call_table32: /*60*/ .word sys_umask, sys_chroot, compat_sys_newfstat, sys_fstat64, sys_getpagesize .word sys_msync, sys_vfork, sys32_pread64, sys32_pwrite64, sys_geteuid /*70*/ .word sys_getegid, sys32_mmap, sys_setreuid, sys_munmap, sys_mprotect - .word sys_madvise, sys_vhangup, sys32_truncate64, sys_mincore, sys32_getgroups16 -/*80*/ .word sys32_setgroups16, sys_getpgrp, sys_setgroups, compat_sys_setitimer, sys32_ftruncate64 + .word sys_madvise, sys_vhangup, sys32_truncate64, sys_mincore, sys_getgroups16 +/*80*/ .word sys_setgroups16, sys_getpgrp, sys_setgroups, compat_sys_setitimer, sys32_ftruncate64 .word sys_swapon, compat_sys_getitimer, sys_setuid, sys_sethostname, sys_setgid /*90*/ .word sys_dup2, sys_setfsuid, compat_sys_fcntl, sys32_select, sys_setfsgid .word sys_fsync, sys_setpriority32, sys_nis_syscall, sys_nis_syscall, sys_nis_syscall