]> sourceware.org Git - systemtap.git/log
systemtap.git
3 months agoAdjust hugepage_cow_delays.stp to work with newer kernels
William Cohen [Fri, 29 Mar 2024 18:28:21 +0000 (14:28 -0400)]
Adjust hugepage_cow_delays.stp to work with newer kernels

Kernel git commit c0e8150e144b6 changed the function handling the
copy-on-write operations for hugepages from copy_user_huge_page to
copy_user_large_folio.  Made hugepage_cow_delays.stp use the new
function name when it is available.

3 months agoPR31500: Never allow probing of kernel __init or __kprobes functions
William Cohen [Fri, 22 Mar 2024 14:29:49 +0000 (10:29 -0400)]
PR31500: Never allow probing of kernel __init or __kprobes functions

When guru mode was used it was possble to get systemtap to instrument
kernel functions marked with __init or __kprobes.  By the time that
systemtap instrumentation is being loaded a kernel __init marked
functions has already run and may be in a section of memory that has
been freed up.  At best this probe will never trigger.  At worst the
registration of the probe will cause a memory fault causing the
process to be killed.  Also probes shouldn't be allowed on __kprobes
functions as a rule.

3 months agoPR31525: add preempt* controls for more STP_TIMING cases
Frank Ch. Eigler [Thu, 21 Mar 2024 22:47:01 +0000 (18:47 -0400)]
PR31525: add preempt* controls for more STP_TIMING cases

The testusite produces warnings otherwise.

3 months agoPR31519: sys/sdt.h causes compiler warnings when compiling with C++
Carl Shapiro [Thu, 21 Mar 2024 01:04:26 +0000 (21:04 -0400)]
PR31519: sys/sdt.h causes compiler warnings when compiling with C++

Add a defined(__STDC_VERSION__) guard.

3 months agoRemove unneeded guru mode option from poll_map.exp
William Cohen [Wed, 20 Mar 2024 14:24:53 +0000 (10:24 -0400)]
Remove unneeded guru mode option from poll_map.exp

Guru mode should only be used when it is really needed to allow the
systemtap script change program state or disable some safety check or
black list exclusions. With guru mode enabled on a particular machine
this test would attempt to probe
kernel.function("vfs_caches_init").call, an initialization function on
a page that would would later freed.  The script would get page fault
when attempting to install the kprobe for this function.

3 months agoAllow systemtap --target-namespace=PID option to work with Intel IBT
William Cohen [Tue, 19 Mar 2024 20:09:52 +0000 (16:09 -0400)]
Allow systemtap --target-namespace=PID option to work with Intel IBT

On Intel systemtap with IBT the systemtap runtime code to implement
--target-namespace=PID would cause a trap to occur.  The runtime
indirect calls are now properly wrapped and will execute without issue
on machines supporting Intel IBT.

4 months agoPR31495: teach step-prep to guess kernel-rt on .rt uname kernels
Frank Ch. Eigler [Fri, 15 Mar 2024 18:22:10 +0000 (14:22 -0400)]
PR31495: teach step-prep to guess kernel-rt on .rt uname kernels

This heuristic was requested by a user.

4 months agoPR31491: stapsh: support --remote=bpf
Frank Ch. Eigler [Thu, 14 Mar 2024 23:39:53 +0000 (19:39 -0400)]
PR31491: stapsh: support --remote=bpf

This needed just some code to recognize incoming ".bo" files as
something to be run via stapbpf.

4 months ago(AUTHOR credit for tapset contribution)
Xinhua Li [Thu, 14 Mar 2024 20:05:07 +0000 (16:05 -0400)]
(AUTHOR credit for tapset contribution)

4 months agoRevert "PR30716: Turn off objtool warnings on systemtap instrumentation modules"
William Cohen [Thu, 14 Mar 2024 19:27:17 +0000 (15:27 -0400)]
Revert "PR30716: Turn off objtool warnings on systemtap instrumentation modules"

This reverts commit 155c689b2a75dcb217a1c52886c04982f4c169f2.

There are other things that objtool is doing in addition to checking
user accesses and disabling objtool with newer RHEL9
5.14.0-428.el9.x86_64 causes the system to reboot when setting up some
tracepoint probes (PR30472).

4 months agoPR31490, add some tcp.stp tapset extensions
Frank Ch. Eigler [Thu, 14 Mar 2024 18:12:38 +0000 (14:12 -0400)]
PR31490, add some tcp.stp tapset extensions

Some more little goodies from <xili@redhat.com>.

4 months agoPR30716: Turn off objtool warnings on systemtap instrumentation modules
William Cohen [Thu, 7 Mar 2024 18:44:06 +0000 (13:44 -0500)]
PR30716: Turn off objtool warnings on systemtap instrumentation modules

The previous approaches to turning off the objtool warnings did not
work for x86_64 RHEL9.  The systemtap generated code is not on the
whitelist to use certain kernel functions. The additional objtool
warning output mentioning the systemtap code using those functions
with UACCESS enabled caused a number of the tests in the testsuite to
fail.  The generated Makefile now includes a line to turn off running
objtool on the systemtap generated module and eliminates those
warnings.

4 months agoPR31117: Correct handling of transport layer allocated memory
William Cohen [Mon, 4 Mar 2024 21:27:18 +0000 (16:27 -0500)]
PR31117: Correct handling of transport layer allocated memory

The _stp_print_flush() code was not correct.  There are four possible
ranges of values compared to the header size (hlen)
_stp_data_write_reserve() could return when beginning to write out
log:

<0      unable to allocate any space
<hlen   pad out the allocated space and try another allocation
==hlen  just enough space for the initial header
>hlen   write out the header and some portion of log

The case where the space allocated was equal size of the header
(==hlen) was not handled correctly.  In the cases where there was only
enough room to write the header the _stp_transport_failures variable
was incremented and none of the log data was written out.  The correct
course of action in these cases would be to write the header out in
the allocated space and start looping to write the rest of the log
data.

