CAPABILITIES: remove undefined caps from all processes
[platform/adaptation/renesas_rcar/renesas_kernel.git] / kernel / kexec.c
index 9c97016..18ff0b9 100644 (file)
@@ -932,6 +932,7 @@ static int kimage_load_segment(struct kimage *image,
  */
 struct kimage *kexec_image;
 struct kimage *kexec_crash_image;
+int kexec_load_disabled;
 
 static DEFINE_MUTEX(kexec_mutex);
 
@@ -942,7 +943,7 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
        int result;
 
        /* We only trust the superuser with rebooting the system. */
-       if (!capable(CAP_SYS_BOOT))
+       if (!capable(CAP_SYS_BOOT) || kexec_load_disabled)
                return -EPERM;
 
        /*
@@ -1536,7 +1537,7 @@ void vmcoreinfo_append_str(const char *fmt, ...)
        size_t r;
 
        va_start(args, fmt);
-       r = vsnprintf(buf, sizeof(buf), fmt, args);
+       r = vscnprintf(buf, sizeof(buf), fmt, args);
        va_end(args);
 
        r = min(r, vmcoreinfo_max_size - vmcoreinfo_size);
@@ -1681,6 +1682,14 @@ int kernel_kexec(void)
                kexec_in_progress = true;
                kernel_restart_prepare(NULL);
                migrate_to_reboot_cpu();
+
+               /*
+                * migrate_to_reboot_cpu() disables CPU hotplug assuming that
+                * no further code needs to use CPU hotplug (which is true in
+                * the reboot case). However, the kexec path depends on using
+                * CPU hotplug again; so re-enable it here.
+                */
+               cpu_hotplug_enable();
                printk(KERN_EMERG "Starting new kernel\n");
                machine_shutdown();
        }