* FW: Tapset difficulties w/ pointers
@ 2006-05-01 21:17 Stone, Joshua I
0 siblings, 0 replies; only message in thread
From: Stone, Joshua I @ 2006-05-01 21:17 UTC (permalink / raw)
To: systemtap
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-05-01 21:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-01 21:17 FW: Tapset difficulties w/ pointers Stone, Joshua I
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).