Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 118907
b: refs/heads/master
c: a189d03
h: refs/heads/master
i:
  118905: c86c22b
  118903: 404bb1e
v: v3
  • Loading branch information
Masami Hiramatsu authored and Linus Torvalds committed Nov 13, 2008
1 parent 758e725 commit e65e004
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3b1b3f6e57064aa8f91c290fe51cda4c74642902
refs/heads/master: a189d0350f387786b1fb5a5d19e3a5ab0bc0cceb
21 changes: 16 additions & 5 deletions trunk/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,30 +613,37 @@ static int __kprobes __register_kprobe(struct kprobe *p,
return -EINVAL;
p->addr = addr;

if (!kernel_text_address((unsigned long) p->addr) ||
in_kprobes_functions((unsigned long) p->addr))
preempt_disable();
if (!__kernel_text_address((unsigned long) p->addr) ||
in_kprobes_functions((unsigned long) p->addr)) {
preempt_enable();
return -EINVAL;
}

p->mod_refcounted = 0;

/*
* Check if are we probing a module.
*/
probed_mod = module_text_address((unsigned long) p->addr);
probed_mod = __module_text_address((unsigned long) p->addr);
if (probed_mod) {
struct module *calling_mod = module_text_address(called_from);
struct module *calling_mod;
calling_mod = __module_text_address(called_from);
/*
* We must allow modules to probe themself and in this case
* avoid incrementing the module refcount, so as to allow
* unloading of self probing modules.
*/
if (calling_mod && calling_mod != probed_mod) {
if (unlikely(!try_module_get(probed_mod)))
if (unlikely(!try_module_get(probed_mod))) {
preempt_enable();
return -EINVAL;
}
p->mod_refcounted = 1;
} else
probed_mod = NULL;
}
preempt_enable();

p->nmissed = 0;
INIT_LIST_HEAD(&p->list);
Expand Down Expand Up @@ -718,6 +725,10 @@ static void __kprobes __unregister_kprobe_bottom(struct kprobe *p)
struct kprobe *old_p;

if (p->mod_refcounted) {
/*
* Since we've already incremented refcount,
* we don't need to disable preemption.
*/
mod = module_text_address((unsigned long)p->addr);
if (mod)
module_put(mod);
Expand Down

0 comments on commit e65e004

Please sign in to comment.