]> git.baikalelectronics.ru Git - kernel.git/commit
jump_label: Fix NULL dereference bug in __jump_label_mod_update()
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 1 Oct 2018 08:13:24 +0000 (10:13 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 2 Oct 2018 06:08:18 +0000 (08:08 +0200)
commit87cc36fda0256f7ff1a4b0b14d98e5a35cc5a1b3
tree6e3ad7ecc4756b0b8ccc6de075fb8bc855a76c6a
parentd6d0c4e7ac382cda9534eb8800bf461dbcce34ff
jump_label: Fix NULL dereference bug in __jump_label_mod_update()

Commit de1607f39381 ("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: de1607f39381 ("jump_label: Annotate entries that operate on ...")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Kees Cook <keescook@chromium.org>
Cc: Jessica Yu <jeyu@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20181001081324.11553-1-ard.biesheuvel@linaro.org
kernel/jump_label.c