From 5bd933fe4481688d595ae1dd0440006c8675a1a8 Mon Sep 17 00:00:00 2001 From: David Daney Date: Tue, 7 Mar 2017 17:31:08 -0800 Subject: [PATCH 1/3] module: set .init_array alignment to 8 The proper idiom for aligning linker sections in modules is different than for built-in sections. ". = ALIGN();" followed by a forced output address of 0 does nothing, as forcing the address changes the value of ".". Use output section alignment specifier instead. Fixes: 9ddf82521c86 ("kernel: add support for .init_array.* constructors") Reviewed-by: Andrey Ryabinin Signed-off-by: David Daney Signed-off-by: Jessica Yu --- scripts/module-common.lds | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/module-common.lds b/scripts/module-common.lds index 9b6e246a45d0..d61b9e8678e8 100644 --- a/scripts/module-common.lds +++ b/scripts/module-common.lds @@ -20,8 +20,7 @@ SECTIONS { __kcrctab_unused_gpl 0 : { *(SORT(___kcrctab_unused_gpl+*)) } __kcrctab_gpl_future 0 : { *(SORT(___kcrctab_gpl_future+*)) } - . = ALIGN(8); - .init_array 0 : { *(SORT(.init_array.*)) *(.init_array) } + .init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) } __jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) } } From 8ba4fcdf0f4068407e98cd9cc0f230c2dd8d56de Mon Sep 17 00:00:00 2001 From: Gao Feng Date: Wed, 19 Apr 2017 09:47:22 +0800 Subject: [PATCH 2/3] module: Unify the return value type of try_module_get The prototypes of try_module_get are different with different macro. When enable module and module unload, it returns bool, but others not. Make the return type for try_module_get consistent across all module config options. Signed-off-by: Gao Feng [jeyu: slightly amended changelog to make it clearer] Signed-off-by: Jessica Yu --- include/linux/module.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index 0297c5cd7cdf..6b79eb76a523 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -582,7 +582,7 @@ extern bool try_module_get(struct module *module); extern void module_put(struct module *module); #else /*!CONFIG_MODULE_UNLOAD*/ -static inline int try_module_get(struct module *module) +static inline bool try_module_get(struct module *module) { return !module || module_is_live(module); } @@ -674,9 +674,9 @@ static inline void __module_get(struct module *module) { } -static inline int try_module_get(struct module *module) +static inline bool try_module_get(struct module *module) { - return 1; + return true; } static inline void module_put(struct module *module) From 17586188276980ff10d1244a35aeb31ae199705e Mon Sep 17 00:00:00 2001 From: "Naveen N. Rao" Date: Sun, 23 Apr 2017 22:53:43 +0530 Subject: [PATCH 3/3] kallsyms: Use bounded strnchr() when parsing string When parsing for the format, we use strchr() to look for the separator, when we know that the module name can't be longer than MODULE_NAME_LEN. Enforce the same using strnchr(). Signed-off-by: Naveen N. Rao Reviewed-by: Masami Hiramatsu Signed-off-by: Jessica Yu --- kernel/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/module.c b/kernel/module.c index 7eba6dea4f41..d3bd56ed3541 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -4017,7 +4017,7 @@ unsigned long module_kallsyms_lookup_name(const char *name) /* Don't lock: we're in enough trouble already. */ preempt_disable(); - if ((colon = strchr(name, ':')) != NULL) { + if ((colon = strnchr(name, MODULE_NAME_LEN, ':')) != NULL) { if ((mod = find_module_all(name, colon - name, false)) != NULL) ret = mod_find_symname(mod, colon+1); } else {