linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: 2.4 Ready list - Kernel Hooks
@ 2002-10-22 23:09 Richard J Moore
  2002-10-22 23:54 ` Greg KH
  2002-10-23 15:28 ` Werner Almesberger
  0 siblings, 2 replies; 14+ messages in thread
From: Richard J Moore @ 2002-10-22 23:09 UTC (permalink / raw)
  To: Werner Almesberger; +Cc: Rob Landley, linux-kernel, S Vamsikrishna


Werner Almesberger wrote:

>Richard J Moore wrote:
>> Kernel Hooks is also ready,
>
>I'm a bit puzzled as to what those hooks accomplish. They look
>like a less flexible but a little faster and more portable
>variant of kprobes.
>
>Is this what they are ? If yes, does it really make sense to
>have two so similar mechanisms for tapping into execution flows
>in the kernel ?
>
>- Werner

Hello Werner, the two things are different:

kprobes
-------

This is kernel interface that allows kernel modules register to register
one or more probes.
A probes comprises a breakpoint location, a breakpoint handler and a post
single-step handler.
Why use the term probes? Because we don't intend to hijack the system,
merely register a location where we can seamlessly gather data and
continue.
The sequence of events that occurs when code containing a probepoint
executes are:
1) The associated probe handler is invoked.
2) The probe handler returns.
3) The probed instruction is single-stepped.
4) The post-single-step handler is called.
5) The post-single-step handler returns.
6) The probed code continues execution.

kprobes confines itself to kernel-space probepoints, which are implemented
using a breakpoint instruction.
There are three incremental patches that Vamsi submitted today which extend
krpobes as follows:
1) debug register management - provides a kernel interface for debug
register allocation and deallocation so debuggers can co-exists e.g
kprobes, ptrace, kdb etc..
2) kwatch points - allows probes to be set using debug registers. This
allows probes to fire on data accesses for example.
3) user space probes - this extends kprobes to be able to set probepoints
in user space. Note probes are tracked by inode and offset so that they are
global and relative to a module. This distinguishes kprobes user-space
probes from ptrace implemented breakpoints.


dprobes
-------
The four kprobes patches is almost equivalent to dprobes. Dprobes provides
a generic RPN interpreter in which to define probe handler actions. We
decided that RPN interpreter should be separated out from the breakpointing
mechanism. It's just an example probe handler and can exist outside the
kernel. Also having a set of callable interfaces is more flexible than just
having an RPN language to define probe handlers. The dprobes project has
evolved in to kprobes + a sample device driver that provide the generic RPN
probe handler.

kernel hooks
------------
This is nothing more than a call-back mechanism such as could be used by
LSM or LTT. The call-backs have to be statically coded into the source
unlike kprobes where the call-back to a probe handler is implemented via a
debug interrupt from a watchpoint or dynamically implanted INT3. We created
kernel hooks for exactly the same reasons that LSM needs hooks - to allow
ancillary function to exist outside the kernel, to avoid kernel bloat, to
allow more than one function to be called from a given call-back (think of
kdb and kprobes - both need to be called from do_debug).

Yes both kprobes and kernel hooks implement call-backs, but using INT3 to
call functions is not the most efficient call mechanism, whereas implanting
call back dynamically for debugging purposes is a tad more difficult if
done by patching in a jmp or call instruction.

It's a case of horses for courses. kprobes is a debugging facility; kernel
hooks is a static call-back mechanism.

Richard


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: 2.4 Ready list - Kernel Hooks
@ 2002-10-24 16:38 Richard J Moore
  2002-10-24 17:02 ` Greg KH
  0 siblings, 1 reply; 14+ messages in thread
From: Richard J Moore @ 2002-10-24 16:38 UTC (permalink / raw)
  To: Greg KH; +Cc: Rob Landley, linux-kernel, S Vamsikrishna, Werner Almesberger


Greg KH wrote:
>Please read the LSM documentation for more information about this.  It
>can be found in the kernel at:
>            Documentation/DocBook/lsm.*
>and there are a number of USENIX and OLS papers about different aspects
>of the project at:


Thanks Greg. I'll check out the doc. I do remember posting the LSM mailing
list about kernel hooks, but as I recall there was no response. I assumed
that the hooking mechanism was not the focus of attention - that was
18months ago. A few weeks ago Suparna told me LSM had been enquiring about
kernel hooks - never heard the outcome though.

Richard




^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: 2.4 Ready list - Kernel Hooks
@ 2002-10-23 16:47 Richard J Moore
  2002-10-23 19:50 ` Werner Almesberger
  0 siblings, 1 reply; 14+ messages in thread
From: Richard J Moore @ 2002-10-23 16:47 UTC (permalink / raw)
  To: Werner Almesberger; +Cc: Rob Landley, linux-kernel, S Vamsikrishna


> Is the idea that people would deploy hooks locally, i.e. while
> profiling or debugging, or that some hooks would be put permanently
> in the kernel ?

Our principle reasons for using hooks is:

1) We simplify the integration of related facilities that would share a
number of common hook points, e.g. kdb, dprobes, ltt etc
2) We don't bloat the kernel with these feature but still have the ability
to turn them on dynamically when the need (or the pain) is sufficient for
us to do something about it.
2a) we can reduce the overhead of the extra function when dormant to almost
nil if it can be unhooked from the kernel.
3) We used them during development to extricate a function from the kernel
into a loadable module. This avoided many reboots and kernel builds.


>By the way, those hooks look like an excellent mechanism for
>circumventing the GPL, so you might want to export them with
>EXPORT_SYMBOL_GPL.

We already do that.

I don't envisage having an arbitrary set of hook points scattered
throughout the kernel. It's only when, for example, dprobes needed certain
hooks that we added them.



Richard


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: 2.4 Ready list - Kernel Hooks
@ 2002-10-23  8:10 Richard J Moore
  2002-10-23 17:09 ` Greg KH
  0 siblings, 1 reply; 14+ messages in thread
From: Richard J Moore @ 2002-10-23  8:10 UTC (permalink / raw)
  To: Greg KH
  Cc: Rob Landley, linux-kernel, Richard J Moore, S Vamsikrishna,
	Werner Almesberger


>On Wed, Oct 23, 2002 at 12:09:38AM +0100, Richard J Moore wrote:
>> We created
>> kernel hooks for exactly the same reasons that LSM needs hooks - to
allow
>> ancillary function to exist outside the kernel, to avoid kernel bloat,
to
>> allow more than one function to be called from a given call-back (think
of
>> kdb and kprobes - both need to be called from do_debug).
>
>No, that is NOT the same reason LSM needs hooks!  LSM hooks are there to
>mediate access to various kernel objects, from within the kernel itself.
>Please do not confuse LSM with any of the above projects.
>
>thanks,
>
>greg k-h

I would have to understand what you meant by "mediate between various
kernel objects" to know whether LSM's need for hooks is radically different
to RAS needs. Can you explain further?


Richard


^ permalink raw reply	[flat|nested] 14+ messages in thread
* 2.4 Ready list - Kernel Hooks
@ 2002-10-21 12:24 Richard J Moore
  2002-10-22 21:02 ` Werner Almesberger
  0 siblings, 1 reply; 14+ messages in thread
From: Richard J Moore @ 2002-10-21 12:24 UTC (permalink / raw)
  To: Rob Landley; +Cc: linux-kernel


Kernel Hooks is also ready,
see: http://www-124.ibm.com/linux/projects/kernelhooks/


Richard
RAS Project Lead - IBM Linux Technology Centre



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

end of thread, other threads:[~2002-10-24 17:16 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-22 23:09 2.4 Ready list - Kernel Hooks Richard J Moore
2002-10-22 23:54 ` Greg KH
2002-10-23 15:28 ` Werner Almesberger
2002-10-23 16:21   ` Karim Yaghmour
  -- strict thread matches above, loose matches on Subject: below --
2002-10-24 16:38 Richard J Moore
2002-10-24 17:02 ` Greg KH
2002-10-23 16:47 Richard J Moore
2002-10-23 19:50 ` Werner Almesberger
2002-10-24  7:38   ` Vamsi Krishna S .
2002-10-24 17:22     ` Werner Almesberger
2002-10-23  8:10 Richard J Moore
2002-10-23 17:09 ` Greg KH
2002-10-21 12:24 Richard J Moore
2002-10-22 21:02 ` Werner Almesberger

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).