diff options
author | Jan Glauber <jang@linux.vnet.ibm.com> | 2011-05-19 18:55:26 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2011-05-19 03:25:26 -0400 |
commit | 01526ed0830643bd53a8434c3068e4c077e1b09d (patch) | |
tree | 6fe0fecf55f6fe5bc94f95f9b0e01f67a53bf9d0 /kernel/module.c | |
parent | 448694a1d50432be63aafccb42d6f54d8cf3d02c (diff) |
module: split unset_section_ro_nx function.
Split the unprotect function into a function per section to make
the code more readable and add the missing static declaration.
Signed-off-by: Jan Glauber <jang@linux.vnet.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'kernel/module.c')
-rw-r--r-- | kernel/module.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/kernel/module.c b/kernel/module.c index b99dcebc980d..0e6f97f43c88 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -1607,24 +1607,24 @@ static void set_section_ro_nx(void *base, | |||
1607 | } | 1607 | } |
1608 | } | 1608 | } |
1609 | 1609 | ||
1610 | /* Setting memory back to W+X before releasing it */ | 1610 | static void unset_module_core_ro_nx(struct module *mod) |
1611 | void unset_section_ro_nx(struct module *mod, void *module_region) | 1611 | { |
1612 | { | 1612 | set_page_attributes(mod->module_core + mod->core_text_size, |
1613 | if (mod->module_core == module_region) { | 1613 | mod->module_core + mod->core_size, |
1614 | set_page_attributes(mod->module_core + mod->core_text_size, | 1614 | set_memory_x); |
1615 | mod->module_core + mod->core_size, | 1615 | set_page_attributes(mod->module_core, |
1616 | set_memory_x); | 1616 | mod->module_core + mod->core_ro_size, |
1617 | set_page_attributes(mod->module_core, | 1617 | set_memory_rw); |
1618 | mod->module_core + mod->core_ro_size, | 1618 | } |
1619 | set_memory_rw); | 1619 | |
1620 | } else if (mod->module_init == module_region) { | 1620 | static void unset_module_init_ro_nx(struct module *mod) |
1621 | set_page_attributes(mod->module_init + mod->init_text_size, | 1621 | { |
1622 | mod->module_init + mod->init_size, | 1622 | set_page_attributes(mod->module_init + mod->init_text_size, |
1623 | set_memory_x); | 1623 | mod->module_init + mod->init_size, |
1624 | set_page_attributes(mod->module_init, | 1624 | set_memory_x); |
1625 | mod->module_init + mod->init_ro_size, | 1625 | set_page_attributes(mod->module_init, |
1626 | set_memory_rw); | 1626 | mod->module_init + mod->init_ro_size, |
1627 | } | 1627 | set_memory_rw); |
1628 | } | 1628 | } |
1629 | 1629 | ||
1630 | /* Iterate through all modules and set each module's text as RW */ | 1630 | /* Iterate through all modules and set each module's text as RW */ |
@@ -1670,7 +1670,8 @@ void set_all_modules_text_ro(void) | |||
1670 | } | 1670 | } |
1671 | #else | 1671 | #else |
1672 | static inline void set_section_ro_nx(void *base, unsigned long text_size, unsigned long ro_size, unsigned long total_size) { } | 1672 | static inline void set_section_ro_nx(void *base, unsigned long text_size, unsigned long ro_size, unsigned long total_size) { } |
1673 | static inline void unset_section_ro_nx(struct module *mod, void *module_region) { } | 1673 | static void unset_module_core_ro_nx(struct module *mod) { } |
1674 | static void unset_module_init_ro_nx(struct module *mod) { } | ||
1674 | #endif | 1675 | #endif |
1675 | 1676 | ||
1676 | /* Free a module, remove from lists, etc. */ | 1677 | /* Free a module, remove from lists, etc. */ |
@@ -1697,7 +1698,7 @@ static void free_module(struct module *mod) | |||
1697 | destroy_params(mod->kp, mod->num_kp); | 1698 | destroy_params(mod->kp, mod->num_kp); |
1698 | 1699 | ||
1699 | /* This may be NULL, but that's OK */ | 1700 | /* This may be NULL, but that's OK */ |
1700 | unset_section_ro_nx(mod, mod->module_init); | 1701 | unset_module_init_ro_nx(mod); |
1701 | module_free(mod, mod->module_init); | 1702 | module_free(mod, mod->module_init); |
1702 | kfree(mod->args); | 1703 | kfree(mod->args); |
1703 | percpu_modfree(mod); | 1704 | percpu_modfree(mod); |
@@ -1706,7 +1707,7 @@ static void free_module(struct module *mod) | |||
1706 | lockdep_free_key_range(mod->module_core, mod->core_size); | 1707 | lockdep_free_key_range(mod->module_core, mod->core_size); |
1707 | 1708 | ||
1708 | /* Finally, free the core (containing the module structure) */ | 1709 | /* Finally, free the core (containing the module structure) */ |
1709 | unset_section_ro_nx(mod, mod->module_core); | 1710 | unset_module_core_ro_nx(mod); |
1710 | module_free(mod, mod->module_core); | 1711 | module_free(mod, mod->module_core); |
1711 | 1712 | ||
1712 | #ifdef CONFIG_MPU | 1713 | #ifdef CONFIG_MPU |
@@ -2932,7 +2933,7 @@ SYSCALL_DEFINE3(init_module, void __user *, umod, | |||
2932 | mod->symtab = mod->core_symtab; | 2933 | mod->symtab = mod->core_symtab; |
2933 | mod->strtab = mod->core_strtab; | 2934 | mod->strtab = mod->core_strtab; |
2934 | #endif | 2935 | #endif |
2935 | unset_section_ro_nx(mod, mod->module_init); | 2936 | unset_module_init_ro_nx(mod); |
2936 | module_free(mod, mod->module_init); | 2937 | module_free(mod, mod->module_init); |
2937 | mod->module_init = NULL; | 2938 | mod->module_init = NULL; |
2938 | mod->init_size = 0; | 2939 | mod->init_size = 0; |