aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/s390/include/asm/cacheflush.h1
-rw-r--r--arch/s390/mm/pageattr.c5
-rw-r--r--kernel/module.c25
3 files changed, 19 insertions, 12 deletions
diff --git a/arch/s390/include/asm/cacheflush.h b/arch/s390/include/asm/cacheflush.h
index 43a5c78046db..3e20383d0921 100644
--- a/arch/s390/include/asm/cacheflush.h
+++ b/arch/s390/include/asm/cacheflush.h
@@ -11,5 +11,6 @@ void kernel_map_pages(struct page *page, int numpages, int enable);
11int set_memory_ro(unsigned long addr, int numpages); 11int set_memory_ro(unsigned long addr, int numpages);
12int set_memory_rw(unsigned long addr, int numpages); 12int set_memory_rw(unsigned long addr, int numpages);
13int set_memory_nx(unsigned long addr, int numpages); 13int set_memory_nx(unsigned long addr, int numpages);
14int set_memory_x(unsigned long addr, int numpages);
14 15
15#endif /* _S390_CACHEFLUSH_H */ 16#endif /* _S390_CACHEFLUSH_H */
diff --git a/arch/s390/mm/pageattr.c b/arch/s390/mm/pageattr.c
index 0607e4b14b27..f05edcc3beff 100644
--- a/arch/s390/mm/pageattr.c
+++ b/arch/s390/mm/pageattr.c
@@ -54,3 +54,8 @@ int set_memory_nx(unsigned long addr, int numpages)
54 return 0; 54 return 0;
55} 55}
56EXPORT_SYMBOL_GPL(set_memory_nx); 56EXPORT_SYMBOL_GPL(set_memory_nx);
57
58int set_memory_x(unsigned long addr, int numpages)
59{
60 return 0;
61}
diff --git a/kernel/module.c b/kernel/module.c
index 92112c91b7e9..b99dcebc980d 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1607,22 +1607,23 @@ static void set_section_ro_nx(void *base,
1607 } 1607 }
1608} 1608}
1609 1609
1610/* Setting memory back to RW+NX before releasing it */ 1610/* Setting memory back to W+X before releasing it */
1611void unset_section_ro_nx(struct module *mod, void *module_region) 1611void unset_section_ro_nx(struct module *mod, void *module_region)
1612{ 1612{
1613 unsigned long total_pages;
1614
1615 if (mod->module_core == module_region) { 1613 if (mod->module_core == module_region) {
1616 /* Set core as NX+RW */ 1614 set_page_attributes(mod->module_core + mod->core_text_size,
1617 total_pages = MOD_NUMBER_OF_PAGES(mod->module_core, mod->core_size); 1615 mod->module_core + mod->core_size,
1618 set_memory_nx((unsigned long)mod->module_core, total_pages); 1616 set_memory_x);
1619 set_memory_rw((unsigned long)mod->module_core, total_pages); 1617 set_page_attributes(mod->module_core,
1620 1618 mod->module_core + mod->core_ro_size,
1619 set_memory_rw);
1621 } else if (mod->module_init == module_region) { 1620 } else if (mod->module_init == module_region) {
1622 /* Set init as NX+RW */ 1621 set_page_attributes(mod->module_init + mod->init_text_size,
1623 total_pages = MOD_NUMBER_OF_PAGES(mod->module_init, mod->init_size); 1622 mod->module_init + mod->init_size,
1624 set_memory_nx((unsigned long)mod->module_init, total_pages); 1623 set_memory_x);
1625 set_memory_rw((unsigned long)mod->module_init, total_pages); 1624 set_page_attributes(mod->module_init,
1625 mod->module_init + mod->init_ro_size,
1626 set_memory_rw);
1626 } 1627 }
1627} 1628}
1628 1629