Jonathan Lebon [Tue, 18 Feb 2014 22:50:53 +0000 (17:50 -0500)]
Merge branch 'templates' into jlebon/callee
This branch converts all the iterate_over_* functions into templates,
which allow for typesafe callbacks. Casts should no longer be used in
callback functions.
Jonathan Lebon [Fri, 7 Feb 2014 15:49:02 +0000 (10:49 -0500)]
callee.exp: new testcase for callee probes
This testcase tests all the aspects callee probes have to handle, such
as inlined functions, exported functions, nested [inlined] functions,
and relocation.
Jonathan Lebon [Tue, 18 Feb 2014 22:13:52 +0000 (17:13 -0500)]
make .callee[s] probes only trigger when called from target callers
Here, we prefix a block to the callee's probe handler to only pass
through if all the callers up the chain match with the current stack.
For .callee("func") probes, we simply add a check for [u]stack(1) ==
"func". For .callees(N) probes, we add a check that the N callers up the
callstack match those iterate_over_callees() found during static
analysis.
These checks are done at runtime by the caller_match() tapset function,
which calls _stp_[uk]module_relocate() to get the relocated address of
the expected caller and _stp_stack_[user|kernel]_get() to get the
unwinding address in the wanted stack frame.
Jonathan Lebon [Tue, 28 Jan 2014 19:51:07 +0000 (14:51 -0500)]
implement iterate_over_callees()
In this patch, we actually implement iterate_over_callees(). This
function looks for inlined subroutines or GNU_call_sites and calls the
callback for each found. The query_callee() callback for now simply does
a query_statement on the callee found. Logic is added in the next patch
to limit probing to calls from caller only.
David Smith [Tue, 18 Feb 2014 21:19:13 +0000 (15:19 -0600)]
Add a rpm require on 'mokutil' when needed.
* systemtap.spec: Make the client subpackage require 'mokutil' when
needed.
* session.cxx (get_mok_info): Remove 'FIXME' comment about needing to
require 'mokutil'.
Frank Ch. Eigler [Tue, 18 Feb 2014 20:03:21 +0000 (15:03 -0500)]
PR16603: correct time drift on fluctuating-cpufreq unsync-tsc boxes
* runtime/time.c: Restructure the per-cpu base_ns/base_cycles logic so
a common function is used during initialization, the regular timer
callback, and the irregular cpufreq callback (via an IPI there).
Josh Stone [Sat, 15 Feb 2014 01:25:12 +0000 (17:25 -0800)]
stapdyn: Reorganize utrace probing, and get end-by-exec working
* mutatee.cxx (mutatee::exec_reset_instrumentation): Save process.end
probes into exec_proc_end_probes, and clear the rest of attached_probes.
(mutatee::call_utrace_dynprobes): Take a whole vector of probes, and do
the lookup for utrace_enter_function here.
(mutatee::find_attached_probes): Return the vector directly.
(mutatee::thread_callback): Use find_attached_probes, and pass that to
call_utrace_dynprobes as is.
(mutatee::begin_callback): Ditto.
(mutatee::exit_callback): Ditto, except treat exec specially.
(mutatee::instrument_dynprobes): Don't try to deal with exec here,
because the stap module probably isn't ready yet.
* mutator.cxx (mutator::exec_callback): Call mutatee::exit_callback.
(mutator::exit_callback): Align the fake-local probe hits to work more
similarly to mutatee::exit_callback.
David Smith [Thu, 13 Feb 2014 19:54:35 +0000 (13:54 -0600)]
Fix PR16580 by decoding the 'protocol' argument of 'syscall.socket{pair}'.
* tapset/linux/aux_syscalls.stp (_sock_protocol_str): New function.
* tapset/linux/syscalls2.stp: Decode the 'protocol' argument in
syscall.socket and syscall.socketpair with _sock_protocol_str().
* tapset/linux/nd_syscalls2.stp: Ditto.
* testsuite/systemtap.syscall/socket.c: New test.
* testsuite/systemtap.syscall/socketpair.c: Updated test to expect decoded
'protocol' arguments.
* testsuite/systemtap.syscall/net1.c: Ditto.
Lukas Berk [Thu, 13 Feb 2014 16:18:18 +0000 (11:18 -0500)]
Check directories exist before sym linking runtime-java helpers
* systemtap.spec - When we're linking libHelperSDT_*.so and
HelperSDT.jar we need to make sure that the openjdk
dirs we're linking to actually exist if yum/openjdk
failed to remove the base dir on an openjdk upgrade.
Jonathan Lebon [Wed, 12 Feb 2014 21:43:47 +0000 (16:43 -0500)]
find_and_build: set from_glob for globby functors
We don't want to create suggestions for probe points created from globby
functors (e.g. syscall.*). Otherwise, we'll be creating a lot of
overhead calculating levenshtein distances for no reason.
Dave Brolley [Wed, 12 Feb 2014 21:03:51 +0000 (16:03 -0500)]
RHBZ 847285: Don't allow 'systemctl reload'.
'reload' is not supported by the stap-server script. The
ExecReload line in stap-server.service was calling
'stap-server restart' which stops the server and starts a
new one. This behavior is not expected or tolerated by systemd
which promptly sends SIGKILL to the new server.
We cannot supported 'reload' in systemctl. Note that 'restart'
is supported and works properly.
David Smith [Wed, 12 Feb 2014 18:58:41 +0000 (12:58 -0600)]
Fix PR16570 by speeding up the syscall.exp/nd_syscall.exp testcases.
* testsuite/systemtap.syscall/syscall.exp: Compile the module once.
* testsuite/systemtap.syscall/nd_syscall.exp: Ditto.
* testsuite/systemtap.syscall/test.tcl (run_one_test): Use staprun to load
the previously compiled module.
David Smith [Tue, 11 Feb 2014 18:07:57 +0000 (12:07 -0600)]
Small scheduler tapset testsuite fixes.
* testsuite/buildok/scheduler-cpu_on.stp: New file.
* testsuite/buildok/scheduler-detailed.stp: Moved 'scheduler.cpu_on' test
to scheduler-cpu_on.stp.
* testsuite/buildok/scheduler-migrate.stp: Removed unneeded
'__scheduler.migrate.kp' test.
David Smith [Tue, 11 Feb 2014 18:03:58 +0000 (12:03 -0600)]
Make 'signal.checkperm.return' optional, since it can be inlined.
* tapset/linux/signal.stp: On some kernels, check_kill_permission() can be
only inlined, so make 'signal.checkperm.return' optional.
* testsuite/buildok/signal-detailed.stp: Make the
'signal.checkperm.return' test optional
David Smith [Tue, 11 Feb 2014 17:38:03 +0000 (11:38 -0600)]
Fix PR16557 by improving the vm.mmap probe alias.
* tapset/linux/memory.stp (vm.mmap): Improve probe alias by probing
do_mmap_pgoff() (when available) instead of do_mmap(), which can be
always inlined.
David Smith [Mon, 10 Feb 2014 23:08:13 +0000 (17:08 -0600)]
Fix kernels that have CONFIG_USER_NS, but uid/gids are still simple values.
* buildrun.cxx (compile_pass): Add an export test for "from_kuid_munged".
* runtime/linux/runtime.h: If we don't have "from_kuid_munged", define our
own from_kgid_munged()/from_kgid_munged() that do nothing.
Jonathan Lebon [Mon, 10 Feb 2014 20:47:25 +0000 (15:47 -0500)]
delete initscript/README.stap-server
The large majority of information in README.stap-server was already part
of the stap-server(8) man page. A few examples and clarifications were
transferred over.
- initscript/README.stap-server: delete it
- man/stap-server.8: incorporate some of the examples from the README
and some clarifications
- systemtap.spec: remove README.stap-server from $files list
- NEWS: add blurb about removal
David Smith [Mon, 10 Feb 2014 19:07:09 +0000 (13:07 -0600)]
Fix PR16541 by updating the nfsd.stp tapset.
* tapset/linux/nfsd.stp: Two fixes. Handle kernels with CONFIG_USER_NS,
whose uids/gids aren't simple types. In nfsd.close, handle the inlined
case were we can't find the argument.
Jonathan Lebon [Mon, 10 Feb 2014 15:20:56 +0000 (10:20 -0500)]
man/systemtap.8.in: new man page to replace README
This man page replaces the README.systemtap text file. The content is
almost the same. A lot of rephrasing, some restructuring, and some
clarifications that weren't present in the original document.
- man/systemtap.8.in: new man page
- initscript/README.systemtap: remove it
- initscript/systemtap.in: add hint to man page
- configure.ac: add man/systemtap.8.in in AC_CONFIG_FILES macro
- man/Makefile.am: add systemtap.8 to man_MANS
- systemtap.spec: replace README by man page in systemtap-initscript pkg
$files list
runtime: linux 3.14 porting: userns: Remove UIDGID_STRICT_TYPE_CHECKS
Adapt to linux commit 261000a56b6382f597bcb12000f55c9ff26a1efb
by using CONFIG_USER_NS as trigger for our *id*munged treatment
instead of CONFIG_UIDGID_STRICT_TYPE_CHECKS.
David Smith [Wed, 29 Jan 2014 19:27:40 +0000 (13:27 -0600)]
Various server cleanups related to MOK handling.
* stap-serverd.cxx (inotify_callback): Simplified.
(avahi_publish_service): Open the inotify file in non-blocking
mode. Create the server mok directory if needed.
(mok_sign_file): Return a bool to let callers know if it worked.
(handleRequest): If MOK signing failed, tell the client to not load the
resulting module.
David Smith [Wed, 29 Jan 2014 16:04:33 +0000 (10:04 -0600)]
Remove global list of server MOK fingerprints.
* stap-serverd.cxx (mok_dir_valid_p): Extract code from
initialize_server_moks().
(get_server_mok_fingerprints): The remains of initialize_server_moks().
(create_services): Call get_server_mok_fingerprints() instead of
initialize_server_moks().
(initialize_server_moks): Removed.
(handleRequest): Don't use global list of server MOKs. Instead, check
presence of client fingerprints on the fly.
David Smith [Wed, 29 Jan 2014 14:21:59 +0000 (08:21 -0600)]
Watch the server MOK directory for changes.
* stap-serverd.cxx (create_services): Refresh the server MOK info.
(inotify_callback): New function.
(avahi_cleanup): Cleanup the inotify watch.
(avahi_publish_service): Watch the server MOK directory for any
changes.
(initialize_server_moks): Clear out the old MOK info. Don't bother
initializing NSS (since it will already be initialzied from the new call
site).
(initialize): Let create_services() find the list of MOKs.
David Smith [Tue, 28 Jan 2014 16:32:22 +0000 (10:32 -0600)]
Make the server send a MOK public cert to the client when needed.
* csclient.cxx (compile_server_client::process_response): If the server
returns a MOK public certificate, copy it to the user's current
directory.
* stap-serverd.cxx (handleRequest): If the server has no MOK in common
with the client, send it one for the client to install.
David Smith [Thu, 23 Jan 2014 22:11:17 +0000 (16:11 -0600)]
Simplify MOK fingerprint advertisement.
* stap-serverd.cxx (create_services): Instead of "mok_infoN" keys, just
use a single key ("mok_info") with multiple values.
* csclient.cxx (get_values_from_avahi_string_list): New function.
(resolve_callback): Expect multiple values with the same "mok_info"
key.
David Smith [Wed, 22 Jan 2014 20:56:12 +0000 (14:56 -0600)]
Initial MOK signed module support.
* buildrun.cxx (make_run_command): If we're using signed modules, we can't
rename modules.
* csclient.cxx (compile_server_info::operator==): Compare MOK fingerprints.
(compile_server_client::create_request): If needed, send a MOK
fingerprint file of valid MOKs to the server.
(operator <<): Output MOK info.
(get_or_keep_compatible_server_info): If the client requires secure boot
signing, make sure the server has the right MOK.
(resolve_callback): Process MOK info in the avahi advertisement.
* nsscommon.cxx (read_cert_info_from_file): New function.
* nsscommon.h: Add read_cert_info_from_file() declaration.
* session.cxx (systemtap_session::check_options): If the kernel is using
signed modules, enforce server use.
(systemtap_session::modules_must_be_signed): New function.
(systemtap_session::get_mok_info): Ditto.
* session.h: Add new function declarations.
* stap-serverd.cxx (process_r): Keep track of kernel build dir.
(create_services): Advertise server MOK information.
(initialize_server_moks): New function.
(initialize): Call initialize_server_moks() to get list of MOKs the
server knows about.
(get_client_mok_fingerprints): New function.
(mok_sign_file): Ditto.
(handleRequest): Match up client and server MOKs. Sign module.
Jonathan Lebon [Wed, 22 Jan 2014 14:01:57 +0000 (09:01 -0500)]
string.stp: fix str_replace() return
Unfortunately, we can't use STAP_RETURN() here because we've been
gradually building STAP_RETVALUE from multiple concatenations so using
STAP_RETURN() would overwrite the hard work.
Jonathan Lebon [Fri, 17 Jan 2014 17:11:20 +0000 (12:11 -0500)]
stap[run/dyn]: disable colors when SYSTEMTAP_COLORS empty
The current behaviour of SYSTEMTAP_COLORS is to turn on colors if it is
not set, or set but empty, and to turn off colors when set and invalid.
With this patch, rather than having users purposely make it invalid to
turn off colors, we interpret a set but empty SYSTEMTAP_COLORS to mean
turning colors off.