mirror of
https://github.com/S3NEO/android_kernel_samsung_msm8226.git
synced 2024-11-07 03:47:13 +00:00
kprobes: Return -ENOENT if probe point doesn't exist
Return -ENOENT if probe point doesn't exist, but still returns -EINVAL if both of kprobe->addr and kprobe->symbol_name are specified or both are not specified. Acked-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> Cc: "David S. Miller" <davem@davemloft.net> Link: http://lkml.kernel.org/r/20110627072650.6528.67329.stgit@fedora15 Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
parent
1538f888f1
commit
bc81d48d13
1 changed files with 23 additions and 10 deletions
|
@ -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
|
* 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.
|
* 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)
|
static kprobe_opcode_t __kprobes *kprobe_addr(struct kprobe *p)
|
||||||
{
|
{
|
||||||
kprobe_opcode_t *addr = p->addr;
|
kprobe_opcode_t *addr = p->addr;
|
||||||
|
|
||||||
|
if ((p->symbol_name && p->addr) ||
|
||||||
|
(!p->symbol_name && !p->addr))
|
||||||
|
goto invalid;
|
||||||
|
|
||||||
if (p->symbol_name) {
|
if (p->symbol_name) {
|
||||||
if (addr)
|
|
||||||
return NULL;
|
|
||||||
kprobe_lookup_name(p->symbol_name, addr);
|
kprobe_lookup_name(p->symbol_name, addr);
|
||||||
|
if (!addr)
|
||||||
|
return ERR_PTR(-ENOENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!addr)
|
addr = (kprobe_opcode_t *)(((char *)addr) + p->offset);
|
||||||
return NULL;
|
if (addr)
|
||||||
return (kprobe_opcode_t *)(((char *)addr) + p->offset);
|
return addr;
|
||||||
|
|
||||||
|
invalid:
|
||||||
|
return ERR_PTR(-EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check passed kprobe is valid and return kprobe in kprobe_table. */
|
/* Check passed kprobe is valid and return kprobe in kprobe_table. */
|
||||||
|
@ -1311,8 +1321,8 @@ int __kprobes register_kprobe(struct kprobe *p)
|
||||||
kprobe_opcode_t *addr;
|
kprobe_opcode_t *addr;
|
||||||
|
|
||||||
addr = kprobe_addr(p);
|
addr = kprobe_addr(p);
|
||||||
if (!addr)
|
if (IS_ERR(addr))
|
||||||
return -EINVAL;
|
return PTR_ERR(addr);
|
||||||
p->addr = addr;
|
p->addr = addr;
|
||||||
|
|
||||||
ret = check_kprobe_rereg(p);
|
ret = check_kprobe_rereg(p);
|
||||||
|
@ -1335,6 +1345,8 @@ int __kprobes register_kprobe(struct kprobe *p)
|
||||||
*/
|
*/
|
||||||
probed_mod = __module_text_address((unsigned long) p->addr);
|
probed_mod = __module_text_address((unsigned long) p->addr);
|
||||||
if (probed_mod) {
|
if (probed_mod) {
|
||||||
|
/* Return -ENOENT if fail. */
|
||||||
|
ret = -ENOENT;
|
||||||
/*
|
/*
|
||||||
* We must hold a refcount of the probed module while updating
|
* We must hold a refcount of the probed module while updating
|
||||||
* its code to prohibit unexpected unloading.
|
* its code to prohibit unexpected unloading.
|
||||||
|
@ -1351,6 +1363,7 @@ int __kprobes register_kprobe(struct kprobe *p)
|
||||||
module_put(probed_mod);
|
module_put(probed_mod);
|
||||||
goto fail_with_jump_label;
|
goto fail_with_jump_label;
|
||||||
}
|
}
|
||||||
|
/* ret will be updated by following code */
|
||||||
}
|
}
|
||||||
preempt_enable();
|
preempt_enable();
|
||||||
jump_label_unlock();
|
jump_label_unlock();
|
||||||
|
@ -1399,7 +1412,7 @@ out:
|
||||||
fail_with_jump_label:
|
fail_with_jump_label:
|
||||||
preempt_enable();
|
preempt_enable();
|
||||||
jump_label_unlock();
|
jump_label_unlock();
|
||||||
return -EINVAL;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(register_kprobe);
|
EXPORT_SYMBOL_GPL(register_kprobe);
|
||||||
|
|
||||||
|
@ -1686,8 +1699,8 @@ int __kprobes register_kretprobe(struct kretprobe *rp)
|
||||||
|
|
||||||
if (kretprobe_blacklist_size) {
|
if (kretprobe_blacklist_size) {
|
||||||
addr = kprobe_addr(&rp->kp);
|
addr = kprobe_addr(&rp->kp);
|
||||||
if (!addr)
|
if (IS_ERR(addr))
|
||||||
return -EINVAL;
|
return PTR_ERR(addr);
|
||||||
|
|
||||||
for (i = 0; kretprobe_blacklist[i].name != NULL; i++) {
|
for (i = 0; kretprobe_blacklist[i].name != NULL; i++) {
|
||||||
if (kretprobe_blacklist[i].addr == addr)
|
if (kretprobe_blacklist[i].addr == addr)
|
||||||
|
|
Loading…
Reference in a new issue