]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
x86/jump-label: Remove support for custom text poker
authorNadav Amit <namit@vmware.com>
Fri, 26 Apr 2019 00:11:32 +0000 (17:11 -0700)
committerIngo Molnar <mingo@kernel.org>
Tue, 30 Apr 2019 10:37:55 +0000 (12:37 +0200)
There are only two types of text poking: early and breakpoint based. The use
of a function pointer to perform text poking complicates the code and is
probably inefficient due to the use of indirect branches.

Signed-off-by: Nadav Amit <namit@vmware.com>
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: <akpm@linux-foundation.org>
Cc: <ard.biesheuvel@linaro.org>
Cc: <deneen.t.dock@intel.com>
Cc: <kernel-hardening@lists.openwall.com>
Cc: <kristen@linux.intel.com>
Cc: <linux_dti@icloud.com>
Cc: <will.deacon@arm.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20190426001143.4983-13-namit@vmware.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/kernel/jump_label.c

index e7d8c636b22889036a858abaa42b90fa26892430..e631c358f7f4a69c58df1aa83663ee9e5b9569ac 100644 (file)
@@ -37,7 +37,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;
@@ -50,14 +49,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 only a single processor is running and the code is still
-        * not marked as RO, text_poke_early() can be used; Checking that
-        * system_state is SYSTEM_BOOTING guarantees it.
-        */
-       if (system_state == SYSTEM_BOOTING)
-               poker = text_poke_early;
-
        if (type == JUMP_LABEL_JMP) {
                if (init) {
                        expect = default_nop; line = __LINE__;
@@ -80,16 +71,19 @@ 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 only a single processor is running and the code is still
+        * not marked as RO, text_poke_early() can be used; Checking that
+        * system_state is SYSTEM_BOOTING guarantees it. It will be set to
+        * SYSTEM_SCHEDULING before other cores are awaken and before the
+        * code is write-protected.
         *
         * 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;
        }
 
@@ -101,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);
 }
 
@@ -131,5 +125,5 @@ __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);
 }