Skip to content

Commit 6ef192f

Browse files
committed
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
2 parents 37c8596 + 0d4ec78 commit 6ef192f

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8364,6 +8364,7 @@ F: drivers/media/dvb-frontends/mn88473*
83648364
MODULE SUPPORT
83658365
M: Jessica Yu <jeyu@redhat.com>
83668366
M: Rusty Russell <rusty@rustcorp.com.au>
8367+
T: git git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux.git modules-next
83678368
S: Maintained
83688369
F: include/linux/module.h
83698370
F: kernel/module.c

include/linux/module.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,13 @@ extern void cleanup_module(void);
126126

127127
/* Each module must use one module_init(). */
128128
#define module_init(initfn) \
129-
static inline initcall_t __inittest(void) \
129+
static inline initcall_t __maybe_unused __inittest(void) \
130130
{ return initfn; } \
131131
int init_module(void) __attribute__((alias(#initfn)));
132132

133133
/* This is only required if you want to be unloadable. */
134134
#define module_exit(exitfn) \
135-
static inline exitcall_t __exittest(void) \
135+
static inline exitcall_t __maybe_unused __exittest(void) \
136136
{ return exitfn; } \
137137
void cleanup_module(void) __attribute__((alias(#exitfn)));
138138

@@ -281,8 +281,6 @@ enum module_state {
281281
MODULE_STATE_UNFORMED, /* Still setting it up. */
282282
};
283283

284-
struct module;
285-
286284
struct mod_tree_node {
287285
struct module *mod;
288286
struct latch_tree_node node;

kernel/module.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,6 +2811,8 @@ static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
28112811
if (get_modinfo(info, "livepatch")) {
28122812
mod->klp = true;
28132813
add_taint_module(mod, TAINT_LIVEPATCH, LOCKDEP_STILL_OK);
2814+
pr_notice_once("%s: tainting kernel with TAINT_LIVEPATCH\n",
2815+
mod->name);
28142816
}
28152817

28162818
return 0;
@@ -3723,6 +3725,7 @@ static int load_module(struct load_info *info, const char __user *uargs,
37233725
mod_sysfs_teardown(mod);
37243726
coming_cleanup:
37253727
mod->state = MODULE_STATE_GOING;
3728+
destroy_params(mod->kp, mod->num_kp);
37263729
blocking_notifier_call_chain(&module_notify_list,
37273730
MODULE_STATE_GOING, mod);
37283731
klp_module_going(mod);
@@ -4169,22 +4172,23 @@ const struct exception_table_entry *search_module_extables(unsigned long addr)
41694172
struct module *mod;
41704173

41714174
preempt_disable();
4172-
list_for_each_entry_rcu(mod, &modules, list) {
4173-
if (mod->state == MODULE_STATE_UNFORMED)
4174-
continue;
4175-
if (mod->num_exentries == 0)
4176-
continue;
4175+
mod = __module_address(addr);
4176+
if (!mod)
4177+
goto out;
41774178

4178-
e = search_extable(mod->extable,
4179-
mod->extable + mod->num_exentries - 1,
4180-
addr);
4181-
if (e)
4182-
break;
4183-
}
4179+
if (!mod->num_exentries)
4180+
goto out;
4181+
4182+
e = search_extable(mod->extable,
4183+
mod->extable + mod->num_exentries - 1,
4184+
addr);
4185+
out:
41844186
preempt_enable();
41854187

4186-
/* Now, if we found one, we are running inside it now, hence
4187-
we cannot unload the module, hence no refcnt needed. */
4188+
/*
4189+
* Now, if we found one, we are running inside it now, hence
4190+
* we cannot unload the module, hence no refcnt needed.
4191+
*/
41884192
return e;
41894193
}
41904194

0 commit comments

Comments
 (0)