aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-02-22 20:08:33 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-22 20:08:33 -0500
commit6ef192f2259e78e1870c509fbd3040e6752b3b9c (patch)
tree61530c9059819327e82e72c70a8b1ee4c3559b47
parent37c85961c3f87f2141c84e53df31e59db072fd2e (diff)
parent0d4ec7849f5a197d46c062a49f47ed326dd0388c (diff)
Merge tag 'modules-for-v4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux
Pull modules updates from Jessica Yu: "Summary of modules changes for the 4.11 merge window: - A few small code cleanups - Add modules git tree url to MAINTAINERS" * tag 'modules-for-v4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux: MAINTAINERS: add tree for modules module: fix memory leak on early load_module() failures module: Optimize search_module_extables() modules: mark __inittest/__exittest as __maybe_unused livepatch/module: print notice of TAINT_LIVEPATCH module: Drop redundant declaration of struct module
-rw-r--r--MAINTAINERS1
-rw-r--r--include/linux/module.h6
-rw-r--r--kernel/module.c30
3 files changed, 20 insertions, 17 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 545633d6663d..7757bef14951 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8364,6 +8364,7 @@ F: drivers/media/dvb-frontends/mn88473*
8364MODULE SUPPORT 8364MODULE SUPPORT
8365M: Jessica Yu <jeyu@redhat.com> 8365M: Jessica Yu <jeyu@redhat.com>
8366M: Rusty Russell <rusty@rustcorp.com.au> 8366M: Rusty Russell <rusty@rustcorp.com.au>
8367T: git git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux.git modules-next
8367S: Maintained 8368S: Maintained
8368F: include/linux/module.h 8369F: include/linux/module.h
8369F: kernel/module.c 8370F: kernel/module.c
diff --git a/include/linux/module.h b/include/linux/module.h
index f4f542ed3d92..0297c5cd7cdf 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -126,13 +126,13 @@ extern void cleanup_module(void);
126 126
127/* Each module must use one module_init(). */ 127/* Each module must use one module_init(). */
128#define module_init(initfn) \ 128#define module_init(initfn) \
129 static inline initcall_t __inittest(void) \ 129 static inline initcall_t __maybe_unused __inittest(void) \
130 { return initfn; } \ 130 { return initfn; } \
131 int init_module(void) __attribute__((alias(#initfn))); 131 int init_module(void) __attribute__((alias(#initfn)));
132 132
133/* This is only required if you want to be unloadable. */ 133/* This is only required if you want to be unloadable. */
134#define module_exit(exitfn) \ 134#define module_exit(exitfn) \
135 static inline exitcall_t __exittest(void) \ 135 static inline exitcall_t __maybe_unused __exittest(void) \
136 { return exitfn; } \ 136 { return exitfn; } \
137 void cleanup_module(void) __attribute__((alias(#exitfn))); 137 void cleanup_module(void) __attribute__((alias(#exitfn)));
138 138
@@ -281,8 +281,6 @@ enum module_state {
281 MODULE_STATE_UNFORMED, /* Still setting it up. */ 281 MODULE_STATE_UNFORMED, /* Still setting it up. */
282}; 282};
283 283
284struct module;
285
286struct mod_tree_node { 284struct mod_tree_node {
287 struct module *mod; 285 struct module *mod;
288 struct latch_tree_node node; 286 struct latch_tree_node node;
diff --git a/kernel/module.c b/kernel/module.c
index a3889169a3ae..7eba6dea4f41 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2811,6 +2811,8 @@ static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
2811 if (get_modinfo(info, "livepatch")) { 2811 if (get_modinfo(info, "livepatch")) {
2812 mod->klp = true; 2812 mod->klp = true;
2813 add_taint_module(mod, TAINT_LIVEPATCH, LOCKDEP_STILL_OK); 2813 add_taint_module(mod, TAINT_LIVEPATCH, LOCKDEP_STILL_OK);
2814 pr_notice_once("%s: tainting kernel with TAINT_LIVEPATCH\n",
2815 mod->name);
2814 } 2816 }
2815 2817
2816 return 0; 2818 return 0;
@@ -3723,6 +3725,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
3723 mod_sysfs_teardown(mod); 3725 mod_sysfs_teardown(mod);
3724 coming_cleanup: 3726 coming_cleanup:
3725 mod->state = MODULE_STATE_GOING; 3727 mod->state = MODULE_STATE_GOING;
3728 destroy_params(mod->kp, mod->num_kp);
3726 blocking_notifier_call_chain(&module_notify_list, 3729 blocking_notifier_call_chain(&module_notify_list,
3727 MODULE_STATE_GOING, mod); 3730 MODULE_STATE_GOING, mod);
3728 klp_module_going(mod); 3731 klp_module_going(mod);
@@ -4169,22 +4172,23 @@ const struct exception_table_entry *search_module_extables(unsigned long addr)
4169 struct module *mod; 4172 struct module *mod;
4170 4173
4171 preempt_disable(); 4174 preempt_disable();
4172 list_for_each_entry_rcu(mod, &modules, list) { 4175 mod = __module_address(addr);
4173 if (mod->state == MODULE_STATE_UNFORMED) 4176 if (!mod)
4174 continue; 4177 goto out;
4175 if (mod->num_exentries == 0)
4176 continue;
4177 4178
4178 e = search_extable(mod->extable, 4179 if (!mod->num_exentries)
4179 mod->extable + mod->num_exentries - 1, 4180 goto out;
4180 addr); 4181
4181 if (e) 4182 e = search_extable(mod->extable,
4182 break; 4183 mod->extable + mod->num_exentries - 1,
4183 } 4184 addr);
4185out:
4184 preempt_enable(); 4186 preempt_enable();
4185 4187
4186 /* Now, if we found one, we are running inside it now, hence 4188 /*
4187 we cannot unload the module, hence no refcnt needed. */ 4189 * Now, if we found one, we are running inside it now, hence
4190 * we cannot unload the module, hence no refcnt needed.
4191 */
4188 return e; 4192 return e;
4189} 4193}
4190 4194