import gcc-toolset-10-systemtap-4.4-5.el8

This commit is contained in:
CentOS Sources 2021-05-18 02:49:22 -04:00 committed by Andrew Lukoshko
parent 15a4c477c8
commit cdbf6be4b0
11 changed files with 3355 additions and 2290 deletions

View File

@ -1 +1 @@
14769266f6591b85895a5f40e516f8228e83476e SOURCES/systemtap-4.3.tar.gz
f126888adda90a0ec57f43f9db20fde68c8ef356 SOURCES/systemtap-4.4.tar.gz

2
.gitignore vendored
View File

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

55
SOURCES/rhbz1650594.patch Normal file
View File

@ -0,0 +1,55 @@
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
}

File diff suppressed because it is too large Load Diff

View File

@ -1,874 +0,0 @@
commit 0a281a96ddf7cae9a0f0cc0eb505a752ffdd932e
Author: William Cohen <wcohen@redhat.com>
Date: Tue Jun 16 16:02:11 2020 -0400
Make sizeof.stp runnable with the bpf backend.
diff --git a/testsuite/systemtap.examples/general/sizeof.meta b/testsuite/systemtap.examples/general/sizeof.meta
index 29713e4..b30078d 100644
--- a/testsuite/systemtap.examples/general/sizeof.meta
+++ b/testsuite/systemtap.examples/general/sizeof.meta
@@ -2,7 +2,7 @@ title: Print the Size of a C Type
name: sizeof.stp
version: 1.0
author: anonymous
-keywords: statistics memory
+keywords: statistics memory bpf
subsystem: any
status: proposed
exit: event-ended
@@ -11,3 +11,5 @@ scope: system-wide
description: This script prints the size of a type, based on dwarf debuginfo for any kernel or userspace module, or trial-compilation of a given header file name.
test_check: stap -p4 sizeof.stp task_struct 'kernel<include/linux/sched.h>'
test_installcheck: stap sizeof.stp FILE '</usr/include/stdio.h>'
+test_check_bpf: stap -p4 --bpf sizeof.stp task_struct 'kernel<include/linux/sched.h>'
+test_installcheck_bpf: stap --bpf sizeof.stp FILE '</usr/include/stdio.h>'
diff --git a/testsuite/systemtap.examples/general/sizeof.stp b/testsuite/systemtap.examples/general/sizeof.stp
index 0c77dce..5aec674 100755
--- a/testsuite/systemtap.examples/general/sizeof.stp
+++ b/testsuite/systemtap.examples/general/sizeof.stp
@@ -7,9 +7,11 @@
# sizeof.stp TYPENAME </usr/include/someheader.h>
probe oneshot {
- println("type ", @1,
- %( $# > 1 %? " in ", @2, %) /* module or header file name */
- " byte-size: ",
- %( $# > 1 %? @cast_module_sizeof(@2, @1) %: @cast_sizeof(@1) %)
- )
+ %( $# > 1 %?
+ printf("type %s in %s byte-size: %d\n", @1, @2,
+ @cast_module_sizeof(@2, @1))
+ %:
+ printf("type %s byte-size: %d\n", @1,
+ @cast_sizeof(@1))
+ %)
}
commit 2b2b6a622dc1d434c60d0ea159b260f660068ad1
Author: William Cohen <wcohen@redhat.com>
Date: Wed Jun 17 11:57:18 2020 -0400
Fix sizeof.stp to explicitly use kernel debuginfo if one not specified
Commit 00ee19ff030f665df7e087a579f39105256a0253 changed how @cast()
operations work and they no longer default to using the kernel
debuginfo for type information. Need to use the @cast_module_sizeof()
instead of @cast_size() to use the kernel debuginfo.
diff --git a/testsuite/systemtap.examples/general/sizeof.stp b/testsuite/systemtap.examples/general/sizeof.stp
index 5aec674..b45f593 100755
--- a/testsuite/systemtap.examples/general/sizeof.stp
+++ b/testsuite/systemtap.examples/general/sizeof.stp
@@ -12,6 +12,6 @@ probe oneshot {
@cast_module_sizeof(@2, @1))
%:
printf("type %s byte-size: %d\n", @1,
- @cast_sizeof(@1))
+ @cast_module_sizeof("kernel", @1))
%)
}
commit 717b7dddd08b66b3caa5585221472d84e40be658
Author: William Cohen <wcohen@redhat.com>
Date: Wed Jun 17 13:08:30 2020 -0400
Use explicit @cast() operators to fslatency-nd.stp and fsslower-nd.stp
Commit 00ee19ff030f665df7e087a579f39105256a0253 changed how @cast()
operations work and they no longer default to using the kernel
debuginfo for type information. Need to include kernel as location for
this information for the @cast() rather than just assuming a default.
diff --git a/testsuite/systemtap.examples/lwtools/fslatency-nd.stp b/testsuite/systemtap.examples/lwtools/fslatency-nd.stp
index 6008399..0bee34f 100755
--- a/testsuite/systemtap.examples/lwtools/fslatency-nd.stp
+++ b/testsuite/systemtap.examples/lwtools/fslatency-nd.stp
@@ -63,8 +63,8 @@ probe __vfs_read = kprobe.function("__vfs_read")
{
# Skip the call if new_sync_read() wouldn't be called.
file = pointer_arg(1)
- if (!file || @cast(file, "file")->f_op->read
- || !@cast(file, "file")->f_op->read_iter)
+ if (!file || @cast(file, "file", "kernel")->f_op->read
+ || !@cast(file, "file", "kernel")->f_op->read_iter)
next
}
@@ -75,8 +75,8 @@ probe __vfs_write = kprobe.function("__vfs_write")
{
# Skip the call if new_sync_write() wouldn't be called.
file = pointer_arg(1)
- if (!file || @cast(file, "file")->f_op->write
- || !@cast(file, "file")->f_op->write_iter)
+ if (!file || @cast(file, "file", "kernel")->f_op->write
+ || !@cast(file, "file", "kernel")->f_op->write_iter)
next
}
@@ -102,8 +102,8 @@ probe __vfs_read.return = kprobe.function("__vfs_read").return
{
# Skip the call if new_sync_read() wouldn't be called.
file = @entry(pointer_arg(1))
- if (!file || @cast(file, "file")->f_op->read
- || !@cast(file, "file")->f_op->read_iter)
+ if (!file || @cast(file, "file", "kernel")->f_op->read
+ || !@cast(file, "file", "kernel")->f_op->read_iter)
next
}
@@ -115,8 +115,8 @@ probe __vfs_write.return = kprobe.function("__vfs_write")
{
# Skip the call if new_sync_write() wouldn't be called.
file = pointer_arg(1)
- if (!file || @cast(file, "file")->f_op->write
- || !@cast(file, "file")->f_op->write_iter)
+ if (!file || @cast(file, "file", "kernel")->f_op->write
+ || !@cast(file, "file", "kernel")->f_op->write_iter)
next
}
diff --git a/testsuite/systemtap.examples/lwtools/fsslower-nd.stp b/testsuite/systemtap.examples/lwtools/fsslower-nd.stp
index 64abe41..90fa9b5 100755
--- a/testsuite/systemtap.examples/lwtools/fsslower-nd.stp
+++ b/testsuite/systemtap.examples/lwtools/fsslower-nd.stp
@@ -65,8 +65,8 @@ probe __vfs_read = kprobe.function("__vfs_read")
{
# Skip the call if new_sync_read() wouldn't be called.
file = pointer_arg(1)
- if (!file || @cast(file, "file")->f_op->read
- || !@cast(file, "file")->f_op->read_iter)
+ if (!file || @cast(file, "file", "kernel")->f_op->read
+ || !@cast(file, "file", "kernel")->f_op->read_iter)
next
}
@@ -77,8 +77,8 @@ probe __vfs_write = kprobe.function("__vfs_write")
{
# Skip the call if new_sync_write() wouldn't be called.
file = pointer_arg(1)
- if (!file || @cast(file, "file")->f_op->write
- || !@cast(file, "file")->f_op->write_iter)
+ if (!file || @cast(file, "file", "kernel")->f_op->write
+ || !@cast(file, "file", "kernel")->f_op->write_iter)
next
}
@@ -110,8 +110,8 @@ probe __vfs_read.return = kprobe.function("__vfs_read").return
{
# Skip the call if new_sync_read() wouldn't be called.
file = @entry(pointer_arg(1))
- if (!file || @cast(file, "file")->f_op->read
- || !@cast(file, "file")->f_op->read_iter)
+ if (!file || @cast(file, "file", "kernel")->f_op->read
+ || !@cast(file, "file", "kernel")->f_op->read_iter)
next
}
@@ -123,7 +123,7 @@ probe __vfs_write.return = kprobe.function("__vfs_write")
{
# Skip the call if new_sync_write() wouldn't be called.
file = pointer_arg(1)
- if (!file || @cast(file, "file")->f_op->write
- || !@cast(file, "file")->f_op->write_iter)
+ if (!file || @cast(file, "file", "kernel")->f_op->write
+ || !@cast(file, "file", "kernel")->f_op->write_iter)
next
}
commit 9eb37102d48b814821b7f474986a7bfe86784192
Author: William Cohen <wcohen@redhat.com>
Date: Wed Jun 17 13:39:20 2020 -0400
Use explicit @cast() operators for pfiles.stp and ioctl_handler.stp
Commit 00ee19ff030f665df7e087a579f39105256a0253 changed how @cast()
operations work and they no longer default to using the kernel
debuginfo for type information. Need to include kernel as location for
this information for the @cast() rather than just assuming a default.
diff --git a/testsuite/systemtap.examples/process/pfiles.stp b/testsuite/systemtap.examples/process/pfiles.stp
index d52a154..6344a4c 100755
--- a/testsuite/systemtap.examples/process/pfiles.stp
+++ b/testsuite/systemtap.examples/process/pfiles.stp
@@ -787,9 +787,9 @@ function print_unix_socket(sock) {
strlen(peername) > 0 ? peername . "\n" : "")
try { # skip line in case of null pointers
printf(" peercred pid: %d\n",
- @defined(@cast(sock, "socket")->sk->sk_peer_pid) ?
- @cast(sock, "socket")->sk->sk_peer_pid->numbers[0]->nr :
- @cast(sock, "socket")->sk->sk_peercred->pid ); } catch { }
+ @defined(@cast(sock, "socket", "kernel")->sk->sk_peer_pid) ?
+ @cast(sock, "socket", "kernel")->sk->sk_peer_pid->numbers[0]->nr :
+ @cast(sock, "socket", "kernel")->sk->sk_peercred->pid ); } catch { }
}
function print_ipv4_socket(sock) {
diff --git a/testsuite/systemtap.examples/profiling/ioctl_handler.stp b/testsuite/systemtap.examples/profiling/ioctl_handler.stp
index 7044185..6f1e52c 100755
--- a/testsuite/systemtap.examples/profiling/ioctl_handler.stp
+++ b/testsuite/systemtap.examples/profiling/ioctl_handler.stp
@@ -9,7 +9,7 @@ probe syscall.ioctl {
ioctl_requests[execname()] <<< 1
try {
# Dig down through the task struct to find the actual function handling ioctl.
- ioctl_func_address = @cast(task_current(), "struct task_struct")->files->fdt->fd[fd]->f_op->unlocked_ioctl
+ ioctl_func_address = @cast(task_current(), "struct task_struct", "kernel")->files->fdt->fd[fd]->f_op->unlocked_ioctl
if (ioctl_func_address)
ioctl_func[execname(), ioctl_func_address] <<< 1
} catch {
commit 3040d4e8ddb6a9b1d1a57a0185206498670c3f1a
Author: William Cohen <wcohen@redhat.com>
Date: Wed Jun 17 13:53:58 2020 -0400
Use explicit @cast() operators for stapgames/pingpong.stp tapset.
diff --git a/testsuite/systemtap.examples/stapgames/tapset/gmtty.stp b/testsuite/systemtap.examples/stapgames/tapset/gmtty.stp
index 026e4a9..f6ad2db 100644
--- a/testsuite/systemtap.examples/stapgames/tapset/gmtty.stp
+++ b/testsuite/systemtap.examples/stapgames/tapset/gmtty.stp
@@ -10,12 +10,12 @@ global GM_tty_ws_row, GM_tty_ws_col, GM_tty_name
# Initialize current TTY -- must be called from begin
function game_tty_init:long ()
{
- tty = @cast(task_current(), "task_struct")->signal->tty
+ tty = @cast(task_current(), "task_struct", "kernel")->signal->tty
if (tty) {
- namep = @cast(tty,"tty_struct")->name
+ namep = @cast(tty,"tty_struct", "kernel")->name
GM_tty_name = kernel_string(namep)
- GM_tty_ws_col = @cast(tty, "tty_struct")->winsize->ws_col
- GM_tty_ws_row = @cast(tty, "tty_struct")->winsize->ws_row
+ GM_tty_ws_col = @cast(tty, "tty_struct", "kernel")->winsize->ws_col
+ GM_tty_ws_row = @cast(tty, "tty_struct", "kernel")->winsize->ws_row
}
return tty
}
commit 3d922919dbe5657becf48917f1c661bf6711e956
Author: William Cohen <wcohen@redhat.com>
Date: Thu Jun 18 13:32:50 2020 -0400
Use explicit @cast() operators for periodic.stp
Commit 00ee19ff030f665df7e087a579f39105256a0253 changed how @cast()
operations work and they no longer default to using the kernel
debuginfo for type information. Need to include kernel as location for
this information for the @cast() rather than just assuming a default.
diff --git a/testsuite/systemtap.examples/profiling/periodic.stp b/testsuite/systemtap.examples/profiling/periodic.stp
index f18f183..b9052e5 100755
--- a/testsuite/systemtap.examples/profiling/periodic.stp
+++ b/testsuite/systemtap.examples/profiling/periodic.stp
@@ -18,8 +18,8 @@ probe kernel.trace("timer_expire_entry")
period[$timer] <<< elapsed
funct[$timer] = $timer->function
data[$timer] = @defined($timer->data) ? $timer->data : 0
- proc_info[$timer] = @defined($timer->data) ? 0 : @container_of($timer, "struct process_timer", timer)->task
- delayed_work_info[$timer] = @defined($timer->data) ? 0 : & @container_of($timer, "struct delayed_work", timer)
+ proc_info[$timer] = @defined($timer->data) ? 0 : @module_container_of($timer, "kernel", "struct process_timer", timer)->task
+ delayed_work_info[$timer] = @defined($timer->data) ? 0 : & @module_container_of($timer, "kernel", "struct delayed_work", timer)
}
last_expire[$timer] = new_expire
}
commit b2d18cb3afca76536506fe4992fdd6ef091ce82f
Author: William Cohen <wcohen@redhat.com>
Date: Thu Jun 18 15:01:40 2020 -0400
Use explicit @cast() operators for semop-watch.stp example.
diff --git a/testsuite/systemtap.examples/process/semop-watch.stp b/testsuite/systemtap.examples/process/semop-watch.stp
index ca2bf0a..bf1d632 100755
--- a/testsuite/systemtap.examples/process/semop-watch.stp
+++ b/testsuite/systemtap.examples/process/semop-watch.stp
@@ -3,7 +3,7 @@ global times;
probe syscall.{semop,semtimedop}
{
- sembuf_sz = @cast_sizeof("struct sembuf");
+ sembuf_sz = @cast_module_sizeof("kernel", "struct sembuf");
res = sprintf("set %d sems", semid)
%( systemtap_v < "2.3" %?
@@ -14,7 +14,7 @@ probe syscall.{semop,semtimedop}
for(i = 0; i < nsops; i++) {
offset = i * sembuf_sz;
pointer = sops_uaddr + offset;
- num_addr = & @cast(pointer, "struct sembuf")->sem_num;
+ num_addr = & @cast(pointer, "struct sembuf", "kernel")->sem_num;
num = user_short(num_addr);
res = sprintf("%s %d", res, num);
commit a948c291c9cd7320d3c9b18b5037908cbbdf70b7
Author: William Cohen <wcohen@redhat.com>
Date: Mon Jun 22 11:28:32 2020 -0400
Use explicit @cast() operators pointing to kernel for tapsets
Commit 00ee19ff030f665df7e087a579f39105256a0253 changed how @cast()
operations work and they no longer default to using the kernel
debuginfo for type information. Need to include kernel as location for
this information for the @cast() rather than just assuming a default.
diff --git a/tapset/linux/dentry.stp b/tapset/linux/dentry.stp
index 4e73532..d148c57 100644
--- a/tapset/linux/dentry.stp
+++ b/tapset/linux/dentry.stp
@@ -28,7 +28,7 @@
@__private30 function __dentry_IS_ROOT:long(dentry:long)
{
- return (@cast(dentry, "dentry")->d_parent == dentry)
+ return (@cast(dentry, "dentry", "kernel")->d_parent == dentry)
}
@@ -61,7 +61,7 @@
*/
function d_name:string(dentry:long)
{
- s = & @cast(dentry, "dentry")->d_name;
+ s = & @cast(dentry, "dentry", "kernel")->d_name;
return kernel_string_n(s->name, s->len);
}
@@ -70,8 +70,8 @@ function d_name:string(dentry:long)
{
/* i_dentry is an hlist_head on 3.6+, or a list_head before that. */
d_alias = @choose_defined(
- @cast(inode, "struct inode")->i_dentry->first,
- @cast(inode, "struct inode")->i_dentry->next)
+ @cast(inode, "struct inode", "kernel")->i_dentry->first,
+ @cast(inode, "struct inode", "kernel")->i_dentry->next)
if (@type_member_defined("struct dentry", d_alias)) {
return & @container_of(d_alias, "struct dentry", d_alias)
@@ -86,8 +86,8 @@ function d_name:string(dentry:long)
{
/* s_mounts was added in kernel 3.6, commit b3d9b7a3c. */
if (@type_member_defined("struct super_block", s_mounts)) {
- mnt_ns = @cast(task_current(), "struct task_struct")->nsproxy->mnt_ns
- sb = @cast(inode, "struct inode")->i_sb
+ mnt_ns = @cast(task_current(), "struct task_struct", "kernel<linux/sched.h>")->nsproxy->mnt_ns
+ sb = @cast(inode, "struct inode", "kernel")->i_sb
/* Look for the mount which matches the current namespace */
head = &sb->s_mounts
@@ -141,7 +141,7 @@ function reverse_path_walk:string(dentry:long)
{
while(1) {
name = __dentry_prepend(dentry, name);
- dentry = @cast(dentry, "dentry")->d_parent;
+ dentry = @cast(dentry, "dentry", "kernel")->d_parent;
if (__dentry_IS_ROOT(dentry))
return name;
}
@@ -209,8 +209,8 @@ function task_dentry_path:string(task:long,dentry:long,vfsmnt:long)
* dentry == vfsmnt->mnt_root. In that case, we'll just go
* ahead and handle them normally.
*/
- dentry = & @cast(dentry, "dentry")
- vfsmnt = & @cast(vfsmnt, "vfsmount")
+ dentry = & @cast(dentry, "dentry", "kernel")
+ vfsmnt = & @cast(vfsmnt, "vfsmount", "kernel")
if (@type_member_defined("dentry", d_op->d_dname)
&& dentry->d_op && dentry->d_op->d_dname
@@ -230,7 +230,7 @@ function task_dentry_path:string(task:long,dentry:long,vfsmnt:long)
return sprintf("ANON_INODE:%s", d_name(dentry))
}
else if (vfsmnt->mnt_sb->s_magic == @const("NSFS_MAGIC")) {
- ns_ops = &@cast(dentry->d_fsdata, "proc_ns_operations")
+ ns_ops = &@cast(dentry->d_fsdata, "proc_ns_operations", "kernel")
return sprintf("%s:[%lu]", kernel_string(ns_ops->name),
dentry->d_inode->i_ino)
}
@@ -239,16 +239,16 @@ function task_dentry_path:string(task:long,dentry:long,vfsmnt:long)
# Handle old-school vs. new-school fs_structs.
if (@type_member_defined("fs_struct", rootmnt)) {
- root_dentry = & @cast(task, "task_struct")->fs->root
- root_vfsmnt = & @cast(task, "task_struct")->fs->rootmnt
+ root_dentry = & @cast(task, "task_struct", "kernel")->fs->root
+ root_vfsmnt = & @cast(task, "task_struct", "kernel")->fs->rootmnt
}
else {
- root_dentry = @cast(task, "task_struct")->fs->root->dentry
- root_vfsmnt = @cast(task, "task_struct")->fs->root->mnt
+ root_dentry = @cast(task, "task_struct", "kernel")->fs->root->dentry
+ root_vfsmnt = @cast(task, "task_struct", "kernel")->fs->root->mnt
}
if (@type_member_defined("mount", mnt_parent)) {
- mnt = &@cast(real_mount(vfsmnt), "mount")
+ mnt = &@cast(real_mount(vfsmnt), "mount", "kernel")
if (mnt == 0)
return "<unknown>"
}
@@ -305,10 +305,10 @@ function task_dentry_path:string(task:long,dentry:long,vfsmnt:long)
*/
function d_path:string(nd:long)
{
- dentry = @choose_defined(@cast(nd,"nameidata")->path->dentry,
- @cast(nd,"nameidata")->dentry)
- vfsmnt = @choose_defined(@cast(nd,"nameidata")->path->mnt,
- @cast(nd,"nameidata")->mnt)
+ dentry = @choose_defined(@cast(nd,"nameidata", "kernel")->path->dentry,
+ @cast(nd,"nameidata", "kernel")->dentry)
+ vfsmnt = @choose_defined(@cast(nd,"nameidata", "kernel")->path->mnt,
+ @cast(nd,"nameidata", "kernel")->mnt)
return sprintf("%s/", task_dentry_path(task_current(), dentry, vfsmnt))
}
@@ -353,8 +353,8 @@ function fullpath_struct_path:string(path:long)
function fullpath_struct_file:string(task:long, file:long)
{
return task_dentry_path(task,
- @choose_defined(@cast(file, "file")->f_path->dentry,
- @cast(file, "file")->f_dentry),
- @choose_defined(@cast(file, "file")->f_path->mnt,
- @cast(file, "file")->f_vfsmnt))
+ @choose_defined(@cast(file, "file", "kernel")->f_path->dentry,
+ @cast(file, "file", "kernel")->f_dentry),
+ @choose_defined(@cast(file, "file", "kernel")->f_path->mnt,
+ @cast(file, "file", "kernel")->f_vfsmnt))
}
diff --git a/tapset/linux/dev.stp b/tapset/linux/dev.stp
index 0232fc9..079ce1c 100644
--- a/tapset/linux/dev.stp
+++ b/tapset/linux/dev.stp
@@ -56,8 +56,8 @@ function usrdev2kerndev:long(dev:long)
function disk_name:string(hd:long, partno:long)
{
if (!partno)
- return kernel_string(@cast(hd, "gendisk")->disk_name)
- disk_name = kernel_string(@cast(hd, "gendisk")->disk_name)
+ return kernel_string(@cast(hd, "gendisk", "kernel")->disk_name)
+ disk_name = kernel_string(@cast(hd, "gendisk", "kernel")->disk_name)
if (isdigit(substr(disk_name, strlen(disk_name)-1, 1)))
return sprintf("%sp%d", disk_name, partno)
else
@@ -66,7 +66,7 @@ function disk_name:string(hd:long, partno:long)
function bdevname:string(bdev:long)
{
- bdev = & @cast(bdev, "block_device")
+ bdev = & @cast(bdev, "block_device", "kernel")
if (bdev == 0)
return "N/A"
diff --git a/tapset/linux/ioblock.stp b/tapset/linux/ioblock.stp
index ad3603c..9d8f57b 100644
--- a/tapset/linux/ioblock.stp
+++ b/tapset/linux/ioblock.stp
@@ -107,12 +107,12 @@ function bio_rw_str(rw:long)
@__private30 function __bio_start_sect:long(bio:long)
{
try {
- if (@defined(@cast(bio, "bio")->bi_dev)) {
- return @cast(bio, "bio")->bi_bdev->bd_part->start_sect
+ if (@defined(@cast(bio, "bio", "kernel")->bi_dev)) {
+ return @cast(bio, "bio", "kernel")->bi_bdev->bd_part->start_sect
}
- else if (@defined(@cast(bio, "bio")->bi_disk)) {
- return disk_get_part_start_sect(@cast(bio, "bio")->bi_disk,
- @cast(bio, "bio")->bi_partno)
+ else if (@defined(@cast(bio, "bio", "kernel")->bi_disk)) {
+ return disk_get_part_start_sect(@cast(bio, "bio", "kernel")->bi_disk,
+ @cast(bio, "bio", "kernel")->bi_partno)
}
} catch {
return -1
@@ -122,12 +122,12 @@ function bio_rw_str(rw:long)
/* returns the block device name */
@__private30 function __bio_devname:string(bio:long)
{
- if (@defined(@cast(bio, "bio")->bi_bdev)) {
- return bdevname(@cast(bio, "bio")->bi_bdev)
+ if (@defined(@cast(bio, "bio", "kernel")->bi_bdev)) {
+ return bdevname(@cast(bio, "bio", "kernel")->bi_bdev)
}
else {
- return disk_name(@cast(bio, "bio")->bi_disk,
- @cast(bio, "bio")->bi_partno)
+ return disk_name(@cast(bio, "bio", "kernel")->bi_disk,
+ @cast(bio, "bio", "kernel")->bi_partno)
}
}
diff --git a/tapset/linux/task.stp b/tapset/linux/task.stp
index 4afc458..b542b61 100644
--- a/tapset/linux/task.stp
+++ b/tapset/linux/task.stp
@@ -40,7 +40,7 @@ function task_current:long () {
return -1;
}
sig = @task(task)->signal;
- return @cast(sig, "signal_struct")->rlim[nd_limit]->rlim_cur;
+ return @cast(sig, "signal_struct", "kernel")->rlim[nd_limit]->rlim_cur;
}
/* sfunction task_rlimit - The current resource limit of the task
commit 403e927796c3008ad5d5fed9bd97dc7cbad424bb
Author: Martin Cermak <mcermak@redhat.com>
Date: Mon Jun 29 16:30:34 2020 +0200
PR26181: Use explicit @cast() within get_ip_from_client()
Commit 00ee19ff030f665df7e087a579f39105256a0253 changed how @cast()
operations work and they no longer default to using the kernel
debuginfo for type information. Need to include kernel as location for
this information for the @cast() rather than just assuming a default.
Also, fix the type of server_ip, which historically had been a long,
but since systemtap_v >= "4.3", it is a string.
diff --git a/tapset/linux/nfs_proc.stp b/tapset/linux/nfs_proc.stp
index 8da3f6b..2579074 100644
--- a/tapset/linux/nfs_proc.stp
+++ b/tapset/linux/nfs_proc.stp
@@ -77,11 +77,11 @@ function get_ip_from_client:string(clnt:long)
* inside that buffer. */
if (@cast(addr, "sockaddr")->sa_family
== @const("AF_INET")) {
- return format_ipaddr(&@cast(addr, "sockaddr_in")->sin_addr->s_addr, @const("AF_INET"))
+ return format_ipaddr(&@cast(addr, "sockaddr_in", "kernel:sunrpc")->sin_addr->s_addr, @const("AF_INET"))
}
else if (@cast(addr, "sockaddr")->sa_family
== @const("AF_INET6")) {
- return format_ipaddr(&@cast(addr, "sockaddr_in6")->sin6_addr, @const("AF_INET6"))
+ return format_ipaddr(&@cast(addr, "sockaddr_in6", "kernel:sunrpc")->sin6_addr, @const("AF_INET6"))
}
return ""
}
@@ -90,12 +90,12 @@ function get_ip_from_client:long(clnt:long)
{
cl_xprt = @cast(clnt, "rpc_clnt", "kernel:sunrpc")->cl_xprt
addr = &@cast(cl_xprt, "rpc_xprt", "kernel:sunrpc")->addr
- if (@cast(addr, "sockaddr_in")->sin_family
+ if (@cast(addr, "sockaddr_in", "kernel:sunrpc")->sin_family
!= @const("AF_INET")) {
/* Now consider ipv4 only */
return 0
}
- return @cast(addr, "sockaddr_in")->sin_addr->s_addr
+ return @cast(addr, "sockaddr_in", "kernel:sunrpc")->sin_addr->s_addr
}
%)
@@ -758,7 +758,11 @@ probe _nfs.proc2.missing_read_setup = never
{
inode = 0
client = 0
+%( systemtap_v >= "4.3" %?
+ server_ip = "0"
+%:
server_ip = 0
+%)
prot = 0
count = 0
commit f1a9bb064d11319a7eca4f4233c9edcc4a03af7e
Author: Martin Cermak <mcermak@redhat.com>
Date: Thu Jul 9 09:19:01 2020 +0200
Tapset and testsuite updates against @cast() change 00ee19ff03
Commit 00ee19ff030f665df7e087a579f39105256a0253 changed how @cast()
operations work and they no longer default to using the kernel
debuginfo for type information. Need to include kernel as location for
this information for the @cast() rather than just assuming a default.
These are respective tapset and testsuite minor updates.
diff --git a/tapset/linux/networking.stp b/tapset/linux/networking.stp
index 69843a7..0b52cbc 100644
--- a/tapset/linux/networking.stp
+++ b/tapset/linux/networking.stp
@@ -69,7 +69,7 @@
/* A function that returns the device name given the net_device struct */
function get_netdev_name:string (addr:long) {
- return kernel_string(@cast(addr, "net_device")->name)
+ return kernel_string(@cast(addr, "net_device", "kernel")->name)
}
/**
diff --git a/tapset/linux/scsi.stp b/tapset/linux/scsi.stp
index 3577942..5359fe8 100644
--- a/tapset/linux/scsi.stp
+++ b/tapset/linux/scsi.stp
@@ -179,8 +179,8 @@ probe scsi.iocompleted
function timer_pending:long(timer:long)
{
- return (@choose_defined(@cast(timer, "timer_list")->entry->next,
- @cast(timer, "timer_list")->base) != 0)
+ return (@choose_defined(@cast(timer, "timer_list", "kernel")->entry->next,
+ @cast(timer, "timer_list", "kernel")->base) != 0)
}
function scsi_timer_pending:long(cmd:long)
diff --git a/testsuite/buildok/pretty.stp b/testsuite/buildok/pretty.stp
index 85c9cd9..a2fc781 100755
--- a/testsuite/buildok/pretty.stp
+++ b/testsuite/buildok/pretty.stp
@@ -6,14 +6,14 @@ global i = 1
# pretty-printing with @cast
probe begin {
t = task_current()
- log(@cast(t, "task_struct")->fs$)
- log(@cast(t, "task_struct")->fs$$)
- log(@cast(t, "task_struct")->comm$)
- log(@cast(t, "task_struct")->comm$$)
- log(@cast(t, "task_struct")->comm[0]$)
- log(@cast(t, "task_struct")->comm[0]$$)
- log(@cast(t, "task_struct")->comm[i]$)
- log(@cast(t, "task_struct")->comm[i]$$)
+ log(@cast(t, "task_struct", "kernel")->fs$)
+ log(@cast(t, "task_struct", "kernel")->fs$$)
+ log(@cast(t, "task_struct", "kernel")->comm$)
+ log(@cast(t, "task_struct", "kernel")->comm$$)
+ log(@cast(t, "task_struct", "kernel")->comm[0]$)
+ log(@cast(t, "task_struct", "kernel")->comm[0]$$)
+ log(@cast(t, "task_struct", "kernel")->comm[i]$)
+ log(@cast(t, "task_struct", "kernel")->comm[i]$$)
}
# pretty-printing in dwarf kernel context
diff --git a/testsuite/semok/cast.stp b/testsuite/semok/cast.stp
index d72763c..fe78e36 100755
--- a/testsuite/semok/cast.stp
+++ b/testsuite/semok/cast.stp
@@ -2,7 +2,7 @@
probe begin {
// basic @cast test, with and without specifying kernel
- println(@cast(0, "task_struct")->tgid)
+ println(@cast(0, "task_struct", "kernel")->tgid)
println(@cast(0, "task_struct", "kernel")->tgid)
// check module-search paths
@@ -25,5 +25,5 @@ probe begin {
@cast(0, "task_struct", "no_such_module")->tgid
// PR11556: we should be able to treat the initial pointer like an array too
- println(@cast(0, "task_struct")[42]->tgid)
+ println(@cast(0, "task_struct", "kernel")[42]->tgid)
}
diff --git a/testsuite/semok/pretty.stp b/testsuite/semok/pretty.stp
index 0211d86..25490e7 100755
--- a/testsuite/semok/pretty.stp
+++ b/testsuite/semok/pretty.stp
@@ -12,16 +12,16 @@ global i = 1
# pretty-printing with @cast
probe begin {
t = task_current()
- log(@cast(t, "task_struct")$)
- log(@cast(t, "task_struct")$$)
- log(@cast(t, "task_struct")->fs$)
- log(@cast(t, "task_struct")->fs$$)
- log(@cast(t, "task_struct")->comm$)
- log(@cast(t, "task_struct")->comm$$)
- log(@cast(t, "task_struct")->comm[0]$)
- log(@cast(t, "task_struct")->comm[0]$$)
- log(@cast(t, "task_struct")->comm[i]$)
- log(@cast(t, "task_struct")->comm[i]$$)
+ log(@cast(t, "task_struct", "kernel")$)
+ log(@cast(t, "task_struct", "kernel")$$)
+ log(@cast(t, "task_struct", "kernel")->fs$)
+ log(@cast(t, "task_struct", "kernel")->fs$$)
+ log(@cast(t, "task_struct", "kernel")->comm$)
+ log(@cast(t, "task_struct", "kernel")->comm$$)
+ log(@cast(t, "task_struct", "kernel")->comm[0]$)
+ log(@cast(t, "task_struct", "kernel")->comm[0]$$)
+ log(@cast(t, "task_struct", "kernel")->comm[i]$)
+ log(@cast(t, "task_struct", "kernel")->comm[i]$$)
}
# pretty-printing in dwarf kernel context
diff --git a/testsuite/semok/sizeof.stp b/testsuite/semok/sizeof.stp
index 8e35e29..a5a6bbb 100755
--- a/testsuite/semok/sizeof.stp
+++ b/testsuite/semok/sizeof.stp
@@ -1,7 +1,7 @@
#! stap -p2
probe begin {
- println("task_struct: ", @cast_sizeof("task_struct"))
+ # println("task_struct: ", @cast_sizeof("task_struct"))
println("task_struct: ", @cast_module_sizeof("kernel", "task_struct"))
println("task_struct: ", @cast_module_sizeof("kernel<linux/sched.h>", "task_struct"))
println("FILE: ", @cast_module_sizeof("<stdio.h>", "FILE"))
diff --git a/testsuite/semok/thirtyeight.stp b/testsuite/semok/thirtyeight.stp
index 15189b7..5018795 100755
--- a/testsuite/semok/thirtyeight.stp
+++ b/testsuite/semok/thirtyeight.stp
@@ -7,4 +7,4 @@
probe kernel.function("do_sys_open") { println(@defined($mode) ? 1 : $nosuchvar) }
probe kernel.trace("sched_switch")? { println(@defined($next->pid) ? 1 : $nosuchvar) }
probe procfs.write { println(@defined($value) ? 1 : $nosuchvar) }
-probe begin { println(@defined(@cast(0, "task_struct")->pid) ? 1 : $nosuchvar) }
+probe begin { println(@defined(@cast(0, "task_struct", "kernel")->pid) ? 1 : $nosuchvar) }
diff --git a/testsuite/semok/thirtysix.stp b/testsuite/semok/thirtysix.stp
index 14f10c1..0adae14 100755
--- a/testsuite/semok/thirtysix.stp
+++ b/testsuite/semok/thirtysix.stp
@@ -17,17 +17,17 @@ probe begin,end,error,never { println(@defined($nosuchvar)?$nosuchvar:0) } # inv
probe timer.s(1),timer.jiffies(1) { println(@defined($nosuchvar)?$nosuchvar:0) } # invalid
probe timer.profile { println(@defined($nosuchvar)?$nosuchvar:0) } # invalid
-probe begin { println(@defined(@cast(0, "task_struct")->foo)?$nosuchvar:0) } # invalid
-probe begin { println(@defined(@cast(0, "task_struct")->pid)?1:$nosuchvar) } # valid
-probe kernel.function("do_sys_open") { println(@defined(@cast(0, "task_struct")->foo)?$nosuchvar:0) } # invalid
-probe kernel.function("do_sys_open") { println(@defined(@cast(0, "task_struct")->pid)?1:$nosuchvar) } # valid
+probe begin { println(@defined(@cast(0, "task_struct", "kernel")->foo)?$nosuchvar:0) } # invalid
+probe begin { println(@defined(@cast(0, "task_struct", "kernel")->pid)?1:$nosuchvar) } # valid
+probe kernel.function("do_sys_open") { println(@defined(@cast(0, "task_struct", "kernel")->foo)?$nosuchvar:0) } # invalid
+probe kernel.function("do_sys_open") { println(@defined(@cast(0, "task_struct", "kernel")->pid)?1:$nosuchvar) } # valid
-function foo1() { println(@defined(@cast(0, "task_struct")->foo)?$nosuchvar:0) } # invalid
-function foo2() { println(@defined(@cast(0, "task_struct")->pid)?1:$nosuchvar) } # valid
+function foo1() { println(@defined(@cast(0, "task_struct", "kernel")->foo)?$nosuchvar:0) } # invalid
+function foo2() { println(@defined(@cast(0, "task_struct", "kernel")->pid)?1:$nosuchvar) } # valid
probe begin { foo1(); foo2(); }
# PR11598: support @defined(&...)
-probe begin { println(@defined(@cast(0, "task_struct")->rcu)?$nosuchvar:0) } # invalid
-probe begin { println(@defined(&@cast(0, "task_struct")->rcu)?1:$nosuchvar) } # valid
+probe begin { println(@defined(@cast(0, "task_struct", "kernel")->rcu)?$nosuchvar:0) } # invalid
+probe begin { println(@defined(&@cast(0, "task_struct", "kernel")->rcu)?1:$nosuchvar) } # valid
probe kernel.function("release_task") { println(@defined($p->rcu)?$nosuchvar:0) } # invalid
probe kernel.function("release_task") { println(@defined(&$p->rcu)?1:$nosuchvar) } # valid
diff --git a/testsuite/systemtap.base/bitfield.stp b/testsuite/systemtap.base/bitfield.stp
index 0208108..b5f7b89 100644
--- a/testsuite/systemtap.base/bitfield.stp
+++ b/testsuite/systemtap.base/bitfield.stp
@@ -11,8 +11,8 @@ function check:long(ack:long, urg:long) {
ptr = get_ptr()
/* set the bits with cast */
- @cast(ptr, "tcphdr")->ack = ack
- @cast(ptr, "tcphdr")->urg = urg
+ @cast(ptr, "tcphdr", "kernel")->ack = ack
+ @cast(ptr, "tcphdr", "kernel")->urg = urg
/* check that reading with embedded-C is ok */
real_ack = get_ack()
@@ -20,8 +20,8 @@ function check:long(ack:long, urg:long) {
errors = (ack != real_ack) + (urg != real_urg)
/* check that reading with a cast is ok */
- cast_ack = @cast(ptr, "tcphdr")->ack
- cast_urg = @cast(ptr, "tcphdr")->urg
+ cast_ack = @cast(ptr, "tcphdr", "kernel")->ack
+ cast_urg = @cast(ptr, "tcphdr", "kernel")->urg
errors += (ack != cast_ack) + (urg != cast_urg)
if (errors)
diff --git a/testsuite/systemtap.base/target_set.stp b/testsuite/systemtap.base/target_set.stp
index ad4dca6..7c458cb 100644
--- a/testsuite/systemtap.base/target_set.stp
+++ b/testsuite/systemtap.base/target_set.stp
@@ -19,13 +19,13 @@ probe begin
probe syscall.nanosleep
{
if (target_set_pid(pid())
- && user_long(&@cast(req_uaddr, "struct timespec")->tv_sec) == $1)
+ && user_long(&@cast(req_uaddr, "struct timespec", "kernel")->tv_sec) == $1)
target_set_report()
}
probe syscall.compat_nanosleep ?
{
if (target_set_pid(pid())
- && user_long(&@cast(req_uaddr, "struct compat_timespec")->tv_sec) == $1)
+ && user_long(&@cast(req_uaddr, "struct compat_timespec", "kernel")->tv_sec) == $1)
target_set_report()
}
diff --git a/testsuite/systemtap.context/usymbols.exp b/testsuite/systemtap.context/usymbols.exp
index f53c1cd..e12f067 100644
--- a/testsuite/systemtap.context/usymbols.exp
+++ b/testsuite/systemtap.context/usymbols.exp
@@ -20,7 +20,7 @@ set testscript {
probe syscall.rt_sigaction {
if (pid() == target() && execname() == "%s") {
// Note user address.
- handler = user_long(&@cast(act_uaddr, "struct sigaction")->sa_handler);
+ handler = user_long(&@cast(act_uaddr, "struct sigaction", "kernel")->sa_handler);
try {
printf("handler: %%s (%%s)\n", usymname(handler), umodname(handler));
} catch {
@@ -31,9 +31,9 @@ set testscript {
probe syscall.rt_sigaction32 ? {
if (pid() == target() && execname() == "%s") {
// Note user address.
- handler = user_long(@defined(@cast(0, "compat_sigaction")->sa_handler)
- ? &@cast(act_uaddr, "compat_sigaction")->sa_handler
- : &@cast(act_uaddr, "sigaction32")->sa_handler);
+ handler = user_long(@defined(@cast(0, "compat_sigaction", "kernel")->sa_handler)
+ ? &@cast(act_uaddr, "compat_sigaction", "kernel")->sa_handler
+ : &@cast(act_uaddr, "sigaction32", "kernel")->sa_handler);
try {
printf("handler: %%s (%%s)\n", usymname(handler), umodname(handler));
} catch {
commit c6831f14e043f88096b2219828c0124cf2549b77
Author: Frank Ch. Eigler <fche@redhat.com>
Date: Thu Jul 9 21:41:51 2020 -0400
testuite: More @cast() fallout
Adjust another test case that uses the deprecated
probe begin { @cast(PTR, "type") }
construct. Now "kernel" is formally required to specify context.
diff --git a/testsuite/systemtap.base/cast.stp b/testsuite/systemtap.base/cast.stp
index cc44a36..0e191eb 100644
--- a/testsuite/systemtap.base/cast.stp
+++ b/testsuite/systemtap.base/cast.stp
@@ -4,7 +4,7 @@ probe begin
// Compare PIDs
pid = pid()
- cast_pid = @cast(curr, "task_struct")->tgid
+ cast_pid = @cast(curr, "task_struct", "kernel")->tgid
if (pid == cast_pid)
println("PID OK")
else
@@ -18,7 +18,7 @@ probe begin
printf("PID2 %d != %d\n", pid, cast_pid)
// Compare PIDs with an array access (PR11556)
- cast_pid = @cast(curr, "task_struct")[0]->tgid
+ cast_pid = @cast(curr, "task_struct", "kernel")[0]->tgid
if (pid == cast_pid)
println("PID3 OK")
else
@@ -26,16 +26,16 @@ probe begin
// Compare execnames
name = execname()
- cast_name = kernel_string(@cast(curr, "task_struct")->comm)
+ cast_name = kernel_string(@cast(curr, "task_struct", "kernel")->comm)
if (name == cast_name)
println("execname OK")
else
printf("execname \"%s\" != \"%s\"\n", name, cast_name)
// Compare usage counter values through a struct address
- usage = @cast(curr, "task_struct")->usage->counter
- pusage = & @cast(curr, "task_struct")->usage
- cast_usage = @cast(pusage, "atomic_t")->counter
+ usage = @cast(curr, "task_struct", "kernel")->usage->counter
+ pusage = & @cast(curr, "task_struct", "kernel")->usage
+ cast_usage = @cast(pusage, "atomic_t", "kernel")->counter
if (usage == cast_usage)
println("usage OK")
else

108
SOURCES/rhbz1873492.patch Normal file
View File

@ -0,0 +1,108 @@
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;

63
SOURCES/rhbz1898288.patch Normal file
View File

@ -0,0 +1,63 @@
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];

217
SOURCES/rhbz1902696.patch Normal file
View File

@ -0,0 +1,217 @@
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);

2831
SOURCES/rhbz1906662.patch Normal file

File diff suppressed because it is too large Load Diff

44
SOURCES/rhbz1908904.patch Normal file
View File

@ -0,0 +1,44 @@
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

@ -54,7 +54,8 @@
%if 0%{?fedora} >= 18 || 0%{?rhel} >= 6
%define initdir %{sysconfdir}/rc.d/init.d
# not scl-wrapped _initddir
%else # RHEL5 doesn't know _initddir
%else
# RHEL5 doesn't know _initddir
%define initdir %{_initrddir}
%endif
@ -64,7 +65,8 @@
%else
%if 0%{?rhel} >= 6
%define udevrulesdir /lib/udev/rules.d
%else # RHEL5
%else
# RHEL5
%define udevrulesdir /etc/udev/rules.d
%endif
%endif
@ -94,8 +96,8 @@
%define __brp_mangle_shebangs_exclude_from .stp$
Name: %{?scl_prefix}systemtap
Version: 4.3
Release: 7%{?dist}
Version: 4.4
Release: 5%{?release_override}%{?dist}
# for version, see also configure.ac
@ -131,8 +133,12 @@ License: GPLv2+
URL: http://sourceware.org/systemtap/
Source: ftp://sourceware.org/pub/systemtap/releases/systemtap-%{version}.tar.gz
Patch10: rhbz1847676,1857749.patch
Patch11: rhbz1855264.patch
Patch1: rhbz1873492.patch
Patch2: rhbz1898288.patch
Patch3: rhbz1902696.patch
Patch4: rhbz1908904.patch
Patch5: rhbz1906662.patch
Patch6: rhbz1650594.patch
# Build*
BuildRequires: gcc-c++
@ -140,6 +146,7 @@ BuildRequires: cpio
BuildRequires: gettext-devel
BuildRequires: pkgconfig(nss)
BuildRequires: pkgconfig(avahi-client)
BuildRequires: %{?scl_prefix}elfutils-debuginfod-client-devel >= 0.179
%if %{with_dyninst}
BuildRequires: %{?scl_prefix}dyninst-devel >= 10.0
BuildRequires: pkgconfig(libselinux)
@ -363,8 +370,8 @@ URL: http://sourceware.org/systemtap/
Requires: %{?scl_prefix}systemtap = %{version}-%{release}
Requires: %{?scl_prefix}systemtap-sdt-devel = %{version}-%{release}
Requires: %{?scl_prefix}systemtap-server = %{version}-%{release}
Requires: %{?scl_prefix}elfutils
Requires: dejagnu which grep nc
Requires: dejagnu which %{?scl_prefix}elfutils grep nc
Requires: %{?scl_prefix}elfutils-debuginfod
Requires: gcc gcc-c++ make glibc-devel
# testsuite/systemtap.base/ptrace.exp needs strace
Requires: strace
@ -509,9 +516,12 @@ systemtap-runtime-virthost machine to execute systemtap scripts.
%prep
%setup -q -n systemtap-%{version}
%patch10 -p1
%patch11 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%build
@ -1248,6 +1258,20 @@ done
# PRERELEASE
%changelog
* Wed Feb 10 2021 Frank Ch. Eigler <fche@redhat.com> - 4.4-5
- rhbz1878303 - align with base rhel systemtap-4.4-9.el8
* Tue Jan 26 2021 Martin Cermak <mcermak@redhat.com> - 4.4-4
- rhbz1878303 - align with base rhel systemtap-4.4-8.el8
* Sun Nov 22 2020 Frank Ch. Eigler <fche@redhat.com> - 4.4-3
- rhbz1898288: stability for exhausted UTRACE_TASK_WORK_POOL
- rhbz1873492 related: mokutil parser robustness for RH keys
- rhbz1873492 related: rhel8 kernel_is_locked_down detection
* Mon Nov 09 2020 Frank Ch. Eigler <fche@redhat.com> - 4.4-1
- Upstream release.
* Tue Jul 28 2020 Frank Ch. Eigler <fche@redhat.com> - 4.3-7
- Fix rhbz1857749 with rhel8.3 baseos patch
- Fix rhbz1852021 with more complete rhel8.3 baseos patch