From: Nadav Amit <namit@vmware.com>
To: Ingo Molnar <mingo@redhat.com>
Cc: <linux-kernel@vger.kernel.org>, <x86@kernel.org>,
"H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Peter Zijlstra <peterz@infradead.org>, <linux_dti@icloud.com>,
<linux-integrity@vger.kernel.org>,
<linux-security-module@vger.kernel.org>,
Nadav Amit <namit@vmware.com>, Andy Lutomirski <luto@kernel.org>,
Kees Cook <keescook@chromium.org>,
Dave Hansen <dave.hansen@intel.com>,
Masami Hiramatsu <mhiramat@kernel.org>
Subject: [PATCH v6 09/10] x86/jump-label: remove support for custom poker
Date: Tue, 20 Nov 2018 12:35:44 -0800 [thread overview]
Message-ID: <20181120203545.34928-10-namit@vmware.com> (raw)
In-Reply-To: <20181120203545.34928-1-namit@vmware.com>
There are only two types of poking: early and breakpoint based. The use
of a function pointer to perform poking complicates the code and is
probably inefficient due to the use of indirect branches.
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Nadav Amit <namit@vmware.com>
---
arch/x86/kernel/jump_label.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
index ed5fe274a7d8..994c13e2867d 100644
--- a/arch/x86/kernel/jump_label.c
+++ b/arch/x86/kernel/jump_label.c
@@ -39,7 +39,6 @@ static void bug_at(unsigned char *ip, int line)
static void __ref __jump_label_transform(struct jump_entry *entry,
enum jump_label_type type,
- void *(*poker)(void *, const void *, size_t),
int init)
{
union jump_code_union jmp;
@@ -52,14 +51,6 @@ static void __ref __jump_label_transform(struct jump_entry *entry,
jmp.offset = jump_entry_target(entry) -
(jump_entry_code(entry) + JUMP_LABEL_NOP_SIZE);
- /*
- * As long as we're UP and not yet marked RO, we can use
- * text_poke_early; SYSTEM_BOOTING guarantees both, as we switch to
- * SYSTEM_SCHEDULING before going either.
- */
- if (system_state == SYSTEM_BOOTING)
- poker = text_poke_early;
-
if (type == JUMP_LABEL_JMP) {
if (init) {
expect = default_nop; line = __LINE__;
@@ -82,16 +73,17 @@ static void __ref __jump_label_transform(struct jump_entry *entry,
bug_at((void *)jump_entry_code(entry), line);
/*
- * Make text_poke_bp() a default fallback poker.
+ * As long as we're UP and not yet marked RO, we can use
+ * text_poke_early; SYSTEM_BOOTING guarantees both, as we switch to
+ * SYSTEM_SCHEDULING before going either.
*
* At the time the change is being done, just ignore whether we
* are doing nop -> jump or jump -> nop transition, and assume
* always nop being the 'currently valid' instruction
- *
*/
- if (poker) {
- (*poker)((void *)jump_entry_code(entry), code,
- JUMP_LABEL_NOP_SIZE);
+ if (init || system_state == SYSTEM_BOOTING) {
+ text_poke_early((void *)jump_entry_code(entry), code,
+ JUMP_LABEL_NOP_SIZE);
return;
}
@@ -103,7 +95,7 @@ void arch_jump_label_transform(struct jump_entry *entry,
enum jump_label_type type)
{
mutex_lock(&text_mutex);
- __jump_label_transform(entry, type, NULL, 0);
+ __jump_label_transform(entry, type, 0);
mutex_unlock(&text_mutex);
}
@@ -133,7 +125,7 @@ __init_or_module void arch_jump_label_transform_static(struct jump_entry *entry,
jlstate = JL_STATE_NO_UPDATE;
}
if (jlstate == JL_STATE_UPDATE)
- __jump_label_transform(entry, type, text_poke_early, 1);
+ __jump_label_transform(entry, type, 1);
}
#endif
--
2.17.1
next prev parent reply other threads:[~2018-11-21 3:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-20 20:35 [PATCH v6 00/10] x86/alternative: text_poke() fixes Nadav Amit
2018-11-20 20:35 ` [PATCH v6 01/10] Fix "x86/alternatives: Lockdep-enforce text_mutex in text_poke*()" Nadav Amit
2018-11-20 20:35 ` [PATCH v6 02/10] x86/jump_label: Use text_poke_early() during early init Nadav Amit
2018-11-20 20:35 ` [PATCH v6 03/10] x86/mm: temporary mm struct Nadav Amit
2018-11-20 20:35 ` [PATCH v6 04/10] fork: provide a function for copying init_mm Nadav Amit
2018-11-20 20:35 ` [PATCH v6 05/10] x86/alternative: initializing temporary mm for patching Nadav Amit
2018-11-20 20:35 ` [PATCH v6 06/10] x86/alternative: use temporary mm for text poking Nadav Amit
2018-11-20 20:35 ` [PATCH v6 07/10] x86/kgdb: avoid redundant comparison of patched code Nadav Amit
2018-11-20 20:35 ` [PATCH v6 08/10] x86: avoid W^X being broken during modules loading Nadav Amit
2018-11-28 18:59 ` Nadav Amit
2018-11-30 2:32 ` Masami Hiramatsu
2018-11-20 20:35 ` Nadav Amit [this message]
2018-11-20 20:35 ` [PATCH v6 10/10] x86/alternative: remove the return value of text_poke_*() Nadav Amit
2018-11-26 10:32 ` [PATCH v6 00/10] x86/alternative: text_poke() fixes Peter Zijlstra
2018-11-26 17:46 ` Nadav Amit
2018-11-29 12:58 ` 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=20181120203545.34928-10-namit@vmware.com \
--to=namit@vmware.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=keescook@chromium.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux_dti@icloud.com \
--cc=luto@kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--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 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).