浏览代码

module: When modifying a module's text ignore modules which are going away too

By default, during the access permission modification of a module's core
and init pages, we only ignore modules that are malformed. Albeit for a
module which is going away, it does not make sense to change its text to
RO since the module should be RW, before deallocation.

This patch makes set_all_modules_text_ro() skip modules which are going
away too.

Signed-off-by: Aaron Tomlin <atomlin@redhat.com>
Acked-by: Rusty Russell <rusty@rustcorp.com.au>
Link: http://lkml.kernel.org/r/1477560966-781-1-git-send-email-atomlin@redhat.com
[jeyu@redhat.com: add comment as suggested by Steven Rostedt]
Signed-off-by: Jessica Yu <jeyu@redhat.com>
Aaron Tomlin 9 年之前
父节点
当前提交
905dd707fc
共有 1 个文件被更改,包括 7 次插入1 次删除
  1. 7 1
      kernel/module.c

+ 7 - 1
kernel/module.c

@@ -1958,7 +1958,13 @@ void set_all_modules_text_ro(void)
 
 
 	mutex_lock(&module_mutex);
 	mutex_lock(&module_mutex);
 	list_for_each_entry_rcu(mod, &modules, list) {
 	list_for_each_entry_rcu(mod, &modules, list) {
-		if (mod->state == MODULE_STATE_UNFORMED)
+		/*
+		 * Ignore going modules since it's possible that ro
+		 * protection has already been disabled, otherwise we'll
+		 * run into protection faults at module deallocation.
+		 */
+		if (mod->state == MODULE_STATE_UNFORMED ||
+			mod->state == MODULE_STATE_GOING)
 			continue;
 			continue;
 
 
 		frob_text(&mod->core_layout, set_memory_ro);
 		frob_text(&mod->core_layout, set_memory_ro);