William Cohen [Thu, 12 Oct 2023 03:10:21 +0000 (23:10 -0400)]
PR30401: Address newer s390 kernels that move struct stack_frame
Linux git commit 78c98f907413 moved struct stack_frame
<asm/processor.h> to a newly created <asm/stacktrace.h>. As a result
the struct definition does not get pulled in by the existing
<asm/ptrace.h> include for the newer kernels. Have a autoconf test to
determine whether the <asm/stacktrace.h> exists and uses it if it
avaialble.
Frank Ch. Eigler [Thu, 12 Oct 2023 17:02:39 +0000 (13:02 -0400)]
testsuite: drop busybox test case
This test case (with an old fixed version of busybox) has been a
problem with respect to compatibility with newer libc/kernels,
with readonly source trees, and doesn't seem to contribute much
to test value. So nuke it all.
Frank Ch. Eigler [Thu, 12 Oct 2023 16:45:09 +0000 (12:45 -0400)]
testsuite: simplify Makefile drivers
It was reported that "make installcheck" broke with commit 218c26a523816. Investigation pointed at quoting mishaps somewhere in
the Makefile machinery related to parallel / partial testsuite runs.
While this logic was clever and appeared useful for a time, it seems
fragile in practice and not in active use after all. So let's nuke
all of it.
Moved the environment_sanity.exp test into the systemtap/ subdirectory
to apprx. guarantee that it's run first, no Makefile magic needed. It
still exits dejagnu entirely if it fails.
Way back during early dejazilla days, the "check-local" target was
needed in order to liberate test results, regardless of pass/failure
of the dejagnu suite. To make that work, an "execrc" wrapper was
interposed between make and dejagnu/runtest, to turn everything into
a pass rc=0.
Dejagnu support was removed in 2022, so this execrc hack is not needed
any more. Tests that fail, especially the early
systemtap.base/environment_sanity.exp one, should stand out better
in buildbot reports.
PR27410 cont'd: Tolerate (skip) foreign-architecture binaries via debuginfod
With debuginfod path probes, it is easy to refer to a whole slew of
binaries. That's a good thing, but debuginfod may be so well informed
that it sends stap buildids of foreign-architecture binaries too.
systemtap should skip these guys instead of having a cow.
New common tapsets.cxx code makes architecture mismatch generally a
warning rather than a direct semantic error. This has effects beyond
the debuginfod based probes, but that should be fine.
Bad-architecture target binaries will just be skipped in other
contexts too. Tweaked debuginfod.process() builder code makes the
subsidiary buildid-based process probes all optional, as though they
were identified by glob ... which in a manner of speaking they were.
William Cohen [Wed, 27 Sep 2023 14:09:11 +0000 (10:09 -0400)]
Eliminate use of kernel's flush_scheduled_work() in systemtap modules
Kernel git commit 20bdedafd2f63e0ba70991127f9b5c0826ebdb32 turns use
of flush_scheduled_work() into a warning which causes builds of
anything using it to fail because warnings are treated as errors.
Previous users of flush_scheduled_work() in the kernel have been
converted over to use individual workqueues. Systemtap runtime now
does the same. It creates and uses its own workqueue to eliminate the
use of flush_scheduled_work().
William Cohen [Fri, 15 Sep 2023 19:12:11 +0000 (15:12 -0400)]
Use TWA_RESUME in the runtime calls to task_work_add
Kernel git commit c40e60f00caf18bc382215c79651777eb40f5f9d in the
linux 6.6 kernels will cause the implicit conversion of boolean true
to an enum task_work_notify_mode to be flagged resulting in the
systemtap instrumentation compile to fail. Adding a config check to
use TWA_RESUME if it is available or pass in the equivalent true
argument for older kernels.
William Cohen [Tue, 12 Sep 2023 15:34:24 +0000 (11:34 -0400)]
Eliminate use of do_each_thread() macro
The Linux kernel commit 5ffd2c37cb7a5 removed the do_each_thread()
macro and suggests using the for_each_process_thread() in its place.
The Systemtap runtime has been migrated to using the more concise
macro. The for_each_process_thread() macro was added by commit 0c740d0afc3bff to Linux 3.14, January 2014, almost a decade ago, so it
should be available on modern systems.
Martin Cermak [Fri, 22 Sep 2023 10:46:03 +0000 (12:46 +0200)]
Fix flightrecorder log rotation test cases
Commit 5b39471380a238469c8fc18136f12600e5e9aec7 changed how flight
recorder logs are rotated. The rotation now only happens in case there
is some actual stap output. Without output, there's nothing to rotate,
and that makes sense after all.
This test suite update makes sure there is always some stap output, so
that the log rotation can actually happen.
PR30858: improve diagnostics for pass-4 build failures in lkm mode
Kernel versions often drift beyond the range against which systemtap
has been tested. Since there is no persistent kernel API, stap
runtime can break with new major releases. Improve the pass-4 error
message, so that the tested kernel range is printed:
[....]
WARNING: kbuild exited with status: 2
Pass 4: compilation failed. [man error::pass4]
Kernel version 6.3.12 is within tested range 2.6.32 ... 6.5
The message advises "within" or "outside" as per strverscmp.
William Cohen [Tue, 12 Sep 2023 14:18:58 +0000 (10:18 -0400)]
Have the scsi tapset support newer kernels struct scsi_cmnd
The linux kernel commit 2266a2def97ce11ec removed the request field
from struct scsi_cmnd. The scsi tapset needed to test whether the
request field is available. If request field is not available, use
the linux kernels helper function scsi_cmd_to_rq to get a value for
request.
William Cohen [Tue, 29 Aug 2023 15:33:41 +0000 (11:33 -0400)]
PR30777: Allow systemtap to work on Intel machines with IBT enabled
Intel 11th gen processors include Indirect Branch Target (IBT)
support. Systemtap needs to take some additional steps to work in
this environment. For kernels that do not have CONFIG_X86_KERNEL_IBT
set these steps are turned into NOPS.
William Cohen [Tue, 29 Aug 2023 15:14:56 +0000 (11:14 -0400)]
For non-x86 architectures set the CPUFlags to be empty.
On aarch64 and other non-x86 architectures the get_system_info
procedure would fail because there are no flags in the /proc/cpuinfo.
The procedure now does a check to see if it is available and set
CPUFlags appropriately.
Housam Alamour [Thu, 24 Aug 2023 17:48:29 +0000 (13:48 -0400)]
PR30434: deprecate rhel6 (2.6.32*) support. Deprecate code from various files as well as the testsuite. Mainly "if" branches used by older kernels/distros to define necessary macros.
Housam Alamour [Wed, 16 Aug 2023 18:35:20 +0000 (14:35 -0400)]
PR30434 complete: Further removal of "if" branches related to old distros/kernel versi
ons. Removal of runtime/linux/autoconf-utrace-regset.c. Patch to previous commits to fix testcase errors.
PR30434: deprecate rhel6 (2.6.32*) support. Depricate code from files in the source /systemtap directory. Mainly "if" branches that define macros used by older kernels/distros.
Frank Ch. Eigler [Wed, 23 Aug 2023 12:51:08 +0000 (08:51 -0400)]
PR30716: work around objtool stac/clac warning
Since early 2022, linux upstream changes have occurred related to use of
segment registers / SMAP machinery to control kernel access to userspace
memory. PR30456 started support in this area, by wrapping our userspace
accessing functions in the proper begin/end wrappers. However, objtool
is programmed with a "whitelist" of functions to permit to be called
within those begin/end wrappers. Our own userspace accessing functions
are "safe" in the sense that they can't leak the "AC" flag, but objtool
doesn't know, so spams stderr with:
/var/tmp/stap8X6e5G/stap_84eb7946bc6f829f61271ffa7a79c1a5_2690620.o: warning: objtool: probe_58677+0xfab: call to __get_user_nocheck_8() with UACCESS enabled
This patch hacks around this by stopping objtool from detecting this
situation (by suppressing its "--uaccess" command line option).
Another approach could be to switch to the kernel's normal get_user_*
etc. wrappers, which should be within the "whitelist", but that's a
larger change to contemplate.
Frank Ch. Eigler [Sat, 12 Aug 2023 18:28:44 +0000 (14:28 -0400)]
PR30749: correct stap --sign-module timing
Previous code signed the temp directory copy, after it had already
been copied into the cache -- so the signature never made it to a
permanent artifact.
If the module was being fetched from the cache from a previous build
run, a sign (re)attempt will still be done. This may not be
necessary, but shouldn't be harmful.
Logic in commit cd48874296e00 (2021, PR28449) fixed broken cross-cpu
message ordering that followed previous transport concurrency fixes,
but imposed a lot of userspace synchronization delays upon the threads
who were supposed to drain messages from the kernel relayfs streams as
fast as possible. This has led to unnecessarily lossy output overall.
New code uses a new many-writers single-reader data structure, a mutex
protected heap. All the per-cpu readers copy & pump messages into
that heap as rapidly as possible, sorted by the generally monotonic
sequence number. The reader is signalled via a condition variable and
time to print & release messages in sequence number order. It also
handles lost messages (jumps in the sequence numbers) by waiting a while
to let the stragglers come in.
The kernel-user messages now also include a framing sequence to allow
the per-cpu readers to resynchronize to the message boundaries, in
case some sort of buffer overflow or something else occurs. It
reports how many bytes and/or messages were skipped in order to
resynchronize. It does so in a lot less lossy way than previous code,
which just tried to flush everything then-currently available, hoping
that it'd match message boundaries.
Unfortunately, this means that the user-kernel message ABI has
changed! Previous-version staprun instances won't work with the new
modules, nor will current-version staprun with old modules. This flag
day is enforced by changing the numbers of the various ctl message
numbers, so old/new kernel/user combinations will generate errors
rather than quasi-successful staprun startup.
New code also dramatically simplifies the use of signals in staprun
(or rather stapio). Gone is the signal thread, a lot of the
masking/blocking/waiting. Instead a single basic signal handler just
increments globals when signals of various kinds arrive, and all the
per-cpu etc. threads poll those globals periodically. This includes
logic needed for -S (output file rotation on SIGUSR2) as well as
flight recorder (-L / -A) modes.
The reader_timeout_ms value (-T) in both bulk/serialized mode for all
ppoll timeouts, to prevent those threads from sleeping indefinitely,
now that they won't be bothered by signals.
William Cohen [Fri, 28 Jul 2023 17:26:10 +0000 (13:26 -0400)]
Simplify init_backlog function to avoid coverity BAD_SHIFT errors
The init_backlog function determines the power of two sized memory
allocation that would have at least fnum_max elements. Reworked the
code to make it clearer to the coverity analyzer what it is doing.
Rather than overshooting the desired order value and then adjusting it
down by one the while loop has been revised to exit when the order is
the correct value.
William Cohen [Sun, 9 Jul 2023 20:46:20 +0000 (16:46 -0400)]
Adjust runtime _access_process_vm_ to work with linux 6.5
Linux kernel commit ca5e863233e8f6acd1792fd85d6bc2729a1b2c10
eliminated the vma argument for ‘get_user_pages_remote. For linux 6.5
kernel use the get_user_page_vma_remote function in its place like the
__access_remote_vm function in mm/memory.c of the kernel.
William Cohen [Thu, 29 Jun 2023 17:17:38 +0000 (13:17 -0400)]
Fedora rawhide kernels are now flagging use of zero length arrays
The kernel has switched from using zero length arrays to flexible
arrays. The kernel compiles have gotten picker and now flags accesses
beyond the end of end of arrays when possible. When trying to run the
testsuite on Fedora rawhide got the following error due to a zero
length array:
In file included from /tmp/stapaBPtwB/stap_6b7e9ee7df4a3f6e4cfbffb7f92d8405_1736_src.c:543:
/home/wcohen/systemtap_write/install/share/systemtap/runtime/linux/stp_tracepoint.c: In function 'add_tracepoint':
/home/wcohen/systemtap_write/install/share/systemtap/runtime/linux/stp_tracepoint.c:148:22: error: 'strcmp' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread]
148 | if (!strcmp(name, e->name)) {
| ^~~~~~~~~~~~~~~~~~~~~
/home/wcohen/systemtap_write/install/share/systemtap/runtime/linux/stp_tracepoint.c:61:14: note: source object 'name' of size 0
61 | char name[0];
| ^~~~
Switched the zero length array in the struct to a flexible array to
eliminate the issue.
Frank Ch. Eigler [Tue, 20 Jun 2023 18:04:48 +0000 (14:04 -0400)]
systemtap.spec: SPDX review cleanup
SPDX codes for the testsuite, -client (tapset+docs!) and -devel
(tapset!) updated.
Also corrected/filledin licenses for stap-prep and
interactive-notebook/codemirror/package.json. Many other files remain
without a formal license header. These all default to GPL-2.0-or-later
William Cohen [Thu, 8 Jun 2023 17:10:00 +0000 (13:10 -0400)]
Make runtime/transport/alloc.c compatible with newer struct module_memory
The upstream kernel commit ac3b43283923440900b4f36ca5f9f0b1ca43b70e
changed the structures for modules. The runtime/transport/alloc.c
made an access to the struct module_memory when -DSTP_MAXMEMORY is
used on the command line and needed the appropriate field name for the
newer kernels. This change allows stap script builds using
-DSTP_MAXMEMORY to work on Linux 6.4 kernels.
William Cohen [Thu, 8 Jun 2023 01:50:34 +0000 (21:50 -0400)]
Make runtime/transport/symbols.c compatible with newer struct module_memory
The upstream kernel commit ac3b43283923440900b4f36ca5f9f0b1ca43b70e
changed the structures for modules. The runtime/transport/symbols.c
made an access to the struct module_memory and needed the appropriate
field name for the newer kernels. This change allows another dozen of
the systemtap examples to pass on Linux 6.4 kernels.
William Cohen [Wed, 7 Jun 2023 17:18:01 +0000 (13:18 -0400)]
Adjust runtime module_kallsyms_on_each_symbol to work with Linux 6.3 kernels
The recent fix for PR30415 worked for new Linux 6.4 kernels and
pre-6.3 kernels, but did not work for Linux 6.3 kernels. The Linux
6.3 kernel module_kallsyms_on_each_symbol function has both the
modname argument of the 6.4 kernels and the function passed in has the
earlier kernel's struct module pointer argument. The runtime/sym.c has
been adjusted to work with the the Linux 6.3 kernels.
William Cohen [Wed, 17 May 2023 14:38:31 +0000 (10:38 -0400)]
Support newer kernels with struct module_memory
The upstream kernel commit ac3b43283923440900b4f36ca5f9f0b1ca43b70e
changed the structures for modules. The runtime printing of kernel
information accessed information about modules and the fields in
module structure. A test has been added to the autoconf list to
determine the appropriate fields to get information about the
module.
Bug: our autoconf mechanism might find unexported symbols in kernel headers not meant for kernel modules
The current BULID_CHECK thing does not pass -DMODULE option as the real
kernel build system does and thus may expose unexported symbols like
nmi_uaccess_okay() to our autoconf test programs.
PR30408: fixed excessive read faults when reading userland memory from within perf event/kprobes handlers
The user_addr_max() macro is gone since kernel 5.18, which broke stap's
userland reading routines.
And also since kernel 5.18, access_ok() now does address range checks on
all architectures. so we don't bother checking it ourselves for newer
kernels.
Frank Ch. Eigler [Fri, 12 May 2023 16:43:55 +0000 (12:43 -0400)]
stap-server logic: drop scraped NSS error table
This used to be needed in the ancient days, when the NSS-related
shared libraries did not reliably decode error codes into usable
messages. This stuff works nwo, so we don't have to carry this
hand-scraped table around any more.
Frank Ch. Eigler [Fri, 12 May 2023 15:13:45 +0000 (11:13 -0400)]
PR30442: failing optional statement probes should not trigger pass2 exceptions
In tapsets.cxx, query_cu() and query_module() aggressively caught &
sess-print_error'd semantic_errors from subsidiary call sites. They
are unaware of whether the probe in question is being resolved within
an optional (? or !) context. Instead of this, they now simply let
the exceptions propagate out to derive_probes() or similar, which does
know whether exceptions are errors in that context. That means
exceptions can propagate through elfutils iteration machinery too,
perhaps risking C level memory leaks, but so be it.
This fix goes well beyond statement probes per se, but hand-testing
and the testsuite appear not to show regressions related to this.
Serhei Makarov [Mon, 8 May 2023 12:12:59 +0000 (08:12 -0400)]
fix PR30395: Regex code has invalid memory reads caught by KASAN
The TNFA tag cleanup on a '\0' byte would incorrectly read beyond the
end of the string. Keeping YYCURSOR on the nul byte fixes this.
Will harden the fix a little (adding a separate increment-only cursor
for safety) before I close the bug, but this change is already
sufficient if the DFA was generated correctly.
William Cohen [Tue, 25 Apr 2023 14:56:47 +0000 (10:56 -0400)]
Test for kernels that backported removal of <linux/genhd.h> include
Some kernels (RHEL9) backported patches that removed the
<linux/genhd.h> include. Thus, the ioblock.stp tapset cannot simply
check the kernel version to determine whether the include file is
available. The added autoconf test will determine whether the include
is available.
William Cohen [Tue, 25 Apr 2023 13:44:51 +0000 (09:44 -0400)]
Allow nfsd.stp tapset to work on kernels with CONFIG_NFSD_V2 unset
Some of the newer Fedora kernels have CONFIG_NFSD_V2 unset (*). The
nfsd.stp tapset was requiring various NFSD V2 probes points to exist.
These required probes caused examples like nfsd-trace and nfsdtop
build failures. Making the NFSD V2 probes optional allows the
nfsd.stp tapset to work on these kernels.
BZ2180328: disable pass-2 dyninst liveness analysis on CONFIG_RETPOLINE kernels
As a stopgap measure, ameliorate the dramatic dyninst analysis time
required to liveness-check $var assignments in kernels compiled with
retpolines. Just skip the effort (with a warning).
See also: https://github.com/dyninst/dyninst/issues/1305 .