]> Git Repo - linux.git/commitdiff
PM / hibernate: Restore processor state before using per-CPU variables
authorThomas Garnier <[email protected]>
Thu, 11 Aug 2016 21:49:29 +0000 (14:49 -0700)
committerRafael J. Wysocki <[email protected]>
Fri, 12 Aug 2016 20:50:42 +0000 (22:50 +0200)
Restore the processor state before calling any other functions to
ensure per-CPU variables can be used with KASLR memory randomization.

Tracing functions use per-CPU variables (GS based on x86) and one was
called just before restoring the processor state fully. It resulted
in a double fault when both the tracing & the exception handler
functions tried to use a per-CPU variable.

Fixes: bb3632c6101b (PM / sleep: trace events for suspend/resume)
Reported-and-tested-by: Borislav Petkov <[email protected]>
Reported-by: Jiri Kosina <[email protected]>
Tested-by: Rafael J. Wysocki <[email protected]>
Tested-by: Jiri Kosina <[email protected]>
Signed-off-by: Thomas Garnier <[email protected]>
Acked-by: Pavel Machek <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
kernel/power/hibernate.c

index 0ee1df0a0bd60c2f2832a2994b6c088fa7be2b6a..61761aa7cc193e62fdebc026f8ed5ff5cbd0d02d 100644 (file)
@@ -300,12 +300,12 @@ static int create_image(int platform_mode)
        save_processor_state();
        trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE, true);
        error = swsusp_arch_suspend();
+       /* Restore control flow magically appears here */
+       restore_processor_state();
        trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE, false);
        if (error)
                printk(KERN_ERR "PM: Error %d creating hibernation image\n",
                        error);
-       /* Restore control flow magically appears here */
-       restore_processor_state();
        if (!in_suspend)
                events_check_enabled = false;
 
This page took 0.055325 seconds and 4 git commands to generate.