[PATCH] x86/power/64: Avoid memory corruption in 64-bit swsusp_arch_resume()

From
Rafael J. Wysocki <hidden>
Date
2016-06-17 23:29:36
Also in
lkml
Reply to
tip-bot for Rafael J. Wysocki, 2016-06-14
From: Rafael J. Wysocki <redacted>

Commit 70595b479ce1 (x86/power/64: Fix crash whan the hibernation
code passes control to the image kernel) forgot to update the last
argument of memcpy() in swsusp_arch_resume() to reflect the other
changes made by it and that may lead to memory corruption if the
core_restore_code code happens to be located at the end of a page,
so fix it.

Fixes: 70595b479ce1 (x86/power/64: Fix crash whan the hibernation code passes control to the image kernel)
Signed-off-by: Rafael J. Wysocki <redacted>
---

Commit 70595b479ce1 is in tip and linux-next now.

---
 arch/x86/power/hibernate_64.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Index: linux-pm/arch/x86/power/hibernate_64.c
===================================================================
--- linux-pm.orig/arch/x86/power/hibernate_64.c
+++ linux-pm/arch/x86/power/hibernate_64.c
@@ -142,8 +142,7 @@ int swsusp_arch_resume(void)
 	relocated_restore_code = (void *)get_safe_page(GFP_ATOMIC);
 	if (!relocated_restore_code)
 		return -ENOMEM;
-	memcpy(relocated_restore_code, &core_restore_code,
-	       &restore_registers - &core_restore_code);
+	memcpy(relocated_restore_code, &core_restore_code, PAGE_SIZE);
 
 	restore_image();
 	return 0;
Thread (10 messages) 10 messages, 5 authors, last reply 2016-06-18
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help