linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: jpoimboe@redhat.com, jbaron@akamai.com, rostedt@goodmis.org,
	ardb@kernel.org, naveen.n.rao@linux.ibm.com,
	anil.s.keshavamurthy@intel.com, mhiramat@kernel.org,
	davem@davemloft.net
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org
Subject: [PATCH 2/3] static_call: Fix static_call_text_reserved() vs __init
Date: Mon, 28 Jun 2021 13:24:11 +0200	[thread overview]
Message-ID: <20210628113045.106211657@infradead.org> (raw)
In-Reply-To: 20210628112409.233121975@infradead.org

It turns out that static_call_text_reserved() was reporting __init
text as being reserved past the time when the __init text was freed
and re-used.

This is mostly harmless and will at worst result in refusing a kprobe.

Fixes: 6333e8f73b83 ("static_call: Avoid kprobes on inline static_call()s")
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 kernel/static_call.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

--- a/kernel/static_call.c
+++ b/kernel/static_call.c
@@ -292,13 +292,15 @@ static int addr_conflict(struct static_c
 
 static int __static_call_text_reserved(struct static_call_site *iter_start,
 				       struct static_call_site *iter_stop,
-				       void *start, void *end)
+				       void *start, void *end, bool init)
 {
 	struct static_call_site *iter = iter_start;
 
 	while (iter < iter_stop) {
-		if (addr_conflict(iter, start, end))
-			return 1;
+		if (init || !static_call_is_init(iter)) {
+			if (addr_conflict(iter, start, end))
+				return 1;
+		}
 		iter++;
 	}
 
@@ -324,7 +326,7 @@ static int __static_call_mod_text_reserv
 
 	ret = __static_call_text_reserved(mod->static_call_sites,
 			mod->static_call_sites + mod->num_static_call_sites,
-			start, end);
+			start, end, mod->state == MODULE_STATE_COMING);
 
 	module_put(mod);
 
@@ -459,8 +461,9 @@ static inline int __static_call_mod_text
 
 int static_call_text_reserved(void *start, void *end)
 {
+	bool init = system_state < SYSTEM_RUNNING;
 	int ret = __static_call_text_reserved(__start_static_call_sites,
-			__stop_static_call_sites, start, end);
+			__stop_static_call_sites, start, end, init);
 
 	if (ret)
 		return ret;



  parent reply	other threads:[~2021-06-28 11:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28 11:24 [PATCH 0/3] jump_label/static_call/kprobes: *_text_reserved() fixes Peter Zijlstra
2021-06-28 11:24 ` [PATCH 1/3] jump_label: Fix jump_label_text_reserved() vs __init Peter Zijlstra
2021-06-28 13:43   ` Masami Hiramatsu
2021-07-05  7:53   ` [tip: locking/urgent] " tip-bot2 for Peter Zijlstra
2021-07-05  9:05   ` tip-bot2 for Peter Zijlstra
2021-06-28 11:24 ` Peter Zijlstra [this message]
2021-06-28 14:26   ` [PATCH 2/3] static_call: Fix static_call_text_reserved() " Masami Hiramatsu
2021-07-05  7:53   ` [tip: locking/urgent] " tip-bot2 for Peter Zijlstra
2021-07-05  9:05   ` tip-bot2 for Peter Zijlstra
2021-06-28 11:24 ` [PATCH 3/3] kprobe/static_call: Restore missing static_call_text_reserved() Peter Zijlstra
2021-06-28 11:34   ` Peter Zijlstra
2021-06-28 14:24     ` Masami Hiramatsu
2021-06-28 15:03       ` Peter Zijlstra
2021-06-28 14:25   ` Masami Hiramatsu
2021-07-05  7:53   ` [tip: locking/urgent] " tip-bot2 for Peter Zijlstra
2021-07-05  9:05   ` tip-bot2 for Peter Zijlstra

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=20210628113045.106211657@infradead.org \
    --to=peterz@infradead.org \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=ardb@kernel.org \
    --cc=davem@davemloft.net \
    --cc=jbaron@akamai.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=naveen.n.rao@linux.ibm.com \
    --cc=rostedt@goodmis.org \
    /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;
as well as URLs for NNTP newsgroup(s).