All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Re: Bug: Tracing recursive system calls
       [not found] <E10r9LE-0006v4-00@the-village.bc.nu>
@ 1999-06-09  1:10 ` Nate Eldredge
  0 siblings, 0 replies; only message in thread
From: Nate Eldredge @ 1999-06-09  1:10 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel

Alan Cox wrote:
> 
> > syscall_trace is in the fast path?!?  It only gets called when a process
> > is being traced, and nobody expects traced processes to run extremely
> > fast, do they?
> 
> Fast path for tracing syscalls. It would be nice to avoid a check every
> trace is what I mean.
> 
> > The problem isn't that the child thread is traced, it's that the `clone'
> > call itself from `kernel_thread' is traced.  So one would have to clear
> > the flag and then reset it in the parent.
> 
> Ok
> 
> > Besides, this doesn't suffice.  There are other places in the kernel
> > that make system calls (there's a `waitpid' in `request_module' for
> > instance).  We would need to find and change all of these and institute
> > a rule for the future, or else change the inline asm definitions in
> > asm/unistd.h.  Either seems a lot more complex.
> 
> Good point. My solution is simple elegant and wrong.

Then here is a patch.  It is against 2.2.10pre2, but I suspect it will
apply to other versions.  I make no claim for its elegance, etc, but it
works for me.  If anyone thinks of a better one, that would be nice.

The other arches should probably adopt similar changes.  I don't know
enough about anything but Intel to do it.

--- arch/i386/kernel/ptrace.c.bak       Mon Jun  7 13:37:01 1999
+++ arch/i386/kernel/ptrace.c   Tue Jun  8 17:51:36 1999
@@ -675,11 +675,14 @@
        return ret;
 }
 
-asmlinkage void syscall_trace(void)
+asmlinkage void syscall_trace(int unused)
 {
+       struct pt_regs *regs = (struct pt_regs *) &unused;
        if ((current->flags & (PF_PTRACED|PF_TRACESYS))
                        != (PF_PTRACED|PF_TRACESYS))
                return;
+       if (!user_mode(regs))
+               return; /* Don't trace the kernel's syscalls */
        current->exit_code = SIGTRAP;
        current->state = TASK_STOPPED;
        notify_parent(current, SIGCHLD);

-- 

Nate Eldredge
nate@cartsys.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-06-09  1:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <E10r9LE-0006v4-00@the-village.bc.nu>
1999-06-09  1:10 ` [PATCH] Re: Bug: Tracing recursive system calls Nate Eldredge

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.