I forgot about "make xcheck", it crashes the kernel. Fortunately the
kernel dumps the stack trace. Trust me, it wasn't easy to notice the
missing return ;) I am wondering why the compiler doesn't complain.

Roland, this all needs more fixes. Look at the fixed code,

        utrace = target->utrace;
        if (!utrace)
                return ERR;
        spin_lock(utrace->lock);

Now, if we race with another task doing utrace_task_alloc() and see
->utrace != NULL, why should we see the correctly initialized *utrace?

utrace_task_alloc() needs wmb(), and the code like above read_barrier_depends().


UPD: tested the kernel with this patch, now late-ptrace-may-attach-check
crashes the kernel silently (no output under kvm).

Signed-off-by: Oleg Nesterov <o...@redhat.com>
---

 kernel/utrace.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- UTRACE-PTRACE/kernel/utrace.c~UTRACE_ATTACH_FIX_UTRACE_CK   2009-11-16 
00:02:08.000000000 +0100
+++ UTRACE-PTRACE/kernel/utrace.c       2009-11-16 00:06:26.000000000 +0100
@@ -281,7 +281,7 @@ struct utrace_engine *utrace_attach_task
 
        if (!(flags & UTRACE_ATTACH_CREATE)) {
                if (unlikely(!utrace))
-                       ERR_PTR(-ENOENT);
+                       return ERR_PTR(-ENOENT);
                spin_lock(&utrace->lock);
                engine = matching_engine(utrace, flags, ops, data);
                if (engine)

Reply via email to