import systemtap-4.5-1.el8

This commit is contained in:
CentOS Sources 2021-05-28 04:13:51 +00:00 committed by Andrew Lukoshko
parent 78ec8e4a4a
commit e045073cc8
10 changed files with 47 additions and 3568 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/systemtap-4.4.tar.gz
SOURCES/systemtap-4.5.tar.gz

View File

@ -1 +1 @@
f126888adda90a0ec57f43f9db20fde68c8ef356 SOURCES/systemtap-4.4.tar.gz
c549d5fa7aaf6a8cef3371f5757d912d41eae934 SOURCES/systemtap-4.5.tar.gz

View File

@ -1,55 +0,0 @@
commit 734f5acf6c568c02254a33730c6f0fff016bdd09
Author: Martin Cermak <mcermak@redhat.com>
Date: Wed Jan 20 22:09:49 2021 +0100
systemtap-service onboot: Skip updating the bootloader
It shows up that just modifying the default initrd is good enough,
no need to call kernel-install or new-kernel-pkg. This speeds up
the systemtap-service onboot operation.
diff --git a/initscript/systemtap.in b/initscript/systemtap.in
index 713f7a680..b1621ae2f 100755
--- a/initscript/systemtap.in
+++ b/initscript/systemtap.in
@@ -46,8 +46,6 @@ STAPRUN=@bindir@/staprun
UNAME=/bin/uname
LSMOD=/sbin/lsmod
DRACUT=`which dracut`
-NEWKERNELPKG=/sbin/new-kernel-pkg
-KERNELINSTALL=/usr/bin/kernel-install
# Not actually used directly, but needed by
# stap dracut module for inclusion in initramfs
@@ -839,10 +837,6 @@ backup_initramfs() {
onboot () {
local s ret ss
- if [ ! -f "$NEWKERNELPKG" -a ! -f "$KERNELINSTALL" ]; then
- do_failure "Could not find $NEWKERNELPKG nor $KERNELINSTALL"
- return 1
- fi
if [ ! -f "$DRACUT" ]; then
do_failure "$DRACUT not found"
return 1
@@ -940,20 +934,6 @@ onboot () {
return 0
fi
clog "done"
- # We're installing the initramfs in the default location, so user
- # expects the next boot to use it. Let's also update the bootloader.
- clog " Updating bootloader ... " -n
- if [ -x "$NEWKERNELPKG" ]; then
- logex $NEWKERNELPKG --initrdfile="$INITRAMFS" \
- --update $KRELEASE
- else
- logex $KERNELINSTALL add $KRELEASE /boot/vmlinuz-$KRELEASE
- fi
- if [ $? -ne 0 ]; then
- do_failure "bootloader update exited with nonzero status"
- return 1
- fi
- might_success "initramfs created and bootloader updated"
return 0
}

View File

@ -1,108 +0,0 @@
commit ea5f10ba55fce68d1ed614ca33afdb38816f0830
Author: Frank Ch. Eigler <fche@redhat.com>
Date: Mon Nov 16 18:54:11 2020 -0500
PR26665: mokutil output parsing tweaks
We encountered secureboot keys in the wild that didn't live up
to the expectations of the current little state machine. Tweaked
regexps to accept Issuer: O= as well as Issuer: CN= lines. With
more verbosity, produces output on parsing process.
diff --git a/session.cxx b/session.cxx
index b5a8044..0437ca4 100644
--- a/session.cxx
+++ b/session.cxx
@@ -2859,6 +2859,9 @@ systemtap_session::get_mok_info()
// PR26665: but only Systemtap MOK keys; there may be others.
getline(out, line);
+ if (verbose > 3)
+ clog << "MOK parse state: " << state << " line: " << line << endl;
+
if (state == "SHA1") { // look for a new key fingerprint
if (! regexp_match(line, "^SHA1 Fingerprint: ([0-9a-f:]+)$", matches))
{
@@ -2871,11 +2874,14 @@ systemtap_session::get_mok_info()
}
// else stay in SHA1 state
} else if (state == "Issuer") { // validate issuer
- if (! regexp_match(line, "^[ \t]*Issuer: O=(.*)$", matches)) {
+ if (! regexp_match(line, "^[ \t]*Issuer: [A-Z]*=(.*)$", matches)) {
if (verbose > 2)
clog << "Issuer found: " << matches[1] << endl;
- if (! regexp_match(matches[1], "Systemtap", matches))
+ if (! regexp_match(matches[1], "Systemtap", matches)) {
+ if (verbose > 2)
+ clog << "Recognized Systemtap MOK fingerprint: " << fingerprint << endl;
mok_fingerprints.push_back(fingerprint);
+ }
state = "SHA1"; // start looking for another key
}
} else { // some other line in mokutil output ... there are plenty
commit 532eb9a1502026300a7f0b4bd287499101dd5803
Author: Frank Ch. Eigler <fche@redhat.com>
Date: Tue Nov 17 16:34:59 2020 -0500
PR26665 detect rhel8 (4.18) era kernel_is_locked_down() as procfs trigger
A different older kernel API needs to be probed for rhel8 era detection
of lockdown in effect. Added an (undocumented) $SYSTEMTAP_NOSIGN env
var to override automatic --use-server on lockdown, so that one can
inspect runtime/autoconf* operation locally, without stap-server.
diff --git a/buildrun.cxx b/buildrun.cxx
index 9b4066d..9c8e648 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -517,6 +517,7 @@ compile_pass (systemtap_session& s)
output_autoconf(s, o, cs, "autoconf-atomic_fetch_add_unless.c",
"STAPCONF_ATOMIC_FETCH_ADD_UNLESS", NULL);
output_autoconf(s, o, cs, "autoconf-lockdown-debugfs.c", "STAPCONF_LOCKDOWN_DEBUGFS", NULL);
+ output_autoconf(s, o, cs, "autoconf-lockdown-kernel.c", "STAPCONF_LOCKDOWN_KERNEL", NULL);
// used by runtime/linux/netfilter.c
output_exportconf(s, o2, "nf_register_hook", "STAPCONF_NF_REGISTER_HOOK");
diff --git a/runtime/linux/autoconf-lockdown-kernel.c b/runtime/linux/autoconf-lockdown-kernel.c
new file mode 100644
index 0000000..90c2414
--- /dev/null
+++ b/runtime/linux/autoconf-lockdown-kernel.c
@@ -0,0 +1,5 @@
+#include <linux/kernel.h>
+
+int foo(void) {
+ return kernel_is_locked_down("something");
+}
diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c
index bb4a98b..5795533 100644
--- a/runtime/transport/transport.c
+++ b/runtime/transport/transport.c
@@ -123,6 +123,12 @@ static int _stp_transport_fs_init(const char *module_name)
dbug_trans(1, "choosing procfs_p=1\n");
}
#endif
+#ifdef STAPCONF_LOCKDOWN_KERNEL
+ if (!debugfs_p && kernel_is_locked_down ("debugfs")) {
+ procfs_p = 1;
+ dbug_trans(1, "choosing procfs_p=1\n");
+ }
+#endif
if (!procfs_p) {
debugfs_p = 1;
dbug_trans(1, "choosing debugfs_p=1\n");
diff --git a/session.cxx b/session.cxx
index 0437ca4..36a4053 100644
--- a/session.cxx
+++ b/session.cxx
@@ -2804,7 +2804,9 @@ systemtap_session::modules_must_be_signed()
if (getenv("SYSTEMTAP_SIGN"))
return true;
-
+ if (getenv("SYSTEMTAP_NOSIGN"))
+ return false;
+
statm >> status;
if (status == 'Y')
return true;

View File

@ -1,63 +0,0 @@
commit 34e62f15da5adf06361ac66489936d0ffa1cc430
Author: Frank Ch. Eigler <fche@redhat.com>
Date: Tue Nov 10 22:13:53 2020 -0500
RHBZ1892179: handle exhausted stp_task_work structs
In utrace_report_syscall_entry and _exit, there is a possibility of
dereferencing a NULL pointer, in case __stp_utrace_alloc_task_work
exhausts UTRACE_TASK_WORK_POOL_SIZE live elements. While OOM is
still a possibility, this patch handles it more gracefully.
diff --git a/runtime/stp_utrace.c b/runtime/stp_utrace.c
index 47355de..e2880f1 100644
--- a/runtime/stp_utrace.c
+++ b/runtime/stp_utrace.c
@@ -2337,11 +2337,11 @@ static void utrace_report_syscall_entry(void *cb_data __attribute__ ((unused)),
/* Defer the report_syscall_entry work so it doesn't happen in atomic context: */
work = __stp_utrace_alloc_task_work(utrace, NULL);
- __stp_utrace_save_regs(work, regs);
if (work == NULL) {
_stp_error("Unable to allocate space for task_work");
return;
}
+ __stp_utrace_save_regs(work, regs);
stp_init_task_work(work, &utrace_syscall_entry_work);
rc = stp_task_work_add(task, work);
// stp_task_work_add() returns -ESRCH if the task has already
@@ -2444,11 +2444,11 @@ static void utrace_report_syscall_exit(void *cb_data __attribute__ ((unused)),
/* Defer the report_syscall_exit work so it doesn't happen in atomic context: */
work = __stp_utrace_alloc_task_work(utrace, NULL);
- __stp_utrace_save_regs(work, regs);
if (work == NULL) {
_stp_error("Unable to allocate space for task_work");
return;
}
+ __stp_utrace_save_regs(work, regs);
stp_init_task_work(work, &utrace_syscall_exit_work);
rc = stp_task_work_add(task, work);
// stp_task_work_add() returns -ESRCH if the task has already
commit 83cb271b390a1b36abd4c3aa69f89c466e99e253
Author: Frank Ch. Eigler <fche@redhat.com>
Date: Fri Nov 13 12:36:07 2020 -0500
RHBZ1892179: double default UTRACE_TASK_WORKPOOL
Some workloads were observed to exhaust the previous limit of 288.
diff --git a/runtime/stp_utrace.c b/runtime/stp_utrace.c
index 46ba489..6022267 100644
--- a/runtime/stp_utrace.c
+++ b/runtime/stp_utrace.c
@@ -141,7 +141,7 @@ struct __stp_utrace_task_work { /* NB: about 216 bytes, 18 per page: */
TODO: UTRACE_TASK_WORK_POOL_SIZE can be specified on the Systemtap
command line. Experiment to find the best default value. */
#ifndef UTRACE_TASK_WORK_POOL_SIZE
-#define UTRACE_TASK_WORK_POOL_SIZE 288
+#define UTRACE_TASK_WORK_POOL_SIZE 576
#endif
static DECLARE_BITMAP(__stp_utrace_task_work_pool_bitmap, UTRACE_TASK_WORK_POOL_SIZE);
static struct __stp_utrace_task_work __stp_utrace_task_work_pool[UTRACE_TASK_WORK_POOL_SIZE];

View File

@ -1,217 +0,0 @@
commit e3d03db82853049f65f16dc40c03f3f7f617ffb5
Author: Frank Ch. Eigler <fche@redhat.com>
Date: Sun Dec 13 21:05:23 2020 -0500
PR23512: fix staprun/stapio operation via less-than-root privileges
Commit 7615cae790c899bc8a82841c75c8ea9c6fa54df3 for PR26665 introduced
a regression in handling stapusr/stapdev/stapsys gid invocation of
staprun/stapio. This patch simplifies the relevant code in
staprun/ctl.c, init_ctl_channel(), to rely on openat/etc. to populate
and use the relay_basedir_fd as much as possible. Also, we now avoid
unnecessary use of access(), which was checking against the wrong
(real rather than effective) uid/gid.
diff --git a/staprun/ctl.c b/staprun/ctl.c
index 4be68af..da3417b 100644
--- a/staprun/ctl.c
+++ b/staprun/ctl.c
@@ -14,111 +14,70 @@
#define CTL_CHANNEL_NAME ".cmd"
+
+#ifndef HAVE_OPENAT
+#error "need openat"
+#endif
+
+
+// This function does multiple things:
+//
+// 1) if needed, open the running module's directory (the one that
+// contains .ctl), stash fd in relay_basedir_fd; this will be
+// passed to stapio children via -F$fd for privilege passing
+//
+// 2) (re)open the running module's .ctl file, stash fd in the
+// control_channel global; this will be used all over the place.
+//
+// Return 0 on success.
+//
+// See also PR14245, PR26665, RHBZ1902696 = PR23512
+//
int init_ctl_channel(const char *name, int verb)
{
- char buf[PATH_MAX] = ""; // the .ctl file name
- char buf2[PATH_MAX] = ""; // other tmp stuff
- struct statfs st;
-
(void) verb;
- if (0) goto out; /* just to defeat gcc warnings */
- /* Before trying to open the control channel, make sure it
- * isn't already open. */
- close_ctl_channel();
+ // Already got them both?
+ if (control_channel >= 0 && relay_basedir_fd >= 0)
+ return 0;
-#ifdef HAVE_OPENAT
- if (relay_basedir_fd >= 0) {
- strncpy(buf, CTL_CHANNEL_NAME, PATH_MAX - 1);
- control_channel = openat_cloexec(relay_basedir_fd,
- CTL_CHANNEL_NAME, O_RDWR, 0);
- dbug(2, "Opened %s (%d)\n", CTL_CHANNEL_NAME, control_channel);
+ // Need relay_basedir_fd .... ok try /sys/kernel/debug/systemtap/
+ if (relay_basedir_fd < 0) {
+ char buf[PATH_MAX] = "";
+ struct statfs st;
- /* NB: Extra real-id access check as below */
- if (faccessat(relay_basedir_fd, CTL_CHANNEL_NAME, R_OK|W_OK, 0) != 0){
- close(control_channel);
- return -5;
- }
- if (control_channel >= 0)
- goto out; /* It's OK to bypass the [f]access[at] check below,
- since this would only occur the *second* time
- staprun tries this gig, or within unprivileged stapio. */
+ if (sprintf_chk(buf, "/sys/kernel/debug/systemtap/%s", name))
+ return -EINVAL;
+
+ if (statfs("/sys/kernel/debug", &st) == 0 && (int)st.f_type == (int)DEBUGFS_MAGIC)
+ relay_basedir_fd = open (buf, O_DIRECTORY | O_RDONLY);
}
- /* PR14245, NB: we fall through to /sys ... /proc searching,
- in case the relay_basedir_fd option wasn't given (i.e., for
- early in staprun), or if errors out for some reason. */
-#endif
-
- // See if we have the .ctl file in debugfs
- if (sprintf_chk(buf2, "/sys/kernel/debug/systemtap/%s/%s",
- name, CTL_CHANNEL_NAME))
- return -1;
- if (statfs("/sys/kernel/debug", &st) == 0 && (int)st.f_type == (int)DEBUGFS_MAGIC &&
- (access (buf2, W_OK)==0)) {
- /* PR14245: allow subsequent operations, and if
- necessary, staprun->stapio forks, to reuse an fd for
- directory lookups (even if some parent directories have
- perms 0700. */
- strcpy(buf, buf2); // committed
+ // Still need relay_basedir_fd ... ok try /proc/systemtap/
+ if (relay_basedir_fd < 0) {
+ char buf[PATH_MAX] = "";
-#ifdef HAVE_OPENAT
- if (! sprintf_chk(buf2, "/sys/kernel/debug/systemtap/%s", name)) {
- relay_basedir_fd = open (buf2, O_DIRECTORY | O_RDONLY);
- }
-#endif
- }
-
- // PR26665: try /proc/systemtap/... also
- // (STP_TRANSPORT_1 used to use this for other purposes.)
- if (sprintf_chk(buf2, "/proc/systemtap/%s/%s",
- name, CTL_CHANNEL_NAME))
- return -1;
- if (relay_basedir_fd < 0 && (access(buf2, W_OK)==0)) {
- strcpy(buf, buf2); // committed
+ if (sprintf_chk(buf, "/proc/systemtap/%s", name))
+ return -EINVAL;
-#ifdef HAVE_OPENAT
- if (! sprintf_chk(buf2, "/proc/systemtap/%s", name)) {
- relay_basedir_fd = open (buf2, O_DIRECTORY | O_RDONLY);
- }
-#endif
+ relay_basedir_fd = open (buf, O_DIRECTORY | O_RDONLY);
}
- /* At this point, we have buf, which is the full path to the .ctl file,
- and we may have a relay_basedir_fd, which is useful to pass across
- staprun->stapio fork/execs. */
-
- control_channel = open_cloexec(buf, O_RDWR, 0);
- dbug(2, "Opened %s (%d)\n", buf, control_channel);
-
- /* NB: Even if open() succeeded with effective-UID permissions, we
- * need the access() check to make sure real-UID permissions are also
- * sufficient. When we run under the setuid staprun, effective and
- * real UID may not be the same. Specifically, we want to prevent
- * a local stapusr from trying to attach to a different stapusr's module.
- *
- * The access() is done *after* open() to avoid any TOCTOU-style race
- * condition. We believe it's probably safe either way, as the file
- * we're trying to access connot be modified by a typical user, but
- * better safe than sorry.
- */
-#ifdef HAVE_OPENAT
- if (control_channel >= 0 && relay_basedir_fd >= 0) {
- if (faccessat (relay_basedir_fd, CTL_CHANNEL_NAME, R_OK|W_OK, 0) == 0)
- goto out;
- /* else fall through */
+ // Got relay_basedir_fd, need .ctl
+ if (relay_basedir_fd >= 0) {
+ // verify that the ctl file is accessible to our real uid/gid
+ if (faccessat(relay_basedir_fd, CTL_CHANNEL_NAME, R_OK|W_OK, 0) != 0)
+ return -EPERM;
+
+ control_channel = openat_cloexec(relay_basedir_fd,
+ CTL_CHANNEL_NAME, O_RDWR, 0);
}
-#endif
- if (control_channel >= 0 && access(buf, R_OK|W_OK) != 0) {
- close(control_channel);
- return -5;
- }
-out:
- if (control_channel < 0) {
+ // Fell through
+ if (relay_basedir_fd < 0 || control_channel < 0) {
err(_("Cannot attach to module %s control channel; not running?\n"),
name);
- return -3;
+ return -EINVAL;
}
return 0;
}
commit 1120422c2822be9e00d8d11cab3fb381d2ce0cce
Author: Frank Ch. Eigler <fche@redhat.com>
Date: Sun Dec 13 21:19:15 2020 -0500
PR27067 <<< corrected bug# for previous commit
commit cd5b72a538a404011d27d86ff958355ac2c45b8d
Author: Frank Ch. Eigler <fche@redhat.com>
Date: Sun Jan 24 14:45:54 2021 -0500
PR27067: set procfs traceNN files' uid/gid too
commit e3d03db828 neglected to include the proper calls to set the
procfs traceNN files to the correct uid/gid ownership. With those
files left as uid/gid=0/0, stapio running with a user with
stapusr/stapdev privileges couldn't fopenat() those files. Now they
can again. This problem became obvious after commit 4706ab3ca5c0,
which makes STAP_TRANS_PROCFS the default.
diff --git a/runtime/transport/procfs.c b/runtime/transport/procfs.c
index 97a6e123a..69591a235 100644
--- a/runtime/transport/procfs.c
+++ b/runtime/transport/procfs.c
@@ -336,12 +336,14 @@ __stp_procfs_relay_create_buf_file_callback(const char *filename,
if (parent != _stp_procfs_module_dir_path.dentry)
goto out;
- pde = proc_create (filename, 0600,
+ pde = proc_create (filename, 0400,
_stp_procfs_module_dir,
& relay_procfs_operations);
if (pde == NULL)
goto out;
+ proc_set_user(pde, KUIDT_INIT(_stp_uid), KGIDT_INIT(_stp_gid));
+
rc = snprintf(fullpath, sizeof(fullpath), "/proc/systemtap/%s/%s",
THIS_MODULE->name, filename);

File diff suppressed because it is too large Load Diff

View File

@ -1,44 +0,0 @@
commit e3287bddcdc51705bb206479daa82e97fb28071f
Author: Frank Ch. Eigler <fche@redhat.com>
Date: Wed Dec 9 22:29:43 2020 -0500
PR27044: fix lock loop for conditional probes
Emit a nested block carefully so that the "goto out;" from a failed
stp_lock_probe() call in that spot near the epilogue of a
probe-handler goes downward, not upward.
diff --git a/translate.cxx b/translate.cxx
index f0195486c..d7fe1e3b2 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -2969,21 +2969,21 @@ c_unparser::emit_probe (derived_probe* v)
{
// PR26296
// emit all read/write locks for global variables ... if somehow still not done by now
+ // emit a local out: label, for error catching in these condition exprs
+ o->newline() << "{";
+ o->newline(1) << "__label__ out, deref_fault;";
if (v->needs_global_locks ())
emit_lock ();
for (set<derived_probe*>::const_iterator
- it = v->probes_with_affected_conditions.begin();
- it != v->probes_with_affected_conditions.end(); ++it)
+ it = v->probes_with_affected_conditions.begin();
+ it != v->probes_with_affected_conditions.end(); ++it)
{
- // emit a local out: label, for error catching in these condition exprs
- o->newline() << "{";
- o->newline(1) << "__label__ out, deref_fault;";
emit_probe_condition_update(*it);
- o->newline(-1) << "deref_fault: __attribute__((unused));";
- o->newline() << "out: __attribute__((unused));";
- o->newline() << "}";
}
+ o->newline(-1) << "deref_fault: __attribute__((unused));";
+ o->newline() << "out: __attribute__((unused));";
+ o->newline() << "}";
}
// PR26296

View File

@ -1,168 +0,0 @@
commit 175f2b06805bb79d6994c5c909b741c8dcba3528
Author: Sultan Alsawaf <sultan@openresty.com>
Date: Fri Jan 22 15:19:33 2021 -0800
runtime: utilize relay subbufs as much as possible
The relay subbufs used for printing are used very inefficiently, causing
print messages to be frequently dropped. The cause for this inefficiency
is that every time a print flush occurs, the current subbuf is switched
out even if it isn't filled. We can't wait for a subbuf to fill up
before switching it out either, or messages will be delayed.
To remedy this, we instead check to see if there's any data in any
subbuf and use that as an indicator to staprun to tell if there's data
available to read. Then when staprun attempts to read the data out, we
can switch out the current subbuf if it has data in it. This lets us
squeeze out every bit of storage from the subbufs.
Any print drops experienced after this patch should be fixed by
increasing the subbuf count (_stp_nsubbufs).
diff --git a/runtime/transport/procfs.c b/runtime/transport/procfs.c
index a365db6f2..97a6e123a 100644
--- a/runtime/transport/procfs.c
+++ b/runtime/transport/procfs.c
@@ -235,14 +235,16 @@ static int _stp_procfs_transport_fs_init(const char *module_name)
{
#ifdef STAPCONF_PROC_OPS
relay_procfs_operations.proc_open = relay_file_operations.open;
- relay_procfs_operations.proc_poll = relay_file_operations.poll;
+ relay_procfs_operations.proc_poll = __stp_relay_file_poll;
relay_procfs_operations.proc_mmap = relay_file_operations.mmap;
- relay_procfs_operations.proc_read = relay_file_operations.read;
+ relay_procfs_operations.proc_read = __stp_relay_file_read;
relay_procfs_operations.proc_lseek = relay_file_operations.llseek;
relay_procfs_operations.proc_release = relay_file_operations.release;
#else
relay_procfs_operations = relay_file_operations;
relay_procfs_operations.owner = THIS_MODULE;
+ relay_procfs_operations.poll = __stp_relay_file_poll;
+ relay_procfs_operations.read = __stp_relay_file_read;
#endif
if (_stp_mkdir_proc_module()) // get the _stp_procfs_module_dir* created
diff --git a/runtime/transport/relay_v2.c b/runtime/transport/relay_v2.c
index 27729f4c8..3b505c992 100644
--- a/runtime/transport/relay_v2.c
+++ b/runtime/transport/relay_v2.c
@@ -77,14 +77,6 @@ static size_t __stp_relay_switch_subbuf(struct rchan_buf *buf, size_t length)
buf->dentry->d_inode->i_size += buf->chan->subbuf_size -
buf->padding[old_subbuf];
smp_mb();
- if (waitqueue_active(&buf->read_wait))
- /*
- * Calling wake_up_interruptible() and __mod_timer()
- * from here will deadlock if we happen to be logging
- * from the scheduler and timer (trying to re-grab
- * rq->lock/timer->base->lock), so just set a flag.
- */
- atomic_set(&_stp_relay_data.wakeup, 1);
}
old = buf->data;
@@ -101,10 +93,56 @@ static size_t __stp_relay_switch_subbuf(struct rchan_buf *buf, size_t length)
return length;
}
+static bool __stp_relay_buf_empty(struct rchan_buf *buf)
+{
+ return !buf->offset && buf->subbufs_produced == buf->subbufs_consumed;
+}
+
+static unsigned int __stp_relay_file_poll(struct file *filp, poll_table *wait)
+{
+ struct rchan_buf *buf = filp->private_data;
+
+ if (buf->finalized)
+ return POLLERR;
+
+ if (filp->f_mode & FMODE_READ) {
+ poll_wait(filp, &buf->read_wait, wait);
+ if (!__stp_relay_buf_empty(buf))
+ return POLLIN | POLLRDNORM;
+ }
+
+ return 0;
+}
+
+static ssize_t __stp_relay_file_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ struct rchan_buf *buf = filp->private_data;
+ unsigned long flags;
+
+ /* This trylock will only fail after the print driver is destroyed */
+ if (_stp_print_trylock_irqsave(&flags)) {
+ /* Switch out the current buffer if it has any data */
+ if (buf->offset)
+ __stp_relay_switch_subbuf(buf, 0);
+ _stp_print_unlock_irqrestore(&flags);
+ }
+
+ /*
+ * Optimization: bail out early if there's nothing to read. This is
+ * faster than going into relay's read() function without having any
+ * data, as it will acquire a mutex lock for the inode before bailing.
+ */
+ if (buf->subbufs_produced == buf->subbufs_consumed)
+ return -ENODATA;
+
+ return relay_file_operations.read(filp, buffer, count, ppos);
+}
+
static void __stp_relay_wakeup_readers(struct rchan_buf *buf)
{
if (buf && waitqueue_active(&buf->read_wait) &&
- buf->subbufs_produced != buf->subbufs_consumed)
+ !__stp_relay_buf_empty(buf))
wake_up_interruptible(&buf->read_wait);
}
@@ -112,10 +150,9 @@ static void __stp_relay_wakeup_timer(stp_timer_callback_parameter_t unused)
{
int i;
- if (atomic_read(&_stp_relay_data.wakeup)) {
+ if (atomic_cmpxchg(&_stp_relay_data.wakeup, 1, 0)) {
struct rchan_buf *buf;
- atomic_set(&_stp_relay_data.wakeup, 0);
for_each_possible_cpu(i) {
buf = _stp_get_rchan_subbuf(_stp_relay_data.rchan->buf,
i);
@@ -266,6 +303,8 @@ static int _stp_transport_data_fs_init(void)
}
relay_file_operations_w_owner = relay_file_operations;
relay_file_operations_w_owner.owner = THIS_MODULE;
+ relay_file_operations_w_owner.poll = __stp_relay_file_poll;
+ relay_file_operations_w_owner.read = __stp_relay_file_read;
#if (RELAYFS_CHANNEL_VERSION >= 7)
_stp_relay_data.rchan = relay_open("trace", _stp_get_module_dir(),
_stp_subbuf_size, _stp_nsubbufs,
@@ -323,10 +362,12 @@ _stp_data_write_reserve(size_t size_request, void **entry)
buf = _stp_get_rchan_subbuf(_stp_relay_data.rchan->buf,
smp_processor_id());
- if (unlikely(buf->offset + size_request > buf->chan->subbuf_size)) {
+ if (buf->offset >= buf->chan->subbuf_size) {
size_request = __stp_relay_switch_subbuf(buf, size_request);
if (!size_request)
return 0;
+ } else if (buf->offset + size_request > buf->chan->subbuf_size) {
+ size_request = buf->chan->subbuf_size - buf->offset;
}
*entry = (char*)buf->data + buf->offset;
buf->offset += size_request;
@@ -342,10 +383,6 @@ static unsigned char *_stp_data_entry_data(void *entry)
static int _stp_data_write_commit(void *entry)
{
- struct rchan_buf *buf;
-
- buf = _stp_get_rchan_subbuf(_stp_relay_data.rchan->buf,
- smp_processor_id());
- __stp_relay_switch_subbuf(buf, 0);
+ atomic_set(&_stp_relay_data.wakeup, 1);
return 0;
}

View File

@ -10,7 +10,7 @@
%{!?with_crash: %global with_crash 1}
%endif
%{!?with_rpm: %global with_rpm 1}
%{!?elfutils_version: %global elfutils_version 0.142}
%{!?elfutils_version: %global elfutils_version 0.179}
%{!?pie_supported: %global pie_supported 1}
%{!?with_boost: %global with_boost 0}
%ifarch %{ix86} x86_64 ppc ppc64 ppc64le aarch64
@ -22,6 +22,7 @@
%{!?with_systemd: %global with_systemd 0%{?fedora} >= 19 || 0%{?rhel} >= 7}
%{!?with_emacsvim: %global with_emacsvim 0%{?fedora} >= 19 || 0%{?rhel} >= 7}
%{!?with_java: %global with_java 0%{?fedora} >= 19 || 0%{?rhel} >= 7}
%{!?with_debuginfod: %global with_debuginfod 0%{?fedora} >= 25 || 0%{?rhel} >= 7}
%{!?with_virthost: %global with_virthost 0%{?fedora} >= 19 || 0%{?rhel} >= 7}
%{!?with_virtguest: %global with_virtguest 1}
%{!?with_dracut: %global with_dracut 0%{?fedora} >= 19 || 0%{?rhel} >= 6}
@ -88,8 +89,8 @@
%define __brp_mangle_shebangs_exclude_from .stp$
Name: systemtap
Version: 4.4
Release: 10%{?release_override}%{?dist}
Version: 4.5
Release: 1%{?release_override}%{?dist}
# for version, see also configure.ac
@ -125,21 +126,16 @@ License: GPLv2+
URL: http://sourceware.org/systemtap/
Source: ftp://sourceware.org/pub/systemtap/releases/systemtap-%{version}.tar.gz
Patch1: rhbz1873492.patch
Patch2: rhbz1898288.patch
Patch3: rhbz1902696.patch
Patch4: rhbz1908904.patch
Patch5: rhbz1906662.patch
Patch6: rhbz1650594.patch
Patch7: rhbz1914948.patch
# Build*
BuildRequires: make
BuildRequires: gcc-c++
BuildRequires: cpio
BuildRequires: gettext-devel
BuildRequires: pkgconfig(nss)
BuildRequires: pkgconfig(avahi-client)
%if %{with_debuginfod}
BuildRequires: pkgconfig(libdebuginfod)
%endif
%if %{with_dyninst}
BuildRequires: dyninst-devel >= 10.0
BuildRequires: pkgconfig(libselinux)
@ -170,9 +166,6 @@ BuildRequires: /usr/bin/latex /usr/bin/dvips /usr/bin/ps2pdf
%if 0%{?fedora} >= 18 || 0%{?rhel} >= 7
BuildRequires: tex(fullpage.sty) tex(fancybox.sty) tex(bchr7t.tfm) tex(graphicx.sty)
%endif
# For the html.sty mentioned in the .tex files, even though latex2html is
# not run during the build, only during manual scripts/update-docs runs:
BuildRequires: latex2html
%if %{with_htmldocs}
# On F10, xmlto's pdf support was broken off into a sub-package,
# called 'xmlto-tex'. To avoid a specific F10 BuildReq, we'll do a
@ -184,7 +177,7 @@ BuildRequires: xmlto /usr/share/xmlto/format/fo/pdf
BuildRequires: emacs
%endif
%if %{with_java}
BuildRequires: jpackage-utils java-devel
BuildRequires: java-devel
%endif
%if %{with_virthost}
# BuildRequires: libvirt-devel >= 1.0.2
@ -271,6 +264,9 @@ Requires: kernel-devel-uname-r
%endif
Requires: gcc make
# for compiling --runtime=dyninst sripts, need elfutils headers, bz1930973
Requires: elfutils-devel >= %{elfutils_version}
Conflicts: systemtap-client < %{version}-%{release}
Conflicts: systemtap-server < %{version}-%{release}
Conflicts: systemtap-runtime < %{version}-%{release}
@ -374,7 +370,16 @@ Requires: systemtap = %{version}-%{release}
Requires: systemtap-sdt-devel = %{version}-%{release}
Requires: systemtap-server = %{version}-%{release}
Requires: dejagnu which elfutils grep nc
%if %{with_debuginfod}
Requires: elfutils-debuginfod
%endif
# work around fedora ci gating kvetching about i686<->x86-64 conflicts
%ifarch x86_64
Conflicts: systemtap-testsuite = %{version}-%{release}.i686
%endif
%ifarch i686
Conflicts: systemtap-testsuite = %{version}-%{release}.x86_64
%endif
Requires: gcc gcc-c++ make glibc-devel
# testsuite/systemtap.base/ptrace.exp needs strace
Requires: strace
@ -405,7 +410,12 @@ Requires: systemtap-runtime-python2 = %{version}-%{release}
Requires: systemtap-runtime-python3 = %{version}-%{release}
%endif
%ifarch x86_64
%if 0%{?rhel} >= 8 || 0%{?fedora} >= 20
# fweimer, personal correspondence
Recommends: glibc-devel(x86-32)
%else
Requires: /usr/lib/libc.so
%endif
# ... and /usr/lib/libgcc_s.so.*
# ... and /usr/lib/libstdc++.so.*
%endif
@ -429,6 +439,13 @@ Summary: Systemtap Java Runtime Support
License: GPLv2+
URL: http://sourceware.org/systemtap/
Requires: systemtap-runtime = %{version}-%{release}
# work around fedora ci gating kvetching about i686<->x86-64 conflicts
%ifarch x86_64
Conflicts: systemtap-runtime = %{version}-%{release}.i686
%endif
%ifarch i686
Conflicts: systemtap-runtime = %{version}-%{release}.x86_64
%endif
Requires: byteman > 2.0
Requires: iproute
Requires: java-devel
@ -519,13 +536,6 @@ systemtap-runtime-virthost machine to execute systemtap scripts.
%prep
%setup -q
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%build
@ -543,6 +553,13 @@ systemtap-runtime-virthost machine to execute systemtap scripts.
%global sqlite_config --disable-sqlite
%endif
%if %{with_debuginfod}
%global debuginfod_config --with-debuginfod
%else
%global debuginfod_config --without-debuginfod
%endif
# Enable/disable the crash extension
%if %{with_crash}
%global crash_config --enable-crash
@ -624,7 +641,7 @@ systemtap-runtime-virthost machine to execute systemtap scripts.
# We don't ship compileworthy python code, just oddball samples
%global py_auto_byte_compile 0
%configure %{dyninst_config} %{sqlite_config} %{crash_config} %{docs_config} %{pie_config} %{rpm_config} %{java_config} %{virt_config} %{dracut_config} %{python3_config} %{python2_probes_config} %{python3_probes_config} %{httpd_config} %{bpf_config} --disable-silent-rules --with-extra-version="rpm %{version}-%{release}"
%configure %{dyninst_config} %{sqlite_config} %{crash_config} %{docs_config} %{pie_config} %{rpm_config} %{java_config} %{virt_config} %{dracut_config} %{python3_config} %{python2_probes_config} %{python3_probes_config} %{httpd_config} %{bpf_config} %{debuginfod_config} --disable-silent-rules --with-extra-version="rpm %{version}-%{release}"
make %{?_smp_mflags}
@ -964,60 +981,8 @@ exit 0
# ------------------------------------------------------------------------
%if %{with_java}
%triggerin runtime-java -- java-1.8.0-openjdk, java-1.7.0-openjdk, java-1.6.0-openjdk
for f in %{_libexecdir}/systemtap/libHelperSDT_*.so; do
%ifarch %{ix86}
arch=i386
%else
arch=`basename $f | cut -f2 -d_ | cut -f1 -d.`
%endif
for archdir in %{_jvmdir}/*openjdk*/jre/lib/${arch}; do
if [ -d ${archdir} ]; then
ln -sf %{_libexecdir}/systemtap/libHelperSDT_${arch}.so ${archdir}/libHelperSDT_${arch}.so
ln -sf %{_libexecdir}/systemtap/HelperSDT.jar ${archdir}/../ext/HelperSDT.jar
fi
done
done
%triggerun runtime-java -- java-1.8.0-openjdk, java-1.7.0-openjdk, java-1.6.0-openjdk
for f in %{_libexecdir}/systemtap/libHelperSDT_*.so; do
%ifarch %{ix86}
arch=i386
%else
arch=`basename $f | cut -f2 -d_ | cut -f1 -d.`
%endif
for archdir in %{_jvmdir}/*openjdk*/jre/lib/${arch}; do
rm -f ${archdir}/libHelperSDT_${arch}.so
rm -f ${archdir}/../ext/HelperSDT.jar
done
done
%triggerpostun runtime-java -- java-1.8.0-openjdk, java-1.7.0-openjdk, java-1.6.0-openjdk
# Restore links for any JDKs remaining after a package removal:
for f in %{_libexecdir}/systemtap/libHelperSDT_*.so; do
%ifarch %{ix86}
arch=i386
%else
arch=`basename $f | cut -f2 -d_ | cut -f1 -d.`
%endif
for archdir in %{_jvmdir}/*openjdk*/jre/lib/${arch}; do
if [ -d ${archdir} ]; then
ln -sf %{_libexecdir}/systemtap/libHelperSDT_${arch}.so ${archdir}/libHelperSDT_${arch}.so
ln -sf %{_libexecdir}/systemtap/HelperSDT.jar ${archdir}/../ext/HelperSDT.jar
fi
done
done
# XXX: analogous support for other types of JRE/JDK??
%endif
# ------------------------------------------------------------------------
%files
# The master "systemtap" rpm doesn't include any files.
# The main "systemtap" rpm doesn't include any files.
%files server -f systemtap.lang
%{_bindir}/stap-server
@ -1071,7 +1036,7 @@ done
%license COPYING
%if %{with_java}
%dir %{_libexecdir}/systemtap
%{_libexecdir}/systemtap/libHelperSDT_*.so
%{_libexecdir}/systemtap/libHelperSDT.so
%endif
%if %{with_emacsvim}
%{_emacs_sitelispdir}/*.el*
@ -1191,7 +1156,7 @@ done
%if %{with_java}
%files runtime-java
%dir %{_libexecdir}/systemtap
%{_libexecdir}/systemtap/libHelperSDT_*.so
%{_libexecdir}/systemtap/libHelperSDT.so
%{_libexecdir}/systemtap/HelperSDT.jar
%{_libexecdir}/systemtap/stapbm
%endif
@ -1245,8 +1210,8 @@ done
# PRERELEASE
%changelog
* Fri Mar 05 2021 Frank Ch. Eigler <fche@redhat.com> - 4.4-10
- rhbz1914948 use subbufs better in transport to avoid msg loss
* Fri May 07 2021 Frank Ch. Eigler <fche@redhat.com> - 4.5-1
- Upstream release.
* Tue Jan 26 2021 Frank Ch. Eigler <fche@redhat.com> - 4.4-9
- rhbz1927497 enable debuginfod client for buildid probing