aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2009-01-06 17:41:46 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-06 18:59:20 -0500
commitbc2f70151fe7a117dbe8347edc5a877e749572a3 (patch)
tree930634f100acb38baa597f840b5b12bec750c66e
parent51e911e27690aecea01d4fe9cb22d38bdd0748ac (diff)
kprobes: bugfix: try_module_get even if calling_mod is NULL
When someone called register_*probe() from kernel-core code(not from module) and that probes a kernel module, users can remove the probed module because kprobe doesn't increment reference counter of the module. (on the other hand, if the kernel-module calls register_*probe, kprobe increments refcount of the probed module.) Currently, we have no register_*probe() calling from kernel-core(except smoke-test, but the smoke-test doesn't probe module), so there is no real bugs. But the logic is wrong(or not fair) and it can causes a problem when someone might want to probe module from kernel. After this patch is applied, even if someone put register_*probe() call in the kernel-core code, it increments the reference counter of the probed module, and it prevents user to remove the module until stopping probing it. Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Cc: Lai Jiangshan <laijs@cn.fujitsu.com> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--kernel/kprobes.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 9f8a3f25259a..3afd354c46f1 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -634,7 +634,7 @@ static int __kprobes __register_kprobe(struct kprobe *p,
634 * avoid incrementing the module refcount, so as to allow 634 * avoid incrementing the module refcount, so as to allow
635 * unloading of self probing modules. 635 * unloading of self probing modules.
636 */ 636 */
637 if (calling_mod && calling_mod != probed_mod) { 637 if (calling_mod != probed_mod) {
638 if (unlikely(!try_module_get(probed_mod))) { 638 if (unlikely(!try_module_get(probed_mod))) {
639 preempt_enable(); 639 preempt_enable();
640 return -EINVAL; 640 return -EINVAL;