Skip to content

Commit

Permalink
PM / hibernate: Restore processor state before using per-CPU variables
Browse files Browse the repository at this point in the history
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: bb3632c (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]>
  • Loading branch information
thgarnie authored and rafaeljw committed Aug 12, 2016
1 parent e4630fd commit 62822e2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/power/hibernate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 62822e2

Please sign in to comment.