4 months agoPR31368: Make debuginfod downloads interruptible
Martin Cermak [Thu, 29 Feb 2024 07:54:50 +0000 (08:54 +0100)]
PR31368: Make debuginfod downloads interruptible

React to Ctrl-C when debuginfod downloads are in progress.

4 months agoPR31404: Make tracepoint queries work with gcc14
William Cohen [Wed, 28 Feb 2024 15:43:51 +0000 (10:43 -0500)]
PR31404: Make tracepoint queries work with gcc14

The Fedora rawhide Linux 6.8 kernels are built with gcc14 and include
-Wmissing-prototypes in the CFLAGS options.  When building the
kernel modules to query the available tracepoints errors occur
resulting in kernel tracepoints being found. The fix is to
include a function declaration before the function definition
in the DECLARE_TRACE macro.

4 months agoGet SHM_* flag defines from the appropriate include file for Linux 6.8 kernels
William Cohen [Tue, 20 Feb 2024 14:22:34 +0000 (09:22 -0500)]
Get SHM_* flag defines from the appropriate include file for Linux 6.8 kernels

Linux git commit bc46ef3cea3d6f6 removed the include/uapi/linux/shm.h
from include/linux/shm.h.  For the newer Linux 6.8 kernels need to get
SHM_* defines directly from include/uapi/linux/shm.h.

5 months agoPR19360: Correct lwtools fslatency-nd.stp and fsslower-nd.stp
William Cohen [Thu, 15 Feb 2024 20:01:53 +0000 (15:01 -0500)]
PR19360: Correct lwtools fslatency-nd.stp and fsslower-nd.stp

Reviewed examples to ensure that the entry value for a function
argument is used for function return probes. Found that
__vfs_write.return probes aliases were missing ".return" and needed an
@entry() for the argument fetch in fslatency-nd.stp and
fsslower-nd.stp.

5 months agoPR31373: Deal with the removal of strlcpy() from linux 6.8
William Cohen [Wed, 14 Feb 2024 14:33:30 +0000 (09:33 -0500)]
PR31373: Deal with the removal of strlcpy() from linux 6.8

The Linux 6.8 kernels removed strlcpy() with git commit d26270061a in
January 2024.  All the kernel's strlcpy() uses were converted to
strscpy().  Systemtap needed to do the same.  This is implemented in
systemtap with a strlcpy macro in the runtime that translates the
strscpy() return value into the equivalent strlcpy() value.

5 months agoUpdate the aux_syscall.stp tapset to directly include <uapi/linux/wait.h>
William Cohen [Mon, 5 Feb 2024 19:37:18 +0000 (14:37 -0500)]
Update the aux_syscall.stp tapset to directly include <uapi/linux/wait.h>

The linux kernel git commit 6dfeff09d5ad33190 removes the include for
<uapi/linux/wait.h> from <linux/wait.h>.  The kernel has had
<uapi/linux/wait.h> header for over a dozen years (kernel git commit
607ca46e97a1b65) and systemtap should just use that directly.  The
downside of this change is that systemtap will require a Linux 3.7 or
newer kernel.

5 months agoFix tast_start_time for newer kernels
William Cohen [Thu, 1 Feb 2024 18:31:43 +0000 (13:31 -0500)]
Fix tast_start_time for newer kernels

Kernel git commit cf25e24db61cc9d renames real_start_time member of
the task_struct to start_boottime.  The task_start_time function needs
to be adjusted to handle this new name.

5 months agoPR29997: Fix the symbol aliases search failure when symbol version is missing
Di Chen [Wed, 31 Jan 2024 02:25:35 +0000 (10:25 +0800)]
PR29997: Fix the symbol aliases search failure when symbol version is missing

After calling module_info::update_symtab, function aliases will be
populated. Then the updated symtab will be used for symbol searching.

For the _IO_new_fopen family with the aliases:

  $ eu-readelf -s /lib64/libc.so.6  | grep 0000000000077440
    247: 0000000000077440     14 FUNC    WEAK   DEFAULT       16 fopen64@@GLIBC_2.2.5
   1014: 0000000000077440     14 FUNC    GLOBAL DEFAULT       16 fopen@@GLIBC_2.2.5
   1028: 0000000000077440     14 FUNC    GLOBAL DEFAULT       16 _IO_fopen@@GLIBC_2.2.5
   1556: 0000000000077440     14 FUNC    LOCAL  DEFAULT       16 _IO_fopen64
   3471: 0000000000077440     14 FUNC    LOCAL  DEFAULT       16 __new_fopen
   4765: 0000000000077440     14 FUNC    LOCAL  DEFAULT       16 _IO_new_fopen
   5110: 0000000000077440     14 FUNC    WEAK   DEFAULT       16 fopen64
   7198: 0000000000077440     14 FUNC    GLOBAL DEFAULT       16 fopen@@GLIBC_2.2.5
   7433: 0000000000077440     14 FUNC    GLOBAL DEFAULT       16 _IO_fopen@@GLIBC_2.2.5

  a) fopen@@GLIBC_2.2.5 exists in the updated symtab
  b) fopen does not exist in the updated symtab

This PR is to add a version info padding when symbol cannot be found in
the updated symtab, so systemap can support searching symbol aliases like
this:

  $ stap -L 'process("/lib64/libc.so.6").function("fopen")'
  # And with wildcard, like this
  $ stap -L 'process("/lib64/libc.so.6").function("fo*en")'

Signed-off-by: Di Chen <dichen@redhat.com>
5 months agoPR31309: Avoid NULL pointer dereference
Martin Cermak [Wed, 31 Jan 2024 12:00:55 +0000 (13:00 +0100)]
PR31309: Avoid NULL pointer dereference

