All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kexec: Update vmcoreinfo after crash happened
@ 2017-03-16 12:16 ` Xunlei Pang
  0 siblings, 0 replies; 20+ messages in thread
From: Xunlei Pang @ 2017-03-16 12:16 UTC (permalink / raw)
  To: linux-kernel, kexec
  Cc: akpm, Eric Biederman, Dave Young, Baoquan He, Xunlei Pang

Currently vmcoreinfo data is updated at boot time subsys_initcall(),
it has the risk of being modified by some wrong code during system
is running.

As a result, vmcore dumped will contain the wrong vmcoreinfo. Later on,
when using "crash" utility to parse this vmcore, we probably will get
"Segmentation fault".

Based on the fact that the value of each vmcoreinfo stays invariable
once kernel boots up, we safely move all the vmcoreinfo operations into
crash_save_vmcoreinfo() which is called after crash happened. In this
way, vmcoreinfo data correctness is always guaranteed.

Signed-off-by: Xunlei Pang <xlpang@redhat.com>
---
 kernel/kexec_core.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index bfe62d5..1bfdd96 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -1367,12 +1367,6 @@ static void update_vmcoreinfo_note(void)
 	final_note(buf);
 }
 
-void crash_save_vmcoreinfo(void)
-{
-	vmcoreinfo_append_str("CRASHTIME=%ld\n", get_seconds());
-	update_vmcoreinfo_note();
-}
-
 void vmcoreinfo_append_str(const char *fmt, ...)
 {
 	va_list args;
@@ -1402,7 +1396,7 @@ phys_addr_t __weak paddr_vmcoreinfo_note(void)
 	return __pa_symbol((unsigned long)(char *)&vmcoreinfo_note);
 }
 
-static int __init crash_save_vmcoreinfo_init(void)
+void crash_save_vmcoreinfo(void)
 {
 	VMCOREINFO_OSRELEASE(init_uts_ns.name.release);
 	VMCOREINFO_PAGESIZE(PAGE_SIZE);
@@ -1474,13 +1468,11 @@ static int __init crash_save_vmcoreinfo_init(void)
 #endif
 
 	arch_crash_save_vmcoreinfo();
-	update_vmcoreinfo_note();
+	vmcoreinfo_append_str("CRASHTIME=%ld\n", get_seconds());
 
-	return 0;
+	update_vmcoreinfo_note();
 }
 
-subsys_initcall(crash_save_vmcoreinfo_init);
-
 /*
  * Move into place and start executing a preloaded standalone
  * executable.  If nothing was preloaded return an error.
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2017-03-21  2:02 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-16 12:16 [PATCH] kexec: Update vmcoreinfo after crash happened Xunlei Pang
2017-03-16 12:16 ` Xunlei Pang
2017-03-16 12:27 ` Baoquan He
2017-03-16 12:27   ` Baoquan He
2017-03-16 12:36   ` Xunlei Pang
2017-03-16 12:36     ` Xunlei Pang
2017-03-16 13:18     ` Baoquan He
2017-03-16 13:18       ` Baoquan He
2017-03-16 13:40       ` Xunlei Pang
2017-03-16 13:40         ` Xunlei Pang
2017-03-18 18:23         ` Petr Tesarik
2017-03-18 18:23           ` Petr Tesarik
2017-03-20  2:17           ` Xunlei Pang
2017-03-20  2:17             ` Xunlei Pang
2017-03-20 13:04             ` Petr Tesarik
2017-03-20 13:04               ` Petr Tesarik
2017-03-20 19:15               ` Eric W. Biederman
2017-03-20 19:15                 ` Eric W. Biederman
2017-03-21  2:05               ` Xunlei Pang
2017-03-21  2:05                 ` Xunlei Pang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.