]> git.baikalelectronics.ru Git - kernel.git/commit
init: verify that function is initcall_t at compile-time
authorMarco Elver <elver@google.com>
Fri, 21 May 2021 07:26:10 +0000 (09:26 +0200)
committerKees Cook <keescook@chromium.org>
Mon, 24 May 2021 22:24:33 +0000 (15:24 -0700)
commita2ef7ed28224f6262628c5a5f9b821ec44bc0dc2
tree94db3431b470b79d30146ff744b4294c591876a5
parent87d9f8b77b5545016adf3cfc494e6ea6899acca7
init: verify that function is initcall_t at compile-time

In the spirit of making it hard to misuse an interface, add a
compile-time assertion in the CONFIG_HAVE_ARCH_PREL32_RELOCATIONS case
to verify the initcall function matches initcall_t, because the inline
asm bypasses any type-checking the compiler would otherwise do. This
will help developers catch incorrect API use in all configurations.

A recent example of this is:
https://lkml.kernel.org/r/20210514140015.2944744-1-arnd@kernel.org

Signed-off-by: Marco Elver <elver@google.com>
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20210521072610.2880286-1-elver@google.com
include/linux/init.h