diff options
author | Yang Yingliang <yangyingliang@huawei.com> | 2019-06-25 11:40:28 +0200 |
---|---|---|
committer | Jessica Yu <jeyu@kernel.org> | 2019-06-26 19:27:59 +0200 |
commit | 93651f80dcb616b8c9115cdafc8e57a781af22d0 (patch) | |
tree | c2612618459c3b0569a3b3668687dfaec5e7d7cf /kernel/module.c | |
parent | ARM: module: recognize unwind exit sections (diff) | |
download | linux-93651f80dcb616b8c9115cdafc8e57a781af22d0.tar.xz linux-93651f80dcb616b8c9115cdafc8e57a781af22d0.zip |
modules: fix compile error if don't have strict module rwx
If CONFIG_ARCH_HAS_STRICT_MODULE_RWX is not defined,
we need stub for module_enable_nx() and module_enable_x().
If CONFIG_ARCH_HAS_STRICT_MODULE_RWX is defined, but
CONFIG_STRICT_MODULE_RWX is disabled, we need stub for
module_enable_nx.
Move frob_text() outside of the CONFIG_STRICT_MODULE_RWX,
because it is needed anyway.
Fixes: 2eef1399a866 ("modules: fix BUG when load module with rodata=n")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/kernel/module.c b/kernel/module.c index 537c456ce3ee..b51838325d08 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1898,7 +1898,7 @@ static void mod_sysfs_teardown(struct module *mod) mod_sysfs_fini(mod); } -#ifdef CONFIG_STRICT_MODULE_RWX +#ifdef CONFIG_ARCH_HAS_STRICT_MODULE_RWX /* * LKM RO/NX protection: protect module's text/ro-data * from modification and any data from execution. @@ -1921,6 +1921,7 @@ static void frob_text(const struct module_layout *layout, layout->text_size >> PAGE_SHIFT); } +#ifdef CONFIG_STRICT_MODULE_RWX static void frob_rodata(const struct module_layout *layout, int (*set_memory)(unsigned long start, int num_pages)) { @@ -2033,15 +2034,19 @@ void set_all_modules_text_ro(void) } mutex_unlock(&module_mutex); } -#else +#else /* !CONFIG_STRICT_MODULE_RWX */ static void module_enable_nx(const struct module *mod) { } -#endif - +#endif /* CONFIG_STRICT_MODULE_RWX */ static void module_enable_x(const struct module *mod) { frob_text(&mod->core_layout, set_memory_x); frob_text(&mod->init_layout, set_memory_x); } +#else /* !CONFIG_ARCH_HAS_STRICT_MODULE_RWX */ +static void module_enable_nx(const struct module *mod) { } +static void module_enable_x(const struct module *mod) { } +#endif /* CONFIG_ARCH_HAS_STRICT_MODULE_RWX */ + #ifdef CONFIG_LIVEPATCH /* |