Loading kernel/sys.c +7 −7 Original line number Original line Diff line number Diff line Loading @@ -8,7 +8,6 @@ #include <linux/mm.h> #include <linux/mm.h> #include <linux/utsname.h> #include <linux/utsname.h> #include <linux/mman.h> #include <linux/mman.h> #include <linux/smp_lock.h> #include <linux/notifier.h> #include <linux/notifier.h> #include <linux/reboot.h> #include <linux/reboot.h> #include <linux/prctl.h> #include <linux/prctl.h> Loading Loading @@ -349,6 +348,9 @@ void kernel_power_off(void) machine_power_off(); machine_power_off(); } } EXPORT_SYMBOL_GPL(kernel_power_off); EXPORT_SYMBOL_GPL(kernel_power_off); static DEFINE_MUTEX(reboot_mutex); /* /* * Reboot system call: for obvious reasons only root may call it, * Reboot system call: for obvious reasons only root may call it, * and even root needs to set up some magic numbers in the registers * and even root needs to set up some magic numbers in the registers Loading Loading @@ -381,7 +383,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off) if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off) cmd = LINUX_REBOOT_CMD_HALT; cmd = LINUX_REBOOT_CMD_HALT; lock_kernel(); mutex_lock(&reboot_mutex); switch (cmd) { switch (cmd) { case LINUX_REBOOT_CMD_RESTART: case LINUX_REBOOT_CMD_RESTART: kernel_restart(NULL); kernel_restart(NULL); Loading @@ -397,20 +399,18 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, case LINUX_REBOOT_CMD_HALT: case LINUX_REBOOT_CMD_HALT: kernel_halt(); kernel_halt(); unlock_kernel(); do_exit(0); do_exit(0); panic("cannot halt"); panic("cannot halt"); case LINUX_REBOOT_CMD_POWER_OFF: case LINUX_REBOOT_CMD_POWER_OFF: kernel_power_off(); kernel_power_off(); unlock_kernel(); do_exit(0); do_exit(0); break; break; case LINUX_REBOOT_CMD_RESTART2: case LINUX_REBOOT_CMD_RESTART2: if (strncpy_from_user(&buffer[0], arg, sizeof(buffer) - 1) < 0) { if (strncpy_from_user(&buffer[0], arg, sizeof(buffer) - 1) < 0) { unlock_kernel(); ret = -EFAULT; return -EFAULT; break; } } buffer[sizeof(buffer) - 1] = '\0'; buffer[sizeof(buffer) - 1] = '\0'; Loading @@ -433,7 +433,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, ret = -EINVAL; ret = -EINVAL; break; break; } } unlock_kernel(); mutex_unlock(&reboot_mutex); return ret; return ret; } } Loading Loading
kernel/sys.c +7 −7 Original line number Original line Diff line number Diff line Loading @@ -8,7 +8,6 @@ #include <linux/mm.h> #include <linux/mm.h> #include <linux/utsname.h> #include <linux/utsname.h> #include <linux/mman.h> #include <linux/mman.h> #include <linux/smp_lock.h> #include <linux/notifier.h> #include <linux/notifier.h> #include <linux/reboot.h> #include <linux/reboot.h> #include <linux/prctl.h> #include <linux/prctl.h> Loading Loading @@ -349,6 +348,9 @@ void kernel_power_off(void) machine_power_off(); machine_power_off(); } } EXPORT_SYMBOL_GPL(kernel_power_off); EXPORT_SYMBOL_GPL(kernel_power_off); static DEFINE_MUTEX(reboot_mutex); /* /* * Reboot system call: for obvious reasons only root may call it, * Reboot system call: for obvious reasons only root may call it, * and even root needs to set up some magic numbers in the registers * and even root needs to set up some magic numbers in the registers Loading Loading @@ -381,7 +383,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off) if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off) cmd = LINUX_REBOOT_CMD_HALT; cmd = LINUX_REBOOT_CMD_HALT; lock_kernel(); mutex_lock(&reboot_mutex); switch (cmd) { switch (cmd) { case LINUX_REBOOT_CMD_RESTART: case LINUX_REBOOT_CMD_RESTART: kernel_restart(NULL); kernel_restart(NULL); Loading @@ -397,20 +399,18 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, case LINUX_REBOOT_CMD_HALT: case LINUX_REBOOT_CMD_HALT: kernel_halt(); kernel_halt(); unlock_kernel(); do_exit(0); do_exit(0); panic("cannot halt"); panic("cannot halt"); case LINUX_REBOOT_CMD_POWER_OFF: case LINUX_REBOOT_CMD_POWER_OFF: kernel_power_off(); kernel_power_off(); unlock_kernel(); do_exit(0); do_exit(0); break; break; case LINUX_REBOOT_CMD_RESTART2: case LINUX_REBOOT_CMD_RESTART2: if (strncpy_from_user(&buffer[0], arg, sizeof(buffer) - 1) < 0) { if (strncpy_from_user(&buffer[0], arg, sizeof(buffer) - 1) < 0) { unlock_kernel(); ret = -EFAULT; return -EFAULT; break; } } buffer[sizeof(buffer) - 1] = '\0'; buffer[sizeof(buffer) - 1] = '\0'; Loading @@ -433,7 +433,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd, ret = -EINVAL; ret = -EINVAL; break; break; } } unlock_kernel(); mutex_unlock(&reboot_mutex); return ret; return ret; } } Loading