Skip to content

Commit

Permalink
jump_label: Fix NULL dereference bug in __jump_label_mod_update()
Browse files Browse the repository at this point in the history
Commit 1948367 ("jump_label: Annotate entries that operate on
__init code earlier") refactored the code that manages runtime
patching of jump labels in modules that are tied to static keys
defined in other modules or in the core kernel.

In the latter case, we may iterate over the static_key_mod linked
list until we hit the entry for the core kernel, whose 'mod' field
will be NULL, and attempt to dereference it to get at its 'state'
member.

So let's add a non-NULL check: this forces the 'init' argument of
__jump_label_update() to false for static keys that are defined in
the core kernel, which is appropriate given that __init annotated
jump_label entries in the core kernel should no longer be active
at this point (i.e., when loading modules).

Fixes: 1948367 ("jump_label: Annotate entries that operate on ...")
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Ard Biesheuvel <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Cc: Jessica Yu <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
  • Loading branch information
Ard Biesheuvel authored and KAGA-KOKO committed Oct 2, 2018
1 parent 57d1587 commit 77ac1c0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kernel/jump_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ static void __jump_label_mod_update(struct static_key *key)
else
stop = m->jump_entries + m->num_jump_entries;
__jump_label_update(key, mod->entries, stop,
m->state == MODULE_STATE_COMING);
m && m->state == MODULE_STATE_COMING);
}
}

Expand Down

0 comments on commit 77ac1c0

Please sign in to comment.