Re: linux-next: add utrace tree

2010-01-24 Thread Kyle Moffett
On Sat, Jan 23, 2010 at 14:48,  ty...@mit.edu wrote:
 The fundamental issue which Ingo is trying to say (and which you
 apparently don't seem to be understanding) is that utrace doesn't
 export a syscall (which is an ABI that we are willing to promise will
 be stable), but rather a set of kernel API's (which we never promise
 to be stable),

The point that's being missed is that there is a chicken-and-egg
problem here.  The chicken is a replacement or extension to the
debugger interface that would make it possible for me to do things
like GDB a process while it's being strace'd or vice versa.  The egg
is the utrace bits, an unstable but somewhat arch-generic ABI that
abstracts out ptrace() to make it possible to stack both in-kernel and
userspace debuggers/tracers/etc and have multiple simultaneous users.

 and the fact that there will be out-of-tree programs
 that are going to be trying to depend on that interface (much like
 Systemtap does today when it creates kernel modules) is something that
 is considered on par with Nvidia trying to ship proprietary video
 drivers.

Ugh... perhaps we should derive a variation of Godwin's law for this:

As an LKML discussion grows longer, the probability of an unfavorable
comparison involving nVidia or Microsoft approaches 1.


 If you want to try to slide utrace in, such that we're able to ignore
 the fact that there will be this external house that will be built on
 quicksand, pointing at how nice the external house will be isn't going
 to be helpful.  Nor is pointing at the ability that other people will
 be able to build other really nice houses on the aforementioned
 quicksand (i.e., out-of-tree kernel modules that depend on kernel
 API's).

Personally I don't give a flying  about SystemTap; I'm interested
in things like the ability to stack gdb with strace, the RFC gdb-stub
posted a week ago, etc.  None of those abilities would be out-of-tree
modules at all, and therefore the quicksand analogy is specious.


 A simple code cleanup argument is not carrying the day (Look!  We
 can cleanup the ptree code!).  It's going to have to be a **really**
 cool in-tree kernel funtionality that provides a killer feature (in
 Linus's words), enough so that people are willing to overlook the fact
 that there's this monster external out-of-tree project that wants to
 be depend on API's that may not be stable, and which, even if the
 developers don't grump at us, users will grump at us when we change
 API's that we had never guaranteed will be stable, and then Systemtap
 breaks.

I would be willing to guess that something like 95% of the people
using SystemTap or other tools are doing so on Red Hat Enterprise
Linux or other enterprise supported platforms, and so when something
breaks they go whinge at Red Hat, etc.  If I recall correctly Red Hat
and many of the other vendors already heavily fiddle with kernel
patches they apply to provide some amount of binary module
compatibility.


 This is probably why Ingo invited you to think about ways of doing
 some kind of safe in-kernel bytecode approach.  That has the advantage
 of doing away with external kernel modules, with all of their many
 downsides: its dependency on unstable kernel API's, the fact that many
 financial customers have security policies that prohibit C compilers
 on production machines, the inherent security risk of allowing
 external random kernel modules to be delivered and loaded into a
 system, etc.

There are substantial non-SystemTap uses for utrace that would *not*
be satisfied by an in-kernel bytecode approach, starting with
stacking debuggers and tracers.  Furthermore, let's say they did go
off and build the in-kernel bytecode interpreter.  I can pretty much
guarantee that people would say the hooks into the rest of the kernel
are too invasive and they should be abstracted out into an API.  *This
is that API!*

Cheers,
Kyle Moffett



Re: linux-next: add utrace tree

2010-01-22 Thread Kyle Moffett
On Fri, Jan 22, 2010 at 19:22, Linus Torvalds
torva...@linux-foundation.org wrote:
 There are cases where we really _want_ to have common code. We want to
 have a common VFS interface because we want to show _one_ interface to
 user space across a gazillion different filesystems. We want to have a
 common driver layer (as far as possible) because - again - we expose a
 metric shitload of drivers, and we want to have one unified interface to
 them.

So... Everybody agrees that ptrace() is horrible and a royal pain to
use, let alone use correctly and without bugs.  Everybody also agrees
that ptrace() needs to stay around for a long time to avoid breaking
all the existing users.

Now how do we get from here to a moderately portable API for
interrogating, controlling, and intercepting process state?
Essentially it would need to support all of the things that a powerful
debugger would want to do, including modifying registers and memory,
substituting syscall return values, etc.  I believe that utrace is
the kernel side of that API.

The killer app for this will be the ability to delete thousands of
lines of code from GDB, strace, and all the various other tools that
have to painfully work around the major interface gotchas of ptrace(),
while at the same time making their handling of complex processes much
more robust.

The *second* killer app for this is to make it much easier for people
to write new userspace debugging tools.  I love the various
crash-catching tools that different distributions or applications
provide, but they all basically have to trap the SIGSEGV and hope
they're still sensible enough to fork() and exec() a gdb process.

Furthermore, I would love to be able to write debugging tools for
scripting languages that allow me to step across Perl, C, PHP,
assembly code, etc, all within the same process.  In theory that's all
possible today, but given how much of a *pain* ptrace() is to use
correctly, nobody bothers.

Now, with all that said, utrace does not provide any of the
userspace side APIs today... but I think it is a necessary refactoring
if we want to provide a new ideal process-introspection interface
without breaking all the ptrace() users.

Think of the utrace interface as very much like the LSM interface.
Just like with LSMs, there is a lot of active research in debugging
and tracing tools, and nobody can even remotely agree what the hell
they want out of the hooks.  In theory you could add one hook for
every place each security module needs one... but then your fast-path
is littered with always-false test-and-jump statements.  What utrace
provides is the one single test in each fast path that then searches
for and executes the appropriate slow path(s) for that process.

I personally would be very happy to see utrace merged.

Cheers,
Kyle Moffett