All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Peter Zijlstra" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: locking/urgent] static_call: Fix static_call_text_reserved() vs __init
Date: Mon, 05 Jul 2021 07:53:33 -0000	[thread overview]
Message-ID: <162547161380.395.9445788023030500733.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20210628113045.106211657@infradead.org>

The following commit has been merged into the locking/urgent branch of tip:

Commit-ID:     8e62ef8c9922d7deaa2d92dc30a87ba6f81fdee3
Gitweb:        https://git.kernel.org/tip/8e62ef8c9922d7deaa2d92dc30a87ba6f81fdee3
Author:        Peter Zijlstra <peterz@infradead.org>
AuthorDate:    Mon, 28 Jun 2021 13:24:11 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Fri, 02 Jul 2021 15:58:27 +02:00

static_call: Fix static_call_text_reserved() vs __init

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>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Link: https://lore.kernel.org/r/20210628113045.106211657@infradead.org
---
 kernel/static_call.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/kernel/static_call.c b/kernel/static_call.c
index 723fcc9..43ba0b1 100644
--- a/kernel/static_call.c
+++ b/kernel/static_call.c
@@ -292,13 +292,15 @@ static int addr_conflict(struct static_call_site *site, void *start, void *end)
 
 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_reserved(void *start, void *end)
 
 	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_reserved(void *start, void *end)
 
 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-07-05  7:53 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 ` [PATCH 2/3] static_call: Fix static_call_text_reserved() " Peter Zijlstra
2021-06-28 14:26   ` Masami Hiramatsu
2021-07-05  7:53   ` tip-bot2 for Peter Zijlstra [this message]
2021-07-05  9:05   ` [tip: locking/urgent] " 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=162547161380.395.9445788023030500733.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.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 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.