5 months agosession.c: bump kernel_version_range()
Frank Ch. Eigler [Mon, 29 Jan 2024 16:16:12 +0000 (11:16 -0500)]
session.c: bump kernel_version_range()

5 months agoPR31288: build with gcc14 cont'd
Frank Ch. Eigler [Thu, 25 Jan 2024 21:46:33 +0000 (16:46 -0500)]
PR31288: build with gcc14 cont'd

5 months agotestsuite: extend pr30407.exp to also cover PIE binaries
Martin Cermak [Mon, 29 Jan 2024 05:26:44 +0000 (06:26 +0100)]
testsuite: extend pr30407.exp to also cover PIE binaries

5 months agosyscall testsuite clock.c test adjusted for newer adjtimex syscall.
William Cohen [Thu, 25 Jan 2024 20:00:34 +0000 (15:00 -0500)]
syscall testsuite clock.c test adjusted for newer adjtimex syscall.

5 months agoPR31288: build with gcc14
Frank Ch. Eigler [Thu, 25 Jan 2024 19:28:38 +0000 (14:28 -0500)]
PR31288: build with gcc14

GCC14 makes -Wmissing-prototypes defaultish on, which triggers on such
gentle-spirited code as:

    void foo(void) { }

when you should darn well know to have an exact duplicate declaration
prototype first.  Because of course.

    void foo(void);
    void foo(void) { }

So anyway, with our fondness for -Werror, this broke the stap runtime
autoconf* business, bits of the runtime, bits of the translator.
Probably more stuff as yet unidentified.  If your testsuite logs show:

 [...]: error: no previous prototype for ‘[...]’ [-Werror=missing-prototypes]

this is probably to blame.

Since this is coming to clang as well, we now get buildrun.cxx to
force -Wmissing-prototypes on all the time, so as to try to notice
occurrences of this problem earlier.

5 months agoPR26843: print_ubacktrace_fileline() fails with PIE binaries
Martin Cermak [Thu, 25 Jan 2024 10:46:50 +0000 (11:46 +0100)]
PR26843: print_ubacktrace_fileline() fails with PIE binaries

Ubuntu has it's GCC configured with --enable-default-pie.  The
binaries it's producing by default are DYN (Position-Independent
Executable file).  This isn't reflected in the producer record.
For processing PIE binaries, additional relocation is needed in
the stap runtime.

5 months agoFix width of _stp_filename_lookup_5's offset to .debug_line_str
Martin Cermak [Thu, 25 Jan 2024 10:37:07 +0000 (11:37 +0100)]
Fix width of _stp_filename_lookup_5's offset to .debug_line_str

The read_pointer( ... DW_EH_PE_data4 ... ) gives a 4 byte value.
Elfutil's readelf.c does this with read_4ubyte_unaligned_inc().
Adjust the storage width for such offset to prevent overflow.
Problem demonstrated with context.exp / symfileline.tcl.

5 months agotestsuite: fix perms of a few .exp files; no +x needed
Frank Ch. Eigler [Tue, 23 Jan 2024 20:12:01 +0000 (15:12 -0500)]
testsuite: fix perms of a few .exp files; no +x needed

5 months agoPR31117: Eliminate some transport failures
William Cohen [Tue, 23 Jan 2024 18:09:45 +0000 (13:09 -0500)]
PR31117: Eliminate some transport failures

The headers for messages cannot span subbuffers.  Depending on the
previous messages the remaining space left in a subbuffer may to too
small for a header.  The code would give up and drop that particular
message when the code found that there was not enough space to write
the entire header.  The revised code now zeros out that small block
allocated and tries again to allocate buffer space for the message
before giving up.  In the common case the next subbuffer has plenty of
space for the header and the rest of the message.

5 months agoPR31280: Add a -Werror suppression configury option, for overly aggressive compiler...
Frank Ch. Eigler [Tue, 23 Jan 2024 15:58:13 +0000 (10:58 -0500)]
PR31280: Add a -Werror suppression configury option, for overly aggressive compiler versions.

5 months agosystemtap.spec: put back the "migrated to spdx" %changelog marker
Frank Ch. Eigler [Mon, 22 Jan 2024 15:36:34 +0000 (10:36 -0500)]
systemtap.spec: put back the "migrated to spdx" %changelog marker

5 months agoFix gates emitting .debug_line_str into stap_symbols.c
Martin Cermak [Mon, 22 Jan 2024 14:26:59 +0000 (15:26 +0100)]
Fix gates emitting .debug_line_str into stap_symbols.c

The symfileline subtest of context.exp pointed a finger to situation
where debug_line_str data weren't emitted to stap_symbols.c while they
were needed.  Align the conditions for emission of .debug_line and
.debug_line_str with conditions for their use.

5 months agotestsuite: Update context.exp
Martin Cermak [Mon, 22 Jan 2024 13:57:13 +0000 (14:57 +0100)]
testsuite: Update context.exp

This improves test results of context.exp.  First it makes the
two .ko's buildable with modern kernels.  The module code seems
to be based on LTP's crasher testcase, and the source should be
usable with 2.6.32 onwards.

I've been facing a problem where systemtap_test_module1 was unable
to see symbols exported by systemtap_test_module2 via EXPORT_SYMBOL
Building both modules using one single makefile seems to solve the
problem.  It also simplifies the testcase.  The makefile2 isn't needed.

Adjust timing in the .tcl files so that expect gates work as needed.
This timing update alread was in symfileline.tcl (kludge warning) and
this timing update now is in all the tcl files.

5 months agostapvirt.c: More gcc-14 -Werror=calloc-transposed-args compatibility
Frank Ch. Eigler [Thu, 18 Jan 2024 21:37:39 +0000 (16:37 -0500)]
stapvirt.c: More gcc-14 -Werror=calloc-transposed-args compatibility

