]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] kprobes: Fix return probes on sys_execve
authorJim Keniston <jkenisto@us.ibm.com>
Wed, 23 Nov 2005 21:37:42 +0000 (13:37 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Thu, 24 Nov 2005 00:08:39 +0000 (16:08 -0800)
Fix a bug in kprobes that can cause an Oops or even a crash when a return
probe is installed on one of the following functions: sys_execve,
do_execve, load_*_binary, flush_old_exec, or flush_thread.  The fix is to
remove the call to kprobe_flush_task() in flush_thread().  This fix has
been tested on all architectures for which the return-probes feature has
been implemented (i386, x86_64, ppc64, ia64).  Please apply.

BACKGROUND

Up to now, we have called kprobe_flush_task() under two situations: when a
task exits, and when it execs.  Flushing kretprobe_instances on exit is
correct because (a) do_exit() doesn't return, and (b) one or more
return-probed functions may be active when a task calls do_exit().  Neither
is the case for sys_execve() and its callees.

Initially, the mistaken call to kprobe_flush_task() on exec was harmless
because we put the "real" return address of each active probed function
back in the stack, just to be safe, when we recycled its
kretprobe_instance.  When support for ppc64 and ia64 was added, this safety
measure couldn't be employed, and was eventually dropped even for i386 and
x86_64.  sys_execve() and its callees were informally blacklisted for
return probes until this fix was developed.

Acked-by: Prasanna S Panchamukhi <prasanna@in.ibm.com>
Signed-off-by: Jim Keniston <jkenisto@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/i386/kernel/process.c
arch/ia64/kernel/process.c
arch/powerpc/kernel/process.c
arch/x86_64/kernel/process.c

index 1cb261f225d580939785c0b9fc94859dcf92a8a0..df6c2bcde0672af1c7d5f084810e874d82a95e04 100644 (file)
@@ -393,13 +393,6 @@ void flush_thread(void)
 {
        struct task_struct *tsk = current;
 
-       /*
-        * Remove function-return probe instances associated with this task
-        * and put them back on the free list. Do not insert an exit probe for
-        * this function, it will be disabled by kprobe_flush_task if you do.
-        */
-       kprobe_flush_task(tsk);
-
        memset(tsk->thread.debugreg, 0, sizeof(unsigned long)*8);
        memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));        
        /*
index 4305d2ba76f6c61e6301c4df94823c819b30ee52..2e33665d9c18db01046f41e64002db351a08f180 100644 (file)
@@ -718,13 +718,6 @@ kernel_thread_helper (int (*fn)(void *), void *arg)
 void
 flush_thread (void)
 {
-       /*
-        * Remove function-return probe instances associated with this task
-        * and put them back on the free list. Do not insert an exit probe for
-        * this function, it will be disabled by kprobe_flush_task if you do.
-        */
-       kprobe_flush_task(current);
-
        /* drop floating-point and debug-register state if it exists: */
        current->thread.flags &= ~(IA64_THREAD_FPH_VALID | IA64_THREAD_DBG_VALID);
        ia64_drop_fpu(current);
index de69fb37c7313ce83d450bdbd6f5a15eb621bdd0..a5a7542a8ff348c27442ba3638a30740cc035e29 100644 (file)
@@ -457,7 +457,6 @@ void flush_thread(void)
        if (t->flags & _TIF_ABI_PENDING)
                t->flags ^= (_TIF_ABI_PENDING | _TIF_32BIT);
 #endif
-       kprobe_flush_task(current);
 
 #ifndef CONFIG_SMP
        if (last_task_used_math == current)
index 5afd63e8cef7ab9c9a71bb1f35df69a738ce90d5..7519fc520eb3f2d157d1da41cb4c3c1d5b40bc82 100644 (file)
@@ -351,13 +351,6 @@ void flush_thread(void)
        struct task_struct *tsk = current;
        struct thread_info *t = current_thread_info();
 
-       /*
-        * Remove function-return probe instances associated with this task
-        * and put them back on the free list. Do not insert an exit probe for
-        * this function, it will be disabled by kprobe_flush_task if you do.
-        */
-       kprobe_flush_task(tsk);
-
        if (t->flags & _TIF_ABI_PENDING)
                t->flags ^= (_TIF_ABI_PENDING | _TIF_IA32);