This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / kernel / sys.c
index 4d414d9..d22fd2d 100644 (file)
@@ -271,6 +271,9 @@ cond_syscall(compat_sys_mq_timedsend)
 cond_syscall(compat_sys_mq_timedreceive)
 cond_syscall(compat_sys_mq_notify)
 cond_syscall(compat_sys_mq_getsetattr)
+cond_syscall(sys_mbind)
+cond_syscall(sys_get_mempolicy)
+cond_syscall(sys_set_mempolicy)
 
 /* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read)
@@ -348,6 +351,8 @@ asmlinkage long sys_setpriority(int which, int who, int niceval)
                                if (p->uid == who)
                                        error = set_one_prio(p, niceval, error);
                        while_each_thread(g, p);
+                       if (who)
+                               free_uid(user);         /* For find_user() */
                        break;
        }
 out_unlock:
@@ -410,6 +415,8 @@ asmlinkage long sys_getpriority(int which, int who)
                                                retval = niceval;
                                }
                        while_each_thread(g, p);
+                       if (who)
+                               free_uid(user);         /* for find_user() */
                        break;
        }
 out_unlock:
@@ -447,7 +454,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
        switch (cmd) {
        case LINUX_REBOOT_CMD_RESTART:
                notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL);
-               system_state = SYSTEM_SHUTDOWN;
+               system_state = SYSTEM_RESTART;
                device_shutdown();
                printk(KERN_EMERG "Restarting system.\n");
                machine_restart(NULL);
@@ -463,7 +470,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
 
        case LINUX_REBOOT_CMD_HALT:
                notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL);
-               system_state = SYSTEM_SHUTDOWN;
+               system_state = SYSTEM_HALT;
                device_shutdown();
                printk(KERN_EMERG "System halted.\n");
                machine_halt();
@@ -473,7 +480,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
 
        case LINUX_REBOOT_CMD_POWER_OFF:
                notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL);
-               system_state = SYSTEM_SHUTDOWN;
+               system_state = SYSTEM_POWER_OFF;
                device_shutdown();
                printk(KERN_EMERG "Power down.\n");
                machine_power_off();
@@ -489,7 +496,7 @@ asmlinkage long sys_reboot(int magic1, int magic2, unsigned int cmd, void __user
                buffer[sizeof(buffer) - 1] = '\0';
 
                notifier_call_chain(&reboot_notifier_list, SYS_RESTART, buffer);
-               system_state = SYSTEM_SHUTDOWN;
+               system_state = SYSTEM_RESTART;
                device_shutdown();
                printk(KERN_EMERG "Restarting system with command '%s'.\n", buffer);
                machine_restart(buffer);
@@ -812,7 +819,7 @@ asmlinkage long sys_setresuid(uid_t ruid, uid_t euid, uid_t suid)
        return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_RES);
 }
 
-asmlinkage long sys_getresuid(uid_t *ruid, uid_t *euid, uid_t *suid)
+asmlinkage long sys_getresuid(uid_t __user *ruid, uid_t __user *euid, uid_t __user *suid)
 {
        int retval;
 
@@ -861,7 +868,7 @@ asmlinkage long sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid)
        return 0;
 }
 
-asmlinkage long sys_getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid)
+asmlinkage long sys_getresgid(gid_t __user *rgid, gid_t __user *egid, gid_t __user *sgid)
 {
        int retval;
 
@@ -1056,12 +1063,16 @@ asmlinkage long sys_getpgid(pid_t pid)
        }
 }
 
+#ifdef __ARCH_WANT_SYS_GETPGRP
+
 asmlinkage long sys_getpgrp(void)
 {
        /* SMP - assuming writes are word atomic this is fine */
        return process_group(current);
 }
 
+#endif
+
 asmlinkage long sys_getsid(pid_t pid)
 {
        if (!pid) {
@@ -1121,10 +1132,10 @@ struct group_info *groups_alloc(int gidsetsize)
        int nblocks;
        int i;
 
-       nblocks = (gidsetsize/NGROUPS_PER_BLOCK) +
-           (gidsetsize%NGROUPS_PER_BLOCK?1:0);
-       group_info = kmalloc(sizeof(*group_info) + nblocks*sizeof(gid_t *),
-           GFP_USER);
+       nblocks = (gidsetsize + NGROUPS_PER_BLOCK - 1) / NGROUPS_PER_BLOCK;
+       /* Make sure we always allocate at least one indirect block pointer */
+       nblocks = nblocks ? : 1;
+       group_info = kmalloc(sizeof(*group_info) + nblocks*sizeof(gid_t *), GFP_USER);
        if (!group_info)
                return NULL;
        group_info->ngroups = gidsetsize;
@@ -1270,8 +1281,12 @@ int set_current_groups(struct group_info *group_info)
 
        groups_sort(group_info);
        get_group_info(group_info);
+
+       task_lock(current);
        old_info = current->group_info;
        current->group_info = group_info;
+       task_unlock(current);
+
        put_group_info(old_info);
 
        return 0;
@@ -1291,6 +1306,7 @@ asmlinkage long sys_getgroups(int gidsetsize, gid_t __user *grouplist)
        if (gidsetsize < 0)
                return -EINVAL;
 
+       /* no need to grab task_lock here; it cannot change */
        get_group_info(current->group_info);
        i = current->group_info->ngroups;
        if (gidsetsize) {
@@ -1402,6 +1418,8 @@ asmlinkage long sys_sethostname(char __user *name, int len)
        return errno;
 }
 
+#ifdef __ARCH_WANT_SYS_GETHOSTNAME
+
 asmlinkage long sys_gethostname(char __user *name, int len)
 {
        int i, errno;
@@ -1419,6 +1437,8 @@ asmlinkage long sys_gethostname(char __user *name, int len)
        return errno;
 }
 
+#endif
+
 /*
  * Only setdomainname; getdomainname can be implemented by calling
  * uname()
@@ -1453,7 +1473,7 @@ asmlinkage long sys_getrlimit(unsigned int resource, struct rlimit __user *rlim)
                        ? -EFAULT : 0;
 }
 
-#if defined(COMPAT_RLIM_OLD_INFINITY) || !(defined(CONFIG_IA64) || defined(CONFIG_V850))
+#ifdef __ARCH_WANT_SYS_OLD_GETRLIMIT
 
 /*
  *     Back compatibility for getrlimit. Needed for some apps.