5 months agoPR31242: Support namespaced include directories in Dyninst
Tim Haines [Thu, 18 Jan 2024 19:33:44 +0000 (14:33 -0500)]
PR31242: Support namespaced include directories in Dyninst

Dyninst now has some namespaced include directories (e.g.,
dyninst/registers/MachRegister.h). This requires adding the top-level
include to the compile flags to find the headers in the flat namespace
included from a namespaced directory.

6 months agoPR31235: configury
Tim Haines [Fri, 12 Jan 2024 17:07:38 +0000 (12:07 -0500)]
PR31235: configury

Correct nesting of HAVE_DYNINST vs. HAVE_NSS in Makefile.am.

6 months agoPR31215: @__compat_task misbehaves
Martin Cermak [Tue, 9 Jan 2024 08:57:43 +0000 (09:57 +0100)]
PR31215: @__compat_task misbehaves

Fix detection of probing a 32-bit userspace binary on x86_64.

6 months agotestsuite: Fix syscall test runtime problems
Martin Cermak [Mon, 8 Jan 2024 22:12:42 +0000 (23:12 +0100)]
testsuite:  Fix syscall test runtime problems

This update is mostly addressing SEGVs in syscall tests
compiled as a 32 bit binary on x86_64.  The 32-bit syscall
wrappers typically convert one structure to another by
dereferencing individual struct members.  This is a problem
when pointer to the said struct is invalid (-1).

6 months agotestsuite: Drop ancient rhel6-era nfsservctl.c syscall test
Martin Cermak [Fri, 5 Jan 2024 16:39:00 +0000 (17:39 +0100)]
testsuite:  Drop ancient rhel6-era nfsservctl.c syscall test

6 months agoRefresh the syscall number tables
Martin Cermak [Fri, 5 Jan 2024 15:28:57 +0000 (16:28 +0100)]
Refresh the syscall number tables

Refresh the syscall number tables using scripts/dump-syscalls.sh
using strace commit 9c5b28d0dc17361425f8d63290f31722507435b0 .

6 months agoPR29076: syscall test fixes for .rodata on x86_64 for syncfs.c
William Cohen [Thu, 4 Jan 2024 21:10:02 +0000 (16:10 -0500)]
PR29076: syscall test fixes for .rodata on x86_64 for  syncfs.c

6 months agotapset: Fix _struct_timeval_u()
Martin Cermak [Thu, 4 Jan 2024 18:17:28 +0000 (19:17 +0100)]
tapset: Fix _struct_timeval_u()

The utimes, select and settimeofday syscalls switched from using
struct timeval over to struct __kernel_old_timeval.  This changed
in kernel-5.5-rc1.

6 months agotestsuite: Avoid SEGv in systemtap.syscall/select.c
Martin Cermak [Thu, 4 Jan 2024 15:37:07 +0000 (16:37 +0100)]
testsuite: Avoid SEGv in systemtap.syscall/select.c

6 months agotestsuite: Remove parallel testsuite runs relicts
Martin Cermak [Thu, 4 Jan 2024 12:27:31 +0000 (13:27 +0100)]
testsuite:  Remove parallel testsuite runs relicts

Continue cleanup started in commit 12c28db32718 .
The _init and _finish functions are being called
from dejagnu/runtest.exp in case they are present.

