diff options
Diffstat (limited to 'kernel/sys.c')
-rw-r--r-- | kernel/sys.c | 64 |
1 files changed, 58 insertions, 6 deletions
diff --git a/kernel/sys.c b/kernel/sys.c index f723522e6986..bce933ebb29f 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/suspend.h> | 28 | #include <linux/suspend.h> |
29 | #include <linux/tty.h> | 29 | #include <linux/tty.h> |
30 | #include <linux/signal.h> | 30 | #include <linux/signal.h> |
31 | #include <linux/cn_proc.h> | ||
31 | 32 | ||
32 | #include <linux/compat.h> | 33 | #include <linux/compat.h> |
33 | #include <linux/syscalls.h> | 34 | #include <linux/syscalls.h> |
@@ -361,17 +362,38 @@ out_unlock: | |||
361 | return retval; | 362 | return retval; |
362 | } | 363 | } |
363 | 364 | ||
365 | /** | ||
366 | * emergency_restart - reboot the system | ||
367 | * | ||
368 | * Without shutting down any hardware or taking any locks | ||
369 | * reboot the system. This is called when we know we are in | ||
370 | * trouble so this is our best effort to reboot. This is | ||
371 | * safe to call in interrupt context. | ||
372 | */ | ||
364 | void emergency_restart(void) | 373 | void emergency_restart(void) |
365 | { | 374 | { |
366 | machine_emergency_restart(); | 375 | machine_emergency_restart(); |
367 | } | 376 | } |
368 | EXPORT_SYMBOL_GPL(emergency_restart); | 377 | EXPORT_SYMBOL_GPL(emergency_restart); |
369 | 378 | ||
370 | void kernel_restart(char *cmd) | 379 | void kernel_restart_prepare(char *cmd) |
371 | { | 380 | { |
372 | notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd); | 381 | notifier_call_chain(&reboot_notifier_list, SYS_RESTART, cmd); |
373 | system_state = SYSTEM_RESTART; | 382 | system_state = SYSTEM_RESTART; |
374 | device_shutdown(); | 383 | device_shutdown(); |
384 | } | ||
385 | |||
386 | /** | ||
387 | * kernel_restart - reboot the system | ||
388 | * @cmd: pointer to buffer containing command to execute for restart | ||
389 | * or %NULL | ||
390 | * | ||
391 | * Shutdown everything and perform a clean reboot. | ||
392 | * This is not safe to call in interrupt context. | ||
393 | */ | ||
394 | void kernel_restart(char *cmd) | ||
395 | { | ||
396 | kernel_restart_prepare(cmd); | ||
375 | if (!cmd) { | 397 | if (!cmd) { |
376 | printk(KERN_EMERG "Restarting system.\n"); | 398 | printk(KERN_EMERG "Restarting system.\n"); |
377 | } else { | 399 | } else { |
@@ -382,6 +404,12 @@ void kernel_restart(char *cmd) | |||
382 | } | 404 | } |
383 | EXPORT_SYMBOL_GPL(kernel_restart); | 405 | EXPORT_SYMBOL_GPL(kernel_restart); |
384 | 406 | ||
407 | /** | ||
408 | * kernel_kexec - reboot the system | ||
409 | * | ||
410 | * Move into place and start executing a preloaded standalone | ||
411 | * executable. If nothing was preloaded return an error. | ||
412 | */ | ||
385 | void kernel_kexec(void) | 413 | void kernel_kexec(void) |
386 | { | 414 | { |
387 | #ifdef CONFIG_KEXEC | 415 | #ifdef CONFIG_KEXEC |
@@ -390,9 +418,7 @@ void kernel_kexec(void) | |||
390 | if (!image) { | 418 | if (!image) { |
391 | return; | 419 | return; |
392 | } | 420 | } |
393 | notifier_call_chain(&reboot_notifier_list, SYS_RESTART, NULL); | 421 | kernel_restart_prepare(NULL); |
394 | system_state = SYSTEM_RESTART; | ||
395 | device_shutdown(); | ||
396 | printk(KERN_EMERG "Starting new kernel\n"); | 422 | printk(KERN_EMERG "Starting new kernel\n"); |
397 | machine_shutdown(); | 423 | machine_shutdown(); |
398 | machine_kexec(image); | 424 | machine_kexec(image); |
@@ -400,21 +426,39 @@ void kernel_kexec(void) | |||
400 | } | 426 | } |
401 | EXPORT_SYMBOL_GPL(kernel_kexec); | 427 | EXPORT_SYMBOL_GPL(kernel_kexec); |
402 | 428 | ||
403 | void kernel_halt(void) | 429 | /** |
430 | * kernel_halt - halt the system | ||
431 | * | ||
432 | * Shutdown everything and perform a clean system halt. | ||
433 | */ | ||
434 | void kernel_halt_prepare(void) | ||
404 | { | 435 | { |
405 | notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); | 436 | notifier_call_chain(&reboot_notifier_list, SYS_HALT, NULL); |
406 | system_state = SYSTEM_HALT; | 437 | system_state = SYSTEM_HALT; |
407 | device_shutdown(); | 438 | device_shutdown(); |
439 | } | ||
440 | void kernel_halt(void) | ||
441 | { | ||
442 | kernel_halt_prepare(); | ||
408 | printk(KERN_EMERG "System halted.\n"); | 443 | printk(KERN_EMERG "System halted.\n"); |
409 | machine_halt(); | 444 | machine_halt(); |
410 | } | 445 | } |
411 | EXPORT_SYMBOL_GPL(kernel_halt); | 446 | EXPORT_SYMBOL_GPL(kernel_halt); |
412 | 447 | ||
413 | void kernel_power_off(void) | 448 | /** |
449 | * kernel_power_off - power_off the system | ||
450 | * | ||
451 | * Shutdown everything and perform a clean system power_off. | ||
452 | */ | ||
453 | void kernel_power_off_prepare(void) | ||
414 | { | 454 | { |
415 | notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); | 455 | notifier_call_chain(&reboot_notifier_list, SYS_POWER_OFF, NULL); |
416 | system_state = SYSTEM_POWER_OFF; | 456 | system_state = SYSTEM_POWER_OFF; |
417 | device_shutdown(); | 457 | device_shutdown(); |
458 | } | ||
459 | void kernel_power_off(void) | ||
460 | { | ||
461 | kernel_power_off_prepare(); | ||
418 | printk(KERN_EMERG "Power down.\n"); | 462 | printk(KERN_EMERG "Power down.\n"); |
419 | machine_power_off(); | 463 | machine_power_off(); |
420 | } | 464 | } |
@@ -583,6 +627,7 @@ asmlinkage long sys_setregid(gid_t rgid, gid_t egid) | |||
583 | current->egid = new_egid; | 627 | current->egid = new_egid; |
584 | current->gid = new_rgid; | 628 | current->gid = new_rgid; |
585 | key_fsgid_changed(current); | 629 | key_fsgid_changed(current); |
630 | proc_id_connector(current, PROC_EVENT_GID); | ||
586 | return 0; | 631 | return 0; |
587 | } | 632 | } |
588 | 633 | ||
@@ -622,6 +667,7 @@ asmlinkage long sys_setgid(gid_t gid) | |||
622 | return -EPERM; | 667 | return -EPERM; |
623 | 668 | ||
624 | key_fsgid_changed(current); | 669 | key_fsgid_changed(current); |
670 | proc_id_connector(current, PROC_EVENT_GID); | ||
625 | return 0; | 671 | return 0; |
626 | } | 672 | } |
627 | 673 | ||
@@ -711,6 +757,7 @@ asmlinkage long sys_setreuid(uid_t ruid, uid_t euid) | |||
711 | current->fsuid = current->euid; | 757 | current->fsuid = current->euid; |
712 | 758 | ||
713 | key_fsuid_changed(current); | 759 | key_fsuid_changed(current); |
760 | proc_id_connector(current, PROC_EVENT_UID); | ||
714 | 761 | ||
715 | return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_RE); | 762 | return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_RE); |
716 | } | 763 | } |
@@ -758,6 +805,7 @@ asmlinkage long sys_setuid(uid_t uid) | |||
758 | current->suid = new_suid; | 805 | current->suid = new_suid; |
759 | 806 | ||
760 | key_fsuid_changed(current); | 807 | key_fsuid_changed(current); |
808 | proc_id_connector(current, PROC_EVENT_UID); | ||
761 | 809 | ||
762 | return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_ID); | 810 | return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_ID); |
763 | } | 811 | } |
@@ -806,6 +854,7 @@ asmlinkage long sys_setresuid(uid_t ruid, uid_t euid, uid_t suid) | |||
806 | current->suid = suid; | 854 | current->suid = suid; |
807 | 855 | ||
808 | key_fsuid_changed(current); | 856 | key_fsuid_changed(current); |
857 | proc_id_connector(current, PROC_EVENT_UID); | ||
809 | 858 | ||
810 | return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_RES); | 859 | return security_task_post_setuid(old_ruid, old_euid, old_suid, LSM_SETID_RES); |
811 | } | 860 | } |
@@ -858,6 +907,7 @@ asmlinkage long sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid) | |||
858 | current->sgid = sgid; | 907 | current->sgid = sgid; |
859 | 908 | ||
860 | key_fsgid_changed(current); | 909 | key_fsgid_changed(current); |
910 | proc_id_connector(current, PROC_EVENT_GID); | ||
861 | return 0; | 911 | return 0; |
862 | } | 912 | } |
863 | 913 | ||
@@ -900,6 +950,7 @@ asmlinkage long sys_setfsuid(uid_t uid) | |||
900 | } | 950 | } |
901 | 951 | ||
902 | key_fsuid_changed(current); | 952 | key_fsuid_changed(current); |
953 | proc_id_connector(current, PROC_EVENT_UID); | ||
903 | 954 | ||
904 | security_task_post_setuid(old_fsuid, (uid_t)-1, (uid_t)-1, LSM_SETID_FS); | 955 | security_task_post_setuid(old_fsuid, (uid_t)-1, (uid_t)-1, LSM_SETID_FS); |
905 | 956 | ||
@@ -928,6 +979,7 @@ asmlinkage long sys_setfsgid(gid_t gid) | |||
928 | } | 979 | } |
929 | current->fsgid = gid; | 980 | current->fsgid = gid; |
930 | key_fsgid_changed(current); | 981 | key_fsgid_changed(current); |
982 | proc_id_connector(current, PROC_EVENT_GID); | ||
931 | } | 983 | } |
932 | return old_fsgid; | 984 | return old_fsgid; |
933 | } | 985 | } |