aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sys.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sys.c')
-rw-r--r--kernel/sys.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/kernel/sys.c b/kernel/sys.c
index bc1dc61c31ed..26a6b73a6b85 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -8,7 +8,6 @@
8#include <linux/mm.h> 8#include <linux/mm.h>
9#include <linux/utsname.h> 9#include <linux/utsname.h>
10#include <linux/mman.h> 10#include <linux/mman.h>
11#include <linux/smp_lock.h>
12#include <linux/notifier.h> 11#include <linux/notifier.h>
13#include <linux/reboot.h> 12#include <linux/reboot.h>
14#include <linux/prctl.h> 13#include <linux/prctl.h>
@@ -191,10 +190,10 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
191 !(user = find_user(who))) 190 !(user = find_user(who)))
192 goto out_unlock; /* No processes for this user */ 191 goto out_unlock; /* No processes for this user */
193 192
194 do_each_thread(g, p) 193 do_each_thread(g, p) {
195 if (__task_cred(p)->uid == who) 194 if (__task_cred(p)->uid == who)
196 error = set_one_prio(p, niceval, error); 195 error = set_one_prio(p, niceval, error);
197 while_each_thread(g, p); 196 } while_each_thread(g, p);
198 if (who != cred->uid) 197 if (who != cred->uid)
199 free_uid(user); /* For find_user() */ 198 free_uid(user); /* For find_user() */
200 break; 199 break;
@@ -255,13 +254,13 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who)
255 !(user = find_user(who))) 254 !(user = find_user(who)))
256 goto out_unlock; /* No processes for this user */ 255 goto out_unlock; /* No processes for this user */
257 256
258 do_each_thread(g, p) 257 do_each_thread(g, p) {
259 if (__task_cred(p)->uid == who) { 258 if (__task_cred(p)->uid == who) {
260 niceval = 20 - task_nice(p); 259 niceval = 20 - task_nice(p);
261 if (niceval > retval) 260 if (niceval > retval)
262 retval = niceval; 261 retval = niceval;
263 } 262 }
264 while_each_thread(g, p); 263 } while_each_thread(g, p);
265 if (who != cred->uid) 264 if (who != cred->uid)
266 free_uid(user); /* for find_user() */ 265 free_uid(user); /* for find_user() */
267 break; 266 break;
@@ -351,6 +350,9 @@ void kernel_power_off(void)
351 machine_power_off(); 350 machine_power_off();
352} 351}
353EXPORT_SYMBOL_GPL(kernel_power_off); 352EXPORT_SYMBOL_GPL(kernel_power_off);
353
354static DEFINE_MUTEX(reboot_mutex);
355
354/* 356/*
355 * Reboot system call: for obvious reasons only root may call it, 357 * Reboot system call: for obvious reasons only root may call it,
356 * and even root needs to set up some magic numbers in the registers 358 * and even root needs to set up some magic numbers in the registers
@@ -383,7 +385,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
383 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off) 385 if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
384 cmd = LINUX_REBOOT_CMD_HALT; 386 cmd = LINUX_REBOOT_CMD_HALT;
385 387
386 lock_kernel(); 388 mutex_lock(&reboot_mutex);
387 switch (cmd) { 389 switch (cmd) {
388 case LINUX_REBOOT_CMD_RESTART: 390 case LINUX_REBOOT_CMD_RESTART:
389 kernel_restart(NULL); 391 kernel_restart(NULL);
@@ -399,20 +401,18 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
399 401
400 case LINUX_REBOOT_CMD_HALT: 402 case LINUX_REBOOT_CMD_HALT:
401 kernel_halt(); 403 kernel_halt();
402 unlock_kernel();
403 do_exit(0); 404 do_exit(0);
404 panic("cannot halt"); 405 panic("cannot halt");
405 406
406 case LINUX_REBOOT_CMD_POWER_OFF: 407 case LINUX_REBOOT_CMD_POWER_OFF:
407 kernel_power_off(); 408 kernel_power_off();
408 unlock_kernel();
409 do_exit(0); 409 do_exit(0);
410 break; 410 break;
411 411
412 case LINUX_REBOOT_CMD_RESTART2: 412 case LINUX_REBOOT_CMD_RESTART2:
413 if (strncpy_from_user(&buffer[0], arg, sizeof(buffer) - 1) < 0) { 413 if (strncpy_from_user(&buffer[0], arg, sizeof(buffer) - 1) < 0) {
414 unlock_kernel(); 414 ret = -EFAULT;
415 return -EFAULT; 415 break;
416 } 416 }
417 buffer[sizeof(buffer) - 1] = '\0'; 417 buffer[sizeof(buffer) - 1] = '\0';
418 418
@@ -435,7 +435,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
435 ret = -EINVAL; 435 ret = -EINVAL;
436 break; 436 break;
437 } 437 }
438 unlock_kernel(); 438 mutex_unlock(&reboot_mutex);
439 return ret; 439 return ret;
440} 440}
441 441