From 1f738f508c8f9ac0c5e9d764e528a80f5cb56582 Mon Sep 17 00:00:00 2001 From: William Cohen Date: Tue, 14 May 2024 16:28:35 -0400 Subject: [PATCH] Resolves: RHEL-36201 --- RHEL-36201a.patch | 116 ++++++++++++++++++++++++++++++++++++++++++++++ RHEL-36201b.patch | 22 +++++++++ systemtap.spec | 9 +++- 3 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 RHEL-36201a.patch create mode 100644 RHEL-36201b.patch diff --git a/RHEL-36201a.patch b/RHEL-36201a.patch new file mode 100644 index 0000000..26994cf --- /dev/null +++ b/RHEL-36201a.patch @@ -0,0 +1,116 @@ +commit b8d4274d1e7697801c12c512b6724dd3f59f2c72 +Author: William Cohen +Date: Mon May 6 11:36:42 2024 -0400 + + Support kernels that backported kallsym functions from newer linux kernels + + Some Linux distributions may have backported + module_kallsyms_on_each_symbol and kallsyms_on_each_symbol functions + from newer linux kernels. In these situations checking the kernel + version would not detect the proper arguments for these functions. + Systemtap now has a couple of autoconf tests to determine what + arguments should be used for these functions. + +diff --git a/buildrun.cxx b/buildrun.cxx +index bb7bdcc9d..8ee8c391f 100644 +--- a/buildrun.cxx ++++ b/buildrun.cxx +@@ -506,6 +506,8 @@ compile_pass (systemtap_session& s) + + output_autoconf(s, o, cs, "autoconf-pagefault_disable.c", "STAPCONF_PAGEFAULT_DISABLE", NULL); + output_exportconf(s, o2, "kallsyms_lookup_name", "STAPCONF_KALLSYMS_LOOKUP_NAME_EXPORTED"); ++ output_autoconf(s, o, cs, "autoconf-kallsyms_6_3.c", "STAPCONF_KALLSYMS_6_3", NULL); ++ output_autoconf(s, o, cs, "autoconf-kallsyms_6_4.c", "STAPCONF_KALLSYMS_6_4", NULL); + output_autoconf(s, o, cs, "autoconf-uidgid.c", "STAPCONF_LINUX_UIDGID_H", NULL); + output_exportconf(s, o2, "sigset_from_compat", "STAPCONF_SIGSET_FROM_COMPAT_EXPORTED"); + output_exportconf(s, o2, "vzalloc", "STAPCONF_VZALLOC"); +diff --git a/runtime/linux/autoconf-kallsyms_6_3.c b/runtime/linux/autoconf-kallsyms_6_3.c +new file mode 100644 +index 000000000..0af1a5c35 +--- /dev/null ++++ b/runtime/linux/autoconf-kallsyms_6_3.c +@@ -0,0 +1,6 @@ ++#include ++ ++int module_kallsyms_on_each_symbol(const char *modname, ++ int (*fn)(void *, const char *, struct module*, ++ unsigned long), ++ void *data); +diff --git a/runtime/linux/autoconf-kallsyms_6_4.c b/runtime/linux/autoconf-kallsyms_6_4.c +new file mode 100644 +index 000000000..3b3680c53 +--- /dev/null ++++ b/runtime/linux/autoconf-kallsyms_6_4.c +@@ -0,0 +1,3 @@ ++#include ++int kallsyms_on_each_symbol(int (*fn)(void *, const char *, unsigned long), ++ void *data); +diff --git a/runtime/linux/kprobes.c b/runtime/linux/kprobes.c +index 6b30f2c52..2fba61cbb 100644 +--- a/runtime/linux/kprobes.c ++++ b/runtime/linux/kprobes.c +@@ -737,7 +737,7 @@ __stapkp_symbol_callback(void *data, const char *name, + } + + static int +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,4,0) ++#if defined(STAPCONF_KALLSYMS_6_4) + stapkp_symbol_callback(void *data, const char *name, + unsigned long addr) + { +@@ -780,7 +780,7 @@ stapkp_init(struct stap_kprobe_probe *probes, + mutex_lock(&module_mutex); + #endif + kallsyms_on_each_symbol(stapkp_symbol_callback, &sd); +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0) ++#if defined(STAPCONF_KALLSYMS_6_3) || defined(STAPCONF_KALLSYMS_6_4) + module_kallsyms_on_each_symbol(sd.modname, stapkp_symbol_callback, &sd); + #elif LINUX_VERSION_CODE >= KERNEL_VERSION(5,12,0) + module_kallsyms_on_each_symbol(stapkp_symbol_callback, &sd); +@@ -855,7 +855,7 @@ stapkp_refresh(const char *modname, + mutex_lock(&module_mutex); + #endif + kallsyms_on_each_symbol(stapkp_symbol_callback, &sd); +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0) ++#if defined(STAPCONF_KALLSYMS_6_3) + module_kallsyms_on_each_symbol(sd.modname, stapkp_symbol_callback, &sd); + #elif LINUX_VERSION_CODE >= KERNEL_VERSION(5,12,0) + module_kallsyms_on_each_symbol(stapkp_symbol_callback, &sd); +diff --git a/runtime/sym.c b/runtime/sym.c +index 3947d42f7..23dd3be30 100644 +--- a/runtime/sym.c ++++ b/runtime/sym.c +@@ -1187,7 +1187,7 @@ unsigned long kallsyms_lookup_name (const char *name) + typedef typeof(&kallsyms_on_each_symbol) kallsyms_on_each_symbol_fn; + + // XXX Will be linked in place of the kernel's kallsyms_on_each_symbol: +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,4,0) ++#if defined(STAPCONF_KALLSYMS_6_4) + int kallsyms_on_each_symbol(int (*fn)(void *, const char *, + unsigned long), + void *data) +@@ -1214,13 +1214,13 @@ int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, + typedef typeof(&module_kallsyms_on_each_symbol) module_kallsyms_on_each_symbol_fn; + + // XXX Will be linked in place of the kernel's module_kallsyms_on_each_symbol: +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,4,0) ++#if defined(STAPCONF_KALLSYMS_6_4) + int module_kallsyms_on_each_symbol(const char *modname, + int (*fn)(void *, const char *, + unsigned long), + void *data) + #else +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0) ++#if defined(STAPCONF_KALLSYMS_6_3) + int module_kallsyms_on_each_symbol(const char *modname, + int (*fn)(void *, const char *, struct module *, + unsigned long), +@@ -1235,7 +1235,7 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module + /* First, try to use a kallsyms_lookup_name address passed to us + through the relocation mechanism. */ + if (_stp_module_kallsyms_on_each_symbol != NULL) +-#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0) ++#if defined(STAPCONF_KALLSYMS_6_3) || defined(STAPCONF_KALLSYMS_6_4) + return ibt_wrapper(int, + (* (module_kallsyms_on_each_symbol_fn)_stp_module_kallsyms_on_each_symbol)(modname, fn, data)); + #else diff --git a/RHEL-36201b.patch b/RHEL-36201b.patch new file mode 100644 index 0000000..2e840f4 --- /dev/null +++ b/RHEL-36201b.patch @@ -0,0 +1,22 @@ +commit ed5649f64a3f8c2e8269f9c4435e9174c4e8c775 +Author: William Cohen +Date: Thu May 9 12:23:54 2024 -0400 + + Support kernels that backported kallsym functions (part 2) + + Git commit b8d4274d1e769780 omitted a test for the Linux 6.4 version + of kallsyms function in runtime/linux/kprobes.c. + +diff --git a/runtime/linux/kprobes.c b/runtime/linux/kprobes.c +index 2fba61cbb..9ae5565e3 100644 +--- a/runtime/linux/kprobes.c ++++ b/runtime/linux/kprobes.c +@@ -855,7 +855,7 @@ stapkp_refresh(const char *modname, + mutex_lock(&module_mutex); + #endif + kallsyms_on_each_symbol(stapkp_symbol_callback, &sd); +-#if defined(STAPCONF_KALLSYMS_6_3) ++#if defined(STAPCONF_KALLSYMS_6_3) || defined(STAPCONF_KALLSYMS_6_4) + module_kallsyms_on_each_symbol(sd.modname, stapkp_symbol_callback, &sd); + #elif LINUX_VERSION_CODE >= KERNEL_VERSION(5,12,0) + module_kallsyms_on_each_symbol(stapkp_symbol_callback, &sd); diff --git a/systemtap.spec b/systemtap.spec index cb30ba7..8b20e95 100644 --- a/systemtap.spec +++ b/systemtap.spec @@ -121,7 +121,7 @@ m stapdev stapdev Name: systemtap # PRERELEASE Version: 5.1 -Release: 1%{?release_override}%{?dist} +Release: 2%{?release_override}%{?dist} # for version, see also configure.ac @@ -157,6 +157,8 @@ Summary: Programmable system-wide instrumentation system License: GPL-2.0-or-later URL: http://sourceware.org/systemtap/ Source: ftp://sourceware.org/pub/systemtap/releases/systemtap-%{version}.tar.gz +Patch1: RHEL-36201a.patch +Patch2: RHEL-36201b.patch # Build* BuildRequires: make @@ -583,6 +585,8 @@ or within a container. %prep %setup -q +%patch -P1 -p1 +%patch -P2 -p1 %build @@ -1310,6 +1314,9 @@ exit 0 # PRERELEASE %changelog +* Tue May 14 2024 William Cohen - 5.1-2 +- RHEL-36201 + * Fri Apr 26 2024 Frank Ch. Eigler - 5.1-1 - Upstream release, see wiki page below for detailed notes. https://sourceware.org/systemtap/wiki/SystemTapReleases