From: Nate Eldredge <nate@cartsys.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.rutgers.edu
Subject: [PATCH] Re: Bug: Tracing recursive system calls
Date: Tue, 08 Jun 1999 18:10:10 -0700 [thread overview]
Message-ID: <375DBEF2.5EECE92D@cartsys.com> (raw)
In-Reply-To: E10r9LE-0006v4-00@the-village.bc.nu
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/
parent reply other threads:[~1999-06-09 1:43 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <E10r9LE-0006v4-00@the-village.bc.nu>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=375DBEF2.5EECE92D@cartsys.com \
--to=nate@cartsys.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.rutgers.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).