Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

jump_label: Disable jump labels in __exit code

With the following commit:

333522447063 ("jump_label: Explicitly disable jump labels in __init code")

... we explicitly disabled jump labels in __init code, so they could be
detected and not warned about in the following commit:

dc1dd184c2f0 ("jump_label: Warn on failed jump_label patching attempt")

In-kernel __exit code has the same issue. It's never used, so it's
freed along with the rest of initmem. But jump label entries in __exit
code aren't explicitly disabled, so we get the following warning when
enabling pr_debug() in __exit code:

can't patch jump_label at dmi_sysfs_exit+0x0/0x2d
WARNING: CPU: 0 PID: 22572 at kernel/jump_label.c:376 __jump_label_update+0x9d/0xb0

Fix the warning by disabling all jump labels in initmem (which includes
both __init and __exit code).

Reported-and-tested-by: Li Wang <liwang@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Jason Baron <jbaron@akamai.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: dc1dd184c2f0 ("jump_label: Warn on failed jump_label patching attempt")
Link: http://lkml.kernel.org/r/7121e6e595374f06616c505b6e690e275c0054d1.1521483452.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Josh Poimboeuf and committed by
Ingo Molnar
578ae447 45dbac0e

+7 -6
+2 -2
include/linux/jump_label.h
··· 151 151 extern struct jump_entry __stop___jump_table[]; 152 152 153 153 extern void jump_label_init(void); 154 - extern void jump_label_invalidate_init(void); 154 + extern void jump_label_invalidate_initmem(void); 155 155 extern void jump_label_lock(void); 156 156 extern void jump_label_unlock(void); 157 157 extern void arch_jump_label_transform(struct jump_entry *entry, ··· 199 199 static_key_initialized = true; 200 200 } 201 201 202 - static inline void jump_label_invalidate_init(void) {} 202 + static inline void jump_label_invalidate_initmem(void) {} 203 203 204 204 static __always_inline bool static_key_false(struct static_key *key) 205 205 {
+1 -1
init/main.c
··· 1001 1001 /* need to finish all async __init code before freeing the memory */ 1002 1002 async_synchronize_full(); 1003 1003 ftrace_free_init_mem(); 1004 - jump_label_invalidate_init(); 1004 + jump_label_invalidate_initmem(); 1005 1005 free_initmem(); 1006 1006 mark_readonly(); 1007 1007 system_state = SYSTEM_RUNNING;
+4 -3
kernel/jump_label.c
··· 16 16 #include <linux/jump_label_ratelimit.h> 17 17 #include <linux/bug.h> 18 18 #include <linux/cpu.h> 19 + #include <asm/sections.h> 19 20 20 21 #ifdef HAVE_JUMP_LABEL 21 22 ··· 422 421 cpus_read_unlock(); 423 422 } 424 423 425 - /* Disable any jump label entries in __init code */ 426 - void __init jump_label_invalidate_init(void) 424 + /* Disable any jump label entries in __init/__exit code */ 425 + void __init jump_label_invalidate_initmem(void) 427 426 { 428 427 struct jump_entry *iter_start = __start___jump_table; 429 428 struct jump_entry *iter_stop = __stop___jump_table; 430 429 struct jump_entry *iter; 431 430 432 431 for (iter = iter_start; iter < iter_stop; iter++) { 433 - if (init_kernel_text(iter->code)) 432 + if (init_section_contains((void *)(unsigned long)iter->code, 1)) 434 433 iter->code = 0; 435 434 } 436 435 }