diff options
author | Frank Ch. Eigler <fche@elastic.org> | 2009-09-16 22:32:28 -0400 |
---|---|---|
committer | Frank Ch. Eigler <fche@elastic.org> | 2009-09-16 22:37:24 -0400 |
commit | 6ecd877049008c5abe9c6720ea8fc64732f47eb5 (patch) | |
tree | 407a536c1271b8e5757899e461c481e599266d67 /tapset/utrace.stp | |
parent | 6846cfc8a5cdb24fccb19037b27a180d2300ee09 (diff) | |
download | systemtap-steved-6ecd877049008c5abe9c6720ea8fc64732f47eb5.tar.gz systemtap-steved-6ecd877049008c5abe9c6720ea8fc64732f47eb5.tar.xz systemtap-steved-6ecd877049008c5abe9c6720ea8fc64732f47eb5.zip |
PR10650: markup some unprivileged-safe tapset functions
Add /* unprivileged */ to a variety of tapset embedded-c functions,
together with uid-assertion-checking code as needed. This is only
an initial set, and may need to grow or shrink after further testing.
Prototyped-By: Dave Brolley <brolley@redhat.com>
* runtime/runtime.h (is_myproc, assert_is_myproc): New macros.
* runtime/addr-map.c (lookup_bad_addr): Reject if !is_myproc
in unprivileged mode.
* runtime/print.c (_stp_print_kernel_info): Add unprivileged
mode info.
* tapset/DEVGUIDE: Document /* pure */ and /* unprivileged */.
* tapset/*.stp: Add /* unprivileged */ here and there, in
questionable cases along with an assert_is_myproc().
Diffstat (limited to 'tapset/utrace.stp')
-rw-r--r-- | tapset/utrace.stp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/tapset/utrace.stp b/tapset/utrace.stp index 0d26ed5f..4f841b30 100644 --- a/tapset/utrace.stp +++ b/tapset/utrace.stp @@ -4,23 +4,38 @@ #include "syscall.h" %} -function _utrace_syscall_nr:long () %{ /* pure */ - THIS->__retvalue = syscall_get_nr(current, CONTEXT->regs); +function _utrace_syscall_nr:long () %{ /* pure */ /* unprivileged */ + assert_is_myproc(); + if (! CONTEXT->regs) { + CONTEXT->last_error = "invalid call without context registers"; + } else { + THIS->__retvalue = syscall_get_nr(current, CONTEXT->regs); + } %} -function _utrace_syscall_arg:long (n:long) %{ /* pure */ +function _utrace_syscall_arg:long (n:long) %{ /* pure */ /* unprivileged */ unsigned long arg = 0; - syscall_get_arguments(current, CONTEXT->regs, (int)THIS->n, 1, &arg); + assert_is_myproc(); + if (! CONTEXT->regs) { + CONTEXT->last_error = "invalid call without context registers"; + } else { + syscall_get_arguments(current, CONTEXT->regs, (int)THIS->n, 1, &arg); + } THIS->__retvalue = arg; %} -function _utrace_syscall_return:long () %{ /* pure */ +function _utrace_syscall_return:long () %{ /* pure */ /* unprivileged */ /* * Here's the reason for the "unsigned long" cast. Since all * values inside systemtap are 64-bit numbers, return values were * getting sign extended. This caused return values to not match * up with the same values passes as arguments. */ - THIS->__retvalue = (unsigned long)syscall_get_return_value(current, + assert_is_myproc(); + if (! CONTEXT->regs) { + CONTEXT->last_error = "invalid call without context registers"; + } else { + THIS->__retvalue = (unsigned long)syscall_get_return_value(current, CONTEXT->regs); + } %} |