From: "Stone, Joshua I" <joshua.i.stone@intel.com>
To: <systemtap@sourceware.org>
Subject: FW: Tapset difficulties w/ pointers
Date: Mon, 01 May 2006 21:17:00 -0000 [thread overview]
Message-ID: <CBDB88BFD06F7F408399DBCF8776B3DC0716E626@scsmsx403.amr.corp.intel.com> (raw)
Forgot to CC the mailing list...
On Monday, May 01, 2006 12:55 PM, Stone, Joshua I wrote:
> On Sunday, April 30, 2006 11:53 AM, Frank Ch. Eigler wrote:
>> 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.
>
> OK, so is this how task_pid() should look?
>
> function task_pid:long (task:long) %{ /* pure */
> struct task_struct *t = (struct task_struct *)(long)THIS->task;
> THIS->__retvalue = deref(sizeof(t->tgid), &(t->tgid));
> goto out;
> deref_fault:
> CONTEXT->last_error = "pointer dereference fault";
> %}
>
> This seems to work, but is it safe from all contexts?
>
> There seems to be a bug in the deref macros in loc2c-runtime.h -- the
> temporary used to capture the value is an intptr_t, which was
> #defined to long. A long is 32-bit on i386, so deref(8,addr) will be
> truncated, and probably corrupt the stack with the rest of the value.
>
>>> 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.
>
> If we can make the dereferencing safe, then I would prefer leave it
> exposed. That way I can have a task_parent function, and let the
> user query info about the parent, grandparent, etc.
>
>
> Josh
reply other threads:[~2006-05-01 21:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=CBDB88BFD06F7F408399DBCF8776B3DC0716E626@scsmsx403.amr.corp.intel.com \
--to=joshua.i.stone@intel.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).