public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
* An autrace that follows forks
@ 2006-10-11 20:06 John D. Ramsdell
  2006-10-11 20:24 ` Steve Grubb
  2006-10-11 20:55 ` James Antill
  0 siblings, 2 replies; 10+ messages in thread
From: John D. Ramsdell @ 2006-10-11 20:06 UTC (permalink / raw)
  To: linux-audit

I plan to write a version of autrace that follows forks.  When run in
follow forks mode, it will ptrace the child.  Each time the child or
one of its descendents creates a new process, the program will use the
API provided by libaudit to add an audit rule for the freshly created
process.  If I hear of interest in this capability, I'll prepare a
patch against the most recent audit source release, and share.

Last summer, someone else in my company made a simple version of a
fork following tracer based on the audit library; however it does not
compile on my FC5 machine.  The reason is he was including the
kernel's headers for ptrace, which defines PTRACE_O_TRACEFORK and
other symbols not part of the standard ptrace header.  I don't like
the idea of requiring kernel headers to compile the extended version
autrace.

I studied the strace source code, in particular, strace.c and
process.c.  I ran the preprocessor on these files using the options
created on an FC5 machine, and my comments refer to the preprocessed
version of these source files.

When asked to follow forks, in addition to calling ptrace with the
PTRACE_TRACEME option in the child, strace uses procfs to find the
task ID of the process PID in the directory /proc/PID/task.
Apparently, it's the only file name in the directory that parses as a
positive number.  Using ptrace to attach to the task ID allows strace
to follow forks.  I'm guessing that I have to set a ptrace option so
that the parent is signaled on every descendent system call, and
inspect each system call to see if a new process was created.  I bet
following more of the strace logic will allow me to figure out these
details.  

I'm worried that blindly following strace's ways may lead me astray.
Is there someplace I can find high-level documentation on when to use
ptrace and when to use the procfs?  Should I also study the GDB
sources?

John

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-10-15 15:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-11 20:06 An autrace that follows forks John D. Ramsdell
2006-10-11 20:24 ` Steve Grubb
2006-10-12 10:51   ` John D. Ramsdell
2006-10-13 14:07     ` Steve Grubb
2006-10-15 15:32       ` John D. Ramsdell
2006-10-11 20:55 ` James Antill
2006-10-12 11:09   ` John D. Ramsdell
2006-10-12 11:40   ` John D. Ramsdell
2006-10-13 13:50   ` John D. Ramsdell
2006-10-15 15:38     ` John D. Ramsdell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox