public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: fche@redhat.com (Frank Ch. Eigler)
To: <systemtap@sourceware.org>
Subject: Re: Tapset difficulties w/ pointers
Date: Sun, 30 Apr 2006 18:53:00 -0000	[thread overview]
Message-ID: <y0m1wvesxnb.fsf@ton.toronto.redhat.com> (raw)
In-Reply-To: <CBDB88BFD06F7F408399DBCF8776B3DC07128FF6@scsmsx403.amr.corp.intel.com>


joshua.i.stone wrote:

> For the process.exec probe, I would like to make the pointer to the new
> task_struct available.  This is fine, and then I can make
> access-functions for the user to extract data from this, like so:
> 
>  function task_pid:long (task:long) %{ /* pure */
>  [...]
>    struct task_struct *t = [...] (THIS->task)-> [...]
>
> The obvious problem here is safety.  I can check that the parameter is
> not zero, but what do I do if the user calls task_pid(0xDEADBEEF)?
> Oops...  Or what happens if the user stashes the pointer away in a
> global, and tries to read it later?  Oops...

We don't have to return correct answers to trick questions, just avoid
hurting the system.  Dereference operations in exposed embedded-C code
can be channeled through the same deref() macro used by $target
variable expansions, which aims to catch ordinary faults.  The new
kprobes fault-handling code being discussed may do this automatically
for some probes.  Further, we can mark mapped-but-unsafe memory
regions (bug #1288) in a similar way as dtrace does, to filter
addresses further.

Some of this would require some discipline from the author of an
embedded-C function.


> One solution is to "hide" task_pid(), perhaps by renaming it to
> __task_pid(), and then have the tapset provide variables for pid,
> tid, etc. and rely on the compiler to elide those that are unused.
> [...]

This style should work well with recent optimizer tweaks.

> This is still not really safe though, because that __task_pid() is
> only discouraged, not protected.  [...]

Another possibility is to impose a naming convention for "internal"
functions (and probes? variables?), so that only guru-mode code can
resolve references to them.  (i.e., external references to "__FOO"
symbols would only resolve in guru mode).


> A more general solution would be if we had some sort of "handle"
> type.  [...]  It can have metadata to identify the type, and perhaps
> also to limit the valid lifetime of the pointer. [...]

Unless the machinery involved in something like this is fairly small
and simple, I'd prefer to first explore the limits of the simpler ones
above.


- FChE

      parent reply	other threads:[~2006-04-30 18:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-28 23:23 Stone, Joshua I
2006-04-28 23:48 ` James Dickens
2006-04-30 18:53 ` Frank Ch. Eigler [this message]

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=y0m1wvesxnb.fsf@ton.toronto.redhat.com \
    --to=fche@redhat.com \
    --cc=systemtap@sourceware.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).