Skip to content

Commit 62822e2

Browse files
thgarnierafaeljw
authored andcommitted
PM / hibernate: Restore processor state before using per-CPU variables
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 <bp@suse.de> Reported-by: Jiri Kosina <jikos@kernel.org> Tested-by: Rafael J. Wysocki <rafael@kernel.org> Tested-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Thomas Garnier <thgarnie@google.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent e4630fd commit 62822e2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/power/hibernate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,12 @@ static int create_image(int platform_mode)
300300
save_processor_state();
301301
trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE, true);
302302
error = swsusp_arch_suspend();
303+
/* Restore control flow magically appears here */
304+
restore_processor_state();
303305
trace_suspend_resume(TPS("machine_suspend"), PM_EVENT_HIBERNATE, false);
304306
if (error)
305307
printk(KERN_ERR "PM: Error %d creating hibernation image\n",
306308
error);
307-
/* Restore control flow magically appears here */
308-
restore_processor_state();
309309
if (!in_suspend)
310310
events_check_enabled = false;
311311

0 commit comments

Comments
 (0)