Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1298088

[PATCH 2/2] module: deal with the failure of complete_formation

Path csiph.com!feeder.erje.net!2.us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From "Qiu, PeiyangX" <peiyangx.qiu@intel.com>
Newsgroups linux.kernel
Subject [PATCH 2/2] module: deal with the failure of complete_formation
Date Fri, 25 Dec 2015 08:10:01 +0100
Message-ID <qJuFH-sh-3@gated-at.bofh.it> (permalink)
References <qJu2Z-8rQ-1@gated-at.bofh.it>
X-Original-To Steven Rostedt <rostedt@goodmis.org>, Ingo Molnar <mingo@redhat.com>, Rusty Russell <rusty@rustcorp.com.au>
X-Extloop1 1
X-Ironport-Av E=Sophos;i="5.20,477,1444719600"; d="scan'208";a="623513247"
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0
MIME-Version 1.0
Content-Type text/plain; charset=gbk
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 58
Organization linux.* mail to news gateway
X-Original-Cc linux-kernel@vger.kernel.org, yanmin_zhang@linux.intel.com
X-Original-Date Fri, 25 Dec 2015 15:03:13 +0800
X-Original-Message-ID <567CEA31.1070507@intel.com>
X-Original-References <567CE0A7.80605@intel.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1298088

Show key headers only | View raw


From: Qiu Peiyang <peiyangx.qiu@intel.com>

complete_formation might fail. kernel need clean up
ftrace records of the module.

The patch fixes it by tuning the operation sequence in
complete_formation. After complete_formation checks
verify_export_symbols, call ftrace_module_init to init
ftrace records.

Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
Signed-off-by: Zhang Yanmin <yanmin.zhang@intel.com>
---
 kernel/module.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 8f051a1..0a67c4e 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -3373,6 +3373,11 @@ static int complete_formation(struct module *mod, struct load_info *info)
 	/* This relies on module_mutex for list integrity. */
 	module_bug_finalize(info->hdr, info->sechdrs, mod);
 
+	mutex_unlock(&module_mutex);
+
+	/* Ftrace init must be called in the MODULE_STATE_UNFORMED state */
+	ftrace_module_init(mod);
+
 	/* Set RO and NX regions for core */
 	set_section_ro_nx(mod->module_core,
 				mod->core_text_size,
@@ -3388,7 +3393,6 @@ static int complete_formation(struct module *mod, struct load_info *info)
 	/* Mark state as coming so strong_try_module_get() ignores us,
 	 * but kallsyms etc. can see us. */
 	mod->state = MODULE_STATE_COMING;
-	mutex_unlock(&module_mutex);
 
 	blocking_notifier_call_chain(&module_notify_list,
 				     MODULE_STATE_COMING, mod);
@@ -3505,9 +3509,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
 
 	dynamic_debug_setup(info->debug, info->num_debug);
 
-	/* Ftrace init must be called in the MODULE_STATE_UNFORMED state */
-	ftrace_module_init(mod);
-
 	/* Finally it's fully formed, ready to start executing. */
 	err = complete_formation(mod, info);
 	if (err)
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] fix ftrace initialization issue when a module is loaded "Qiu, PeiyangX" <peiyangx.qiu@intel.com> - 2015-12-25 07:30 +0100
  [PATCH 1/2] ftrace: fix the race between ftrace and insmod "Qiu, PeiyangX" <peiyangx.qiu@intel.com> - 2015-12-25 07:50 +0100
  [PATCH 2/2] module: deal with the failure of complete_formation "Qiu, PeiyangX" <peiyangx.qiu@intel.com> - 2015-12-25 08:10 +0100
  [PATCH 1/2] ftrace: fix the race between ftrace and insmod "Qiu, PeiyangX" <peiyangx.qiu@intel.com> - 2015-12-25 08:10 +0100

csiph-web