public inbox for linux-um@lists.infradead.org
 help / color / mirror / Atom feed
From: Thomas Meyer <thomas@m3y3r.de>
To: user-mode-linux-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, richard@nod.at
Cc: Thomas Meyer <thomas@m3y3r.de>
Subject: [PATCH] um: Fix kcov crash before kernel is started.
Date: Sun,  8 Oct 2017 12:31:58 +0200	[thread overview]
Message-ID: <20171008103158.14107-1-thomas@m3y3r.de> (raw)

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



             reply	other threads:[~2017-10-08 10:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-08 10:31 Thomas Meyer [this message]
2017-10-08 10:44 ` [PATCH] um: Fix kcov crash before kernel is started Richard Weinberger
2017-10-08 11:18   ` Thomas Meyer
  -- strict thread matches above, loose matches on Subject: below --
2017-10-10  8:59 [thomas@m3y3r.de: Re: [PATCH] um: Fix kcov crash before kernel is started.] Dmitry Vyukov
2017-10-13 22:00 ` [PATCH] um: Fix kcov crash before kernel is started Thomas Meyer
2017-10-14  8:05   ` Richard Weinberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171008103158.14107-1-thomas@m3y3r.de \
    --to=thomas@m3y3r.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=richard@nod.at \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox