Skip to contentSkip to conversation

Return proper error code from register_kprobe()

PATCH Masami Hiramatsu 1 participant 1 message Feb 14, 2012 1 message not in the archive Stable branch

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 5 lines · Prashanth Nageshappa

register_kprobe() aborts if the address of the new request falls in a prohibited area (such as ftrace pouch, __kprobes annotated functions, non-kernel text addresses, jump label text). We however don't return the right error on this abort, resulting in incorrect adding/reporting of kprobes (Ex: 'perf probe do_fork+18' or 'perf probe mcount')

OK, I see.

Quoted 5 lines

This patch fixes it by returning -EINVAL upon failure.

However, I can't agree with this change :(, because this ignores possibilities of -ENOENT error code in other error paths.

What I'm expecting is, setup an error code where the error occurs, as below;

        jump_label_lock();
        preempt_disable();
        if (!kernel_text_address((unsigned long) p->addr) ||
            in_kprobes_functions((unsigned long) p->addr) ||
            ftrace_text_reserved(p->addr, p->addr) ||
-           jump_label_text_reserved(p->addr, p->addr))
+           jump_label_text_reserved(p->addr, p->addr)) {
+		ret = -EINVAL;
                goto fail_with_jump_label;

+ }

IMHO, we should change the label name too...

Thank you,

Signature · 4 lines
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]