Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 257130
b: refs/heads/master
c: bc81d48
h: refs/heads/master
v: v3
  • Loading branch information
Masami Hiramatsu authored and Steven Rostedt committed Jul 15, 2011
1 parent cd8a063 commit 9bed409
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 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: 1538f888f1e793de04e0f90372352ac1b05833cf
refs/heads/master: bc81d48d13d8839fae6833c95794c403b2133f36
33 changes: 23 additions & 10 deletions trunk/kernel/kprobes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1255,19 +1255,29 @@ static int __kprobes in_kprobes_functions(unsigned long addr)
/*
* If we have a symbol_name argument, look it up and add the offset field
* to it. This way, we can specify a relative address to a symbol.
* This returns encoded errors if it fails to look up symbol or invalid
* combination of parameters.
*/
static kprobe_opcode_t __kprobes *kprobe_addr(struct kprobe *p)
{
kprobe_opcode_t *addr = p->addr;

if ((p->symbol_name && p->addr) ||
(!p->symbol_name && !p->addr))
goto invalid;

if (p->symbol_name) {
if (addr)
return NULL;
kprobe_lookup_name(p->symbol_name, addr);
if (!addr)
return ERR_PTR(-ENOENT);
}

if (!addr)
return NULL;
return (kprobe_opcode_t *)(((char *)addr) + p->offset);
addr = (kprobe_opcode_t *)(((char *)addr) + p->offset);
if (addr)
return addr;

invalid:
return ERR_PTR(-EINVAL);
}

/* Check passed kprobe is valid and return kprobe in kprobe_table. */
Expand Down Expand Up @@ -1311,8 +1321,8 @@ int __kprobes register_kprobe(struct kprobe *p)
kprobe_opcode_t *addr;

addr = kprobe_addr(p);
if (!addr)
return -EINVAL;
if (IS_ERR(addr))
return PTR_ERR(addr);
p->addr = addr;

ret = check_kprobe_rereg(p);
Expand All @@ -1335,6 +1345,8 @@ int __kprobes register_kprobe(struct kprobe *p)
*/
probed_mod = __module_text_address((unsigned long) p->addr);
if (probed_mod) {
/* Return -ENOENT if fail. */
ret = -ENOENT;
/*
* We must hold a refcount of the probed module while updating
* its code to prohibit unexpected unloading.
Expand All @@ -1351,6 +1363,7 @@ int __kprobes register_kprobe(struct kprobe *p)
module_put(probed_mod);
goto fail_with_jump_label;
}
/* ret will be updated by following code */
}
preempt_enable();
jump_label_unlock();
Expand Down Expand Up @@ -1399,7 +1412,7 @@ int __kprobes register_kprobe(struct kprobe *p)
fail_with_jump_label:
preempt_enable();
jump_label_unlock();
return -EINVAL;
return ret;
}
EXPORT_SYMBOL_GPL(register_kprobe);

Expand Down Expand Up @@ -1686,8 +1699,8 @@ int __kprobes register_kretprobe(struct kretprobe *rp)

if (kretprobe_blacklist_size) {
addr = kprobe_addr(&rp->kp);
if (!addr)
return -EINVAL;
if (IS_ERR(addr))
return PTR_ERR(addr);

for (i = 0; kretprobe_blacklist[i].name != NULL; i++) {
if (kretprobe_blacklist[i].addr == addr)
Expand Down

0 comments on commit 9bed409

Please sign in to comment.