From: Cong Wang <xiyou.wangcong@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Dennis1.Chen@amd.com, Cong Wang <xiyou.wangcong@gmail.com>,
Eric Dumazet <eric.dumazet@gmail.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Rusty Russell <rusty@rustcorp.com.au>
Subject: [PATCH 2/7] module: take rcu_read_lock_sched for find_symbol
Date: Thu, 15 Mar 2012 22:48:56 +0800 [thread overview]
Message-ID: <1331822941-19938-2-git-send-email-xiyou.wangcong@gmail.com> (raw)
In-Reply-To: <1331822941-19938-1-git-send-email-xiyou.wangcong@gmail.com>
find_symbol() iterates module list with list_for_each_entry_rcu()
should its caller should hold rcu_read_lock_sched().
This patch changes the module_mutex to rcu_read_lock_sched in
resolve_symbol() and adds rcu_read_lock_sched in verify_export_symbols().
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
kernel/module.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/kernel/module.c b/kernel/module.c
index 6f6a3fd..b31b23f 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1174,7 +1174,7 @@ static const struct kernel_symbol *resolve_symbol(struct module *mod,
const unsigned long *crc;
int err;
- mutex_lock(&module_mutex);
+ rcu_read_lock_sched();
sym = find_symbol(name, &owner, &crc,
!(mod->taints & (1 << TAINT_PROPRIETARY_MODULE)), true);
if (!sym)
@@ -1196,7 +1196,7 @@ getname:
/* We must make copy under the lock if we failed to get ref. */
strncpy(ownername, module_name(owner), MODULE_NAME_LEN);
unlock:
- mutex_unlock(&module_mutex);
+ rcu_read_unlock_sched();
return sym;
}
@@ -1844,6 +1844,7 @@ static int verify_export_symbols(struct module *mod)
#endif
};
+ rcu_read_lock_sched();
for (i = 0; i < ARRAY_SIZE(arr); i++) {
for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
if (find_symbol(s->name, &owner, NULL, true, false)) {
@@ -1851,10 +1852,12 @@ static int verify_export_symbols(struct module *mod)
"%s: exports duplicate symbol %s"
" (owned by %s)\n",
mod->name, s->name, module_name(owner));
+ rcu_read_unlock_sched();
return -ENOEXEC;
}
}
}
+ rcu_read_unlock_sched();
return 0;
}
--
1.7.7.6
next prev parent reply other threads:[~2012-03-15 14:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-15 14:48 [V3 PATCH 1/7] module: replace preempt_disable with rcu_read_lock_sched Cong Wang
2012-03-15 14:48 ` Cong Wang [this message]
2012-03-15 14:48 ` [PATCH 3/7] module: take rcu_read_lock_sched for find_module Cong Wang
2012-03-15 16:29 ` Eric Dumazet
2012-03-15 14:48 ` [PATCH 4/7] module: take rcu_read_lock_sched in module_kallsyms_on_each_symbol() Cong Wang
2012-03-15 14:48 ` [PATCH 5/7] module: take rcu_read_lock_sched() for /proc read Cong Wang
2012-03-15 16:18 ` Eric Dumazet
2012-03-15 14:49 ` [PATCH 6/7] module: add two missing synchronize_sched() Cong Wang
2012-03-15 16:26 ` Eric Dumazet
2012-03-15 14:49 ` [PATCH 7/7] module: avoid exporting module_mutex Cong Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1331822941-19938-2-git-send-email-xiyou.wangcong@gmail.com \
--to=xiyou.wangcong@gmail.com \
--cc=Dennis1.Chen@amd.com \
--cc=akpm@linux-foundation.org \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=rusty@rustcorp.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).