Skip to content

Commit dc1dd18

Browse files
jpoimboeIngo Molnar
authored andcommitted
jump_label: Warn on failed jump_label patching attempt
Currently when the jump label code encounters an address which isn't recognized by kernel_text_address(), it just silently fails. This can be dangerous because jump labels are used in a variety of places, and are generally expected to work. Convert the silent failure to a warning. This won't warn about attempted writes to tracepoints in __init code after initmem has been freed, as those are already guarded by the entry->code check. Signed-off-by: Josh Poimboeuf <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Jason Baron <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/de3a271c93807adb7ed48f4e946b4f9156617680.1519051220.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar <[email protected]>
1 parent 3335224 commit dc1dd18

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

kernel/jump_label.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,15 @@ static void __jump_label_update(struct static_key *key,
367367
{
368368
for (; (entry < stop) && (jump_entry_key(entry) == key); entry++) {
369369
/*
370-
* entry->code set to 0 invalidates module init text sections
371-
* kernel_text_address() verifies we are not in core kernel
372-
* init code, see jump_label_invalidate_module_init().
370+
* An entry->code of 0 indicates an entry which has been
371+
* disabled because it was in an init text area.
373372
*/
374-
if (entry->code && kernel_text_address(entry->code))
375-
arch_jump_label_transform(entry, jump_label_type(entry));
373+
if (entry->code) {
374+
if (kernel_text_address(entry->code))
375+
arch_jump_label_transform(entry, jump_label_type(entry));
376+
else
377+
WARN_ONCE(1, "can't patch jump_label at %pS", (void *)entry->code);
378+
}
376379
}
377380
}
378381

0 commit comments

Comments
 (0)