6 months agobpf-translate.cxx: fix build against upcoming `gcc-14` (`-Werror=calloc-transposed...
Sergei Trofimovich [Fri, 22 Dec 2023 19:42:38 +0000 (19:42 +0000)]
bpf-translate.cxx: fix build against upcoming `gcc-14` (`-Werror=calloc-transposed-args`)

`gcc-14` added a new `-Wcalloc-transposed-args` warning recently. It
detected minor infelicity in `calloc()` API usage in `systemtap`:

    bpf-translate.cxx: In function 'bpf::BPF_Section* bpf::output_probe(BPF_Output&, program&, const std::string&, unsigned int)':
    bpf-translate.cxx:5044:39: error: 'void* calloc(size_t, size_t)' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
     5044 |   bpf_insn *buf = (bpf_insn*) calloc (sizeof(bpf_insn), ninsns);
          |                                       ^~~~~~~~~~~~~~~~
    bpf-translate.cxx:5044:39: note: earlier argument should specify number of elements, later size of each element

6 months agotestsuite listing_mode.exp: canonicalize subtest names
Frank Ch. Eigler [Sat, 23 Dec 2023 20:12:14 +0000 (15:12 -0500)]
testsuite listing_mode.exp: canonicalize subtest names

Replace hexadecimal literals with HEXADDR.

6 months agoMakefile.am: fix build with --with-debuginfod=/path configure option
Victor Kamensky [Mon, 18 Dec 2023 05:01:35 +0000 (21:01 -0800)]
Makefile.am: fix build with --with-debuginfod=/path configure option

While I was testing my previous fix with libdebuginfod auto detection
failure I've noticed that configure option --with-debuginfod=/path does
not work in case if system does not have elfutils-debuginfod-client-devel.

I had external elfutils branch with debuginfod metadata change installed
at /path and when I've tried to build SystemTap with it, it was failing
in multiple places. My system is FC38.

It boils dows for couple issues applied in serveral Makefile.am files.

1. util.cxx is C++ file so debuginfod_CFLAGS should be added to _CXXFLAGS
flags, rather then just _CFLAGS

2. debuginfod_LDFLAGS should be added to _LDFLAGS, otherwise link command
does not get proper -L flag

Signed-off-by: Victor Kamensky <victor.kamensky7@gmail.com>
6 months agoconfigure.ac: fix broken libdebuginfod library auto detection
Victor Kamensky [Mon, 18 Dec 2023 05:01:34 +0000 (21:01 -0800)]
configure.ac: fix broken libdebuginfod library auto detection

After 2e67b053e3796ee7cf29a39f9698729b52078406 "configury: rework debuginfod searches"
commit, libdebuginfod.so library auto detection is broken. It was reported by Martin Jansa
on openembedded-core mailing list [1].

Currently configure.ac does "AC_DEFINE([HAVE_LIBDEBUGINFOD], [1] ..." as long as
no --without-debuginfod option is passed, regardless PKG_CHECK_MODULES check result.
It seems to be bad copy/paste. Address the issue by moving the AC_DEFINE back to
PKG_CHECK_MODULES action-if-found block.

To reproduce the issue on FC system, one can do the following
"sudo dnf remove elfutils-debuginfod-client-devel" and then try to build SystemTap
util.cxx will fail to compile because of missing elfutils/debuginfod.h because
config.h will have "#define HAVE_LIBDEBUGINFOD 1", while config.log and configure
output indicates that check for libdebuginfod library failed.

[1] https://lists.openembedded.org/g/openembedded-core/message/192109?p=%2C%2C%2C20%2C0%2C0%2C0%3A%3Acreated%2C0%2Csystemtap%2C20%2C2%2C0%2C102987514

Signed-off-by: Victor Kamensky <victor.kamensky7@gmail.com>
6 months agostaprun: fix build against upcoming `gcc-14` (`-Werror=calloc-transposed-args`)
Sergei Trofimovich [Thu, 21 Dec 2023 10:00:06 +0000 (10:00 +0000)]
staprun: fix build against upcoming `gcc-14` (`-Werror=calloc-transposed-args`)

`gcc-14` added a new `-Wcalloc-transposed-args` warning recently. It
detected minor infelicity in `calloc()` API usage in `systemtap`:

    staprun.c: In function 'main':
    staprun.c:550:50: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
      550 |                 char ** new_argv = calloc(sizeof(char *),argc+2);
          |                                                  ^~~~

6 months agoPR31060: Dynamically switch mount namespaces for the target.
Yichun Zhang (agentzh) [Mon, 18 Dec 2023 01:45:02 +0000 (17:45 -0800)]
PR31060: Dynamically switch mount namespaces for the target.

When --target-namespace=PID is specified, the early uprobe registration
and target program file path resolving in task finder should switch the
current mount namespace to the target program's.

Otherwise we'd see errors like this:

    ERROR: Couldn't resolve target program file path '/newtarget/a.out': -2

We switch mount namespaces in the kernel space around kern_path() calls
because the kernel module also fiddles with files like relayfs in the
original mount namespace. The granularity of calling setns() on userland is
just too coarse.

For older kernels like those on CentOS/RHEL 7, Ubuntu 16.04 and Debian 9,
we use a hack to call the setns() syscall directly from within the
kernel space. Newer kernels have a good enough kernel C API to emulate
setns() in the kernel space.

6 months agoPR31180: feature: added new probepoint process.data(ADDR).* for userland hardware...
Yichun Zhang (agentzh) [Sun, 17 Dec 2023 06:21:27 +0000 (22:21 -0800)]
PR31180: feature: added new probepoint process.data(ADDR).* for userland hardware watchpoints.

6 months agoRefactored some of the code for kernel.data(*).* probepoints to the stap runtime.
Yichun Zhang (agentzh) [Sun, 17 Dec 2023 04:49:46 +0000 (20:49 -0800)]
Refactored some of the code for kernel.data(*).* probepoints to the stap runtime.

This makes development easier by avoiding updating a lot of code in
the translator all the time.

This also makes the upcoming process.data(*) probepoints easier to
implement.

Additionally, we made it abort when the first hw breakpoint fails
to register instead of going on registering the remaining hw
breakpoints. Added tests to cover this change.

6 months agochange: use bounded loops for spin_trylock() in the NMI context.
Yichun Zhang (agentzh) [Mon, 18 Dec 2023 07:06:25 +0000 (23:06 -0800)]
change: use bounded loops for spin_trylock() in the NMI context.

6 months agoPR31176: fix Spin lock deadlocks in memory pool allocations for mixed NMI and non...
Yichun Zhang (agentzh) [Sun, 17 Dec 2023 01:35:03 +0000 (17:35 -0800)]
PR31176: fix Spin lock deadlocks in memory pool allocations for mixed NMI and non-NMI contexts

The kernel's lockdep finds dead locks in the stap memory pool allocator's
spinlocks when mixing NMI and non-NMI contexts.

Now we use trylock in the NMI context to avoid waiting forever on a lock
held by a non-NMI context (which is interrupted by NMI).

This bug can be reproduced by running TEST 4 in
testsuite/systemtap.base/kernel-hw-breakpoint-addr.exp on a lockdep
kernel that is recent enough (like 5.11.22).

6 months agotests: updated the test cases in kernel-hw-breakpoint-addr for ubuntu and slower...
Yichun Zhang (agentzh) [Mon, 18 Dec 2023 00:47:13 +0000 (16:47 -0800)]
tests: updated the test cases in kernel-hw-breakpoint-addr for ubuntu and slower machines.

6 months agoPR30831: Improve error handling of systemtap workqueue
William Cohen [Mon, 18 Dec 2023 01:40:56 +0000 (20:40 -0500)]
PR30831: Improve error handling of systemtap workqueue

During the startup of systemtap instrumentation a workqueue is
created.  It is possible that the kernel is unable to allocate space
for the workqueue. The initialization for this case should return
-ENOMEM to end the loading of the instrumentation module.  There are
other ways that the systemtap instrumentation may fail during
initialization after the creation of the workqueue.  In those cases
the workqueue needs to be destroyed to avoid leaking resources.

7 months agoAdd more tests to cover the kernel.data(ADDR) probepoints much better.
Yichun Zhang (agentzh) [Sat, 16 Dec 2023 19:17:47 +0000 (11:17 -0800)]
Add more tests to cover the kernel.data(ADDR) probepoints much better.

Also fixed the symbol extraction regex (against nm outputs) in the
test scaffold.

7 months agoAdjust DEBUG_TRANS enabled code to work with current kernels and compilers
William Cohen [Fri, 15 Dec 2023 02:23:34 +0000 (21:23 -0500)]
Adjust DEBUG_TRANS enabled code to work with current kernels and compilers

The last element in _stp_command_names is in
_stp_command_name[STP_MAX_CMD].  Thus, the array has STP_MAX_CMD+1
elements rather than STP_MAX_CMD elements.  The compiler would flag
the access beyond the end of the array due to the incorrectly sized
array.

The min operation provided by the kernel's minmax.h include does type
checking.  Needed to type cast STP_MAX_CMD to match the other argument
and avoid the compiler flagging the type mismatch as an error.

7 months agoPR31039: Make autoconf-utrace-via-tracepoints.c work with struct folio
William Cohen [Mon, 11 Dec 2023 22:03:18 +0000 (17:03 -0500)]
PR31039: Make autoconf-utrace-via-tracepoints.c work with struct folio

Newer linux kernels are using struct folio in place of struct page.
Kernel git commit 8c9ae56dc73b5ae48 replaces the struct page argument
in should_numa_migrate_memory() with a struct folio.  To make the
autoconf-utrace-via-tracepoints.c test compile properly needed to add
an include to pull in the struct folio definition.  This allows the
auto_path.exp and many other tests using userspace probes to function
properly on the newer Linux 6.7 kernels.

7 months agoPR31119: translator: sign-extension might yield wrong results in string escaping...
Yichun Zhang (agentzh) [Fri, 8 Dec 2023 21:35:43 +0000 (13:35 -0800)]
PR31119: translator: sign-extension might yield wrong results in string escaping code.

The C++ sign-extensiosn might lead to wrong results in the current escapging
code:

`(unsigned)str[I]` is equivalent to `(unsigned)(int)str[i]`.

Thanks Junlong Li for the original patch.

7 months agoPR27803: Do not remove doc/SystemTap_Tapset_Reference/tapsets.pdf
William Cohen [Wed, 6 Dec 2023 21:36:42 +0000 (16:36 -0500)]
PR27803: Do not remove doc/SystemTap_Tapset_Reference/tapsets.pdf

The "make clean" would remove tapsets.pdf and the "make" does
not rebuild it.  tapsets.pdf is built using some other scripts
and is checked into the SystemTap git repository.  Changing
the Makefile.am and Makefile.in to avoid removing tapsets.pdf

7 months agotestsuite: Use --skip-badvars with syscall tests (cont'd)
Martin Cermak [Wed, 6 Dec 2023 11:45:30 +0000 (12:45 +0100)]
testsuite:  Use --skip-badvars with syscall tests (cont'd)

7 months agotestsuite: Use --skip-badvars with syscall tests
Martin Cermak [Wed, 6 Dec 2023 08:49:43 +0000 (09:49 +0100)]
testsuite:  Use --skip-badvars with syscall tests

Without it, the "big" test module, having syscall.* in it, might
not compile at all. In such case none of the syscall tests can run.
This way we can at least run the tests and possibly KFAIL the test
results where needed.

7 months agoSupport kretprobe ABI change in Linux 5.11 kernels
William Cohen [Tue, 5 Dec 2023 14:55:30 +0000 (09:55 -0500)]
Support kretprobe ABI change in Linux 5.11 kernels

Linux git commit d741bf41d7 changed how to access information
associated with a kretprobe instance.  Code should use the
get_kretprobe function to get that information.  For older kernels
just define an equivalent get_kretprobe define.

7 months agoPR31074: Ensure that the set_kernel_string* functions limit their writes
William Cohen [Mon, 4 Dec 2023 16:28:10 +0000 (11:28 -0500)]
PR31074: Ensure that the set_kernel_string* functions limit their writes

Both the set_kernel_string and set_kernel_string_n function use the
underlying _stp_store_deref_string_ function to write strings.  There
were two issues with the this function:

 1) wrote MAXSTRINGLEN bytes even if string was shorter
 2) null write at end could spill past end of buffer

The first issue was addressed by stopping to write once a null
character is encountered.  The second issue is a side effect of C
implicit promotion of character constants to ints and was addressed by
explicitlying casting the character constants as a char.

The pr31074.exp test was added to verify that the write length are
limited to string length and the null write does not go beyond the end
of the buffer.

7 months agoMakefile.am: remove runtime/linux/uprobes and runtime/linux/uprobes2 install
Victor Kamensky [Mon, 4 Dec 2023 03:38:39 +0000 (19:38 -0800)]
Makefile.am: remove runtime/linux/uprobes and runtime/linux/uprobes2 install

"PR30434 continuation:  Removed old uprobes, uprobes2 implementation,
uprobes-inc.h & any mentions of CONFIG_UTRACE." commit removed uprobes,
and uprobes2 sources and directories, but Makefile.am still tries to
install them. In fact after failing to 'cd' into runtime/linux/uprobes
directory it copies top level *.[ch] files into
${prefix}/share/systemtap/runtime/linux/uprobes directory.

The issue was caught by OpenEmbedded project do_package_qa checks.

Signed-off-by: Victor Kamensky <victor.kamensky7@gmail.com>
7 months agosystemtap.spec: always build systemtap-jupyter
Frank Ch. Eigler [Sun, 12 Nov 2023 12:46:51 +0000 (07:46 -0500)]
systemtap.spec: always build systemtap-jupyter

The build/packaging part of that subsystem does not actually depend on
python or anything.  The "make install" configury is entirely unconditional.
So the RPM should also unconditionally package the %files up.  (They won't
-run- without python, but that's a runtime dependency issue, not a build-time
one.)

7 months agotestsuite: Allow for caching the syscall test module
Martin Cermak [Wed, 29 Nov 2023 15:41:51 +0000 (16:41 +0100)]
testsuite: Allow for caching the syscall test module

The systemtap module needed for the syscall test is big, and building
it takes time.  In case one tries to fix a syscall test, keeping the
tapset intact, it's handy to cache the module to save time.

However, using the cached module may lead to confusing results in case
it's not used right.  To lower the risk, the testcase prints a bold warn
message if the feature is in use.

Here's an example usage:
make installcheck RUNTESTFLAGS=syscall.exp CHECK_ONLY=futex REUSE_MODULE=1

7 months agoTestsuite: syscall/clock.c: RHEL8 improvements
Martin Cermak [Mon, 27 Nov 2023 16:22:09 +0000 (17:22 +0100)]
Testsuite: syscall/clock.c: RHEL8 improvements

7 months agopost-release 5.1 version bump
Frank Ch. Eigler [Tue, 21 Nov 2023 23:57:44 +0000 (18:57 -0500)]
post-release 5.1 version bump

7 months agoTweak testsuite/semok/target_addr.stp to work with linux 5.14 and newer.
William Cohen [Tue, 21 Nov 2023 23:56:42 +0000 (18:56 -0500)]
Tweak testsuite/semok/target_addr.stp to work with linux 5.14 and newer.

8 months agoPR29076: syscall test fixes for .rodata on x86_64 for pwritev.c and sysfs.c
William Cohen [Wed, 15 Nov 2023 22:01:14 +0000 (17:01 -0500)]
PR29076: syscall test fixes for .rodata on x86_64 for pwritev.c and sysfs.c

8 months agoPR29076: Additional syscall test fixes for .rodata on x86_64
William Cohen [Wed, 15 Nov 2023 20:40:07 +0000 (15:40 -0500)]
PR29076: Additional syscall test fixes for .rodata on x86_64

There were a number of additional syscall tests that needed fixes
similar to git commit 6577f2237.

8 months agoFix map_hash.exp and map_wrap.exp tests
William Cohen [Thu, 9 Nov 2023 14:44:40 +0000 (09:44 -0500)]
Fix map_hash.exp and map_wrap.exp tests

At one time systemtap output hexidecimal numbers for dumping
the associative arrays.  It is currently using decimal numbers.
The map_hash.exp and map_wrap.exp tests needed to be adjusted
to recognize the current systemtap output.

8 months agobugfix: older gcc versions do not have the -Wno-infinite-recursion option.
Yichun Zhang (agentzh) [Mon, 13 Nov 2023 22:17:47 +0000 (14:17 -0800)]
bugfix: older gcc versions do not have the -Wno-infinite-recursion option.

This affect older gcc versions used to compile the kernel.

8 months agoPR31054: Non-system-wide perf event probes should not use work queues for registration
Yichun Zhang (agentzh) [Sat, 11 Nov 2023 01:46:41 +0000 (17:46 -0800)]
PR31054: Non-system-wide perf event probes should not use work queues for registration

The non-system-wide task-finder-based perf event probes do not have the
limitation of always requiring SYS_CAP_ADMIN like the system-wide ones.
So avoiding the work queue thing for this case is a nice-to-have optimization.

Getting rid of work queue in this case also make it easier if we want to
support resolving task executable file paths in another mount namespace
in the future (otherwise the current task context would be kworker
instead of stapio/staprun).

8 months agofeature: stap -t now outputs module init timing reports.
Yichun Zhang (agentzh) [Sun, 12 Nov 2023 05:32:29 +0000 (21:32 -0800)]
feature: stap -t now outputs module init timing reports.

8 months agotranslator: fixed output code indentation regarding stap -t.
Yichun Zhang (agentzh) [Sun, 12 Nov 2023 04:16:12 +0000 (20:16 -0800)]
translator: fixed output code indentation regarding stap -t.

8 months agoPR31052: -DDEBUG_MEMALLOC_MIGHT_SLEEP resulted in lots of kernel errors
Yichun Zhang (agentzh) [Sat, 11 Nov 2023 07:56:13 +0000 (23:56 -0800)]
PR31052: -DDEBUG_MEMALLOC_MIGHT_SLEEP resulted in lots of kernel errors

We should really enable `might_sleep()` only when the gfp_mask might sleep.

8 months agoPR31053: memory allocator might sleep in atomic contexts
Yichun Zhang (agentzh) [Sat, 11 Nov 2023 07:25:54 +0000 (23:25 -0800)]
PR31053: memory allocator might sleep in atomic contexts

Previously, STP_ALLOC_FLAGS used in the stap kernel runtime's
memory allocator actually included __GFP_IO and __GFP_FS flags which might
sleep. All modern kernels would trigger this bug.

STP_ALLOC_FLAGS is supposed to be used "anywhere", including atomic
contexts.

8 months agoPR31051: memory and uprobe leaks in early uprobe registraton code when errors happen
Yichun Zhang (agentzh) [Sat, 11 Nov 2023 05:51:56 +0000 (21:51 -0800)]
PR31051: memory and uprobe leaks in early uprobe registraton code when errors happen

8 months agodebug: added new MTAG macro so that we can know where the leaked allocation comes...
Yichun Zhang (agentzh) [Sat, 11 Nov 2023 05:35:39 +0000 (21:35 -0800)]
debug: added new MTAG macro so that we can know where the leaked allocation comes from.

It is still required to add MTAG invocations to the relavant code. I
prefer not adding them by default to the code base since it gets messy
very quickly.

One sample error line is like this:

    ERROR: Memory ffff88811e63b320 len=72 tag=runtime/linux/uprobes-inode.c:556
        allocation type: kmalloc. Not freed

In this example, we know the leak comes from the code after the line 556
of the source file uprobes-inode.c and also before the next MTAG
invocation.

8 months agotestsuite: PR30407 cleanup
Frank Ch. Eigler [Wed, 8 Nov 2023 00:55:26 +0000 (19:55 -0500)]
testsuite: PR30407 cleanup

The build process (including the testsuite) should not attempt to
modify $srcdir - it might be read-only.  Instead, those little files
are simply put into the git repo.  Also, switched to a dejagnu library
routine for the target file compilation, with more consistent
diagnostics.

8 months agosystemtap.spec: Correct 5.0 release timestamp
Frank Ch. Eigler [Wed, 8 Nov 2023 00:11:49 +0000 (19:11 -0500)]
systemtap.spec: Correct 5.0 release timestamp

8 months agotestsuite: auto_path.exp
Frank Ch. Eigler [Wed, 8 Nov 2023 00:10:48 +0000 (19:10 -0500)]
testsuite: auto_path.exp

Rework invocation mechanism for the workload test binaries some more.
These are now run from within the systemtap script directly, instead
of funky nested expect { } blocks inside tcl.

8 months agoprerelease datestamp fixes
Frank Ch. Eigler [Sat, 4 Nov 2023 16:19:59 +0000 (12:19 -0400)]
prerelease datestamp fixes

8 months agoFix timing issue causing failures of testcase auto_path.exp
Martin Cermak [Tue, 7 Nov 2023 11:04:16 +0000 (12:04 +0100)]
Fix timing issue causing failures of testcase auto_path.exp

8 months agoPR31028: Handle .callee probes for DWARF5 information release-5.0a
William Cohen [Fri, 3 Nov 2023 16:09:19 +0000 (12:09 -0400)]
PR31028: Handle .callee probes for DWARF5 information

DWARF5 stores call site information differently than DWARF4. The
DWARF5 call sites are tagged with DW_TAG_call_site in place of
DWARF4's DW_TAG_GNU_call_site and need to reference the
DW_AT_call_origin rather than DW_AT_abstract_origin.

Without this patch any of the tests in the
systemtap.base/listing_mode.exp testsuite using .callee() would fail
to find the associated probe point.

8 months agoDrop the tapset_functions.exp
Martin Cermak [Fri, 3 Nov 2023 14:44:42 +0000 (15:44 +0100)]
Drop the tapset_functions.exp

Drop the tapset_functions.exp.  It needs constant maintenance of the
blocklist as the systemtap codebase grows.  It's also using a
--compatible hack to access private functions.  After a discussion on
the #systemtap IRC channel the decision was to drop the testcase.

8 months agopre-release AUTHORS bump
Frank Ch. Eigler [Thu, 2 Nov 2023 20:38:28 +0000 (16:38 -0400)]
pre-release AUTHORS bump

8 months agopre-release NEWS refresh
Frank Ch. Eigler [Thu, 2 Nov 2023 20:37:09 +0000 (16:37 -0400)]
pre-release NEWS refresh

8 months agosystemtap.spec: reenable crash
Frank Ch. Eigler [Thu, 2 Nov 2023 20:36:48 +0000 (16:36 -0400)]
systemtap.spec: reenable crash

https://bugzilla.redhat.com/show_bug.cgi?id=2219728 has been solved

8 months agoAvoid conflicting with statx declaration provided by glibc 2.28 and newer.
William Cohen [Wed, 1 Nov 2023 23:58:00 +0000 (19:58 -0400)]
Avoid conflicting with statx declaration provided by glibc 2.28 and newer.

8 months agoPR31014: Uprobes registered in task finder would block the target processes for long...
Yichun Zhang (agentzh) [Mon, 30 Oct 2023 07:46:36 +0000 (00:46 -0700)]
PR31014: Uprobes registered in task finder would block the target processes for long time.

Currently, the stap runtime tries to call uprobe_register() to register new
uprobes inside the context of the target processes via the task finder.
This makes little sense for inode-based uprobes implemented in modern kernels
and also introduces significant (8ms+) delay in all the target processes via
the task work mechanism. Such delays may manifest themselves in syscalls like
epoll_wait inside the target processes.

All the target processes are affected even though only one task finder
callback gets to call uprobe_register(). Other concurrent target processes
would just wait on the lock `c->consumer_lock`.

After talking with fche, I'd propose that we should register uprobes early
before starting the task finder callbacks. This still may block a CPU core
for 8ms+ or so, but it no longer blocks all the target processes in their
own process contexts.

8 months agoPR31024: always compare the real inodes for files in overlay or union fs.
Yichun Zhang (agentzh) [Wed, 1 Nov 2023 03:16:43 +0000 (20:16 -0700)]
PR31024: always compare the real inodes for files in overlay or union fs.

overlay fs is popular in containerized applications and currently the stap
runtime does not always use the real inode for the target processes/programs.
This may make the uprobes registered on the fake inode insead of the true ones,
making the probe handlers never fire.

8 months agoPR31020: runtime: task_finder2: we didn't resolve symlink PATH in "probe process...
Yichun Zhang (agentzh) [Wed, 1 Nov 2023 06:15:30 +0000 (23:15 -0700)]
PR31020: runtime: task_finder2: we didn't resolve symlink PATH in "probe process(PATH).*"

Use of symlinks in PATH might confuse the task finder when matching
procname.

8 months agoTurn off gcc stringop-overflow warnings for syscall.exp tests
William Cohen [Wed, 1 Nov 2023 19:29:58 +0000 (15:29 -0400)]
Turn off gcc stringop-overflow warnings for syscall.exp tests

On RHEL9 and Fedora the gcc compiler warns about string manipulations
that could overflow desitnation buffer.  When the compiler warns about
these for the C code being compiled the actual systemtap test does not
run.  Passing in -Wno-stringop-overflow to the compiler to turn those
warnings off and allow the tests to run.  This eliminates about 110 of
the untested test on Fedora Rawhide.

8 months agopre-release sample index regen
Frank Ch. Eigler [Wed, 1 Nov 2023 16:59:32 +0000 (12:59 -0400)]
pre-release sample index regen

This page took 0.073501 seconds and 5 git commands to generate.