mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] um: Fix kcov crash before kernel is started.
@ 2017-10-08 10:31 Thomas Meyer
  2017-10-08 10:44 ` Richard Weinberger
  0 siblings, 1 reply; 9+ messages in thread
From: Thomas Meyer @ 2017-10-08 10:31 UTC (permalink / raw)
  To: user-mode-linux-devel, linux-kernel, richard; +Cc: Thomas Meyer

UMLs current_thread_info() unconditionally assumes that the top of the stack
contains the thread_info structure. But on UML the __sanitizer_cov_trace_pc
function is called for *all* functions! This results in an early crash:

Prevent kcov from using invalid curent_thread_info() data by checking
the system_state.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
 kernel/kcov.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/kcov.c b/kernel/kcov.c
index 3f693a0f6f3e..d601c0e956f6 100644
--- a/kernel/kcov.c
+++ b/kernel/kcov.c
@@ -56,6 +56,12 @@ void notrace __sanitizer_cov_trace_pc(void)
 	struct task_struct *t;
 	enum kcov_mode mode;
 
+#ifdef CONFIG_UML
+	if(!(system_state == SYSTEM_SCHEDULING ||
+	     system_state == SYSTEM_RUNNING))
+		return;
+#endif
+
 	t = current;
 	/*
 	 * We are interested in code coverage as a function of a syscall inputs,
-- 
2.11.0

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

end of thread, other threads:[~2017-10-14  8:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20171009163710.o5z5xjnlvmo3mi52@olymp>
2017-10-09 18:10 ` [thomas@m3y3r.de: Re: [PATCH] um: Fix kcov crash before kernel is started.] Dmitry Vyukov
2017-10-09 19:16   ` Thomas Meyer
2017-10-10  8:59     ` Dmitry Vyukov
2017-10-10 10:14       ` Mark Rutland
2017-10-13 22:00       ` [PATCH] um: Fix kcov crash before kernel is started Thomas Meyer
2017-10-14  8:05         ` Richard Weinberger
2017-10-08 10:31 Thomas Meyer
2017-10-08 10:44 ` Richard Weinberger
2017-10-08 11:18   ` Thomas Meyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®