From 8addaa4cfbc642b7e01fd1d8a34bcdacc0d7392e Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Tue, 1 Mar 2022 06:07:58 -0500 Subject: [PATCH] import systemtap-4.6-11.el9 --- SOURCES/rhbz2027683.patch | 29 ++++++ SOURCES/rhbz2039207.patch | 80 ++++++++++++++++ SOURCES/rhbz2041526.patch | 167 +++++++++++++++++++++++++++++++++ SOURCES/rhbz2047256.patch | 179 ++++++++++++++++++++++++++++++++++++ SOURCES/sdt-asm-glibc.patch | 22 +++-- SPECS/systemtap.spec | 26 +++++- 6 files changed, 495 insertions(+), 8 deletions(-) create mode 100644 SOURCES/rhbz2027683.patch create mode 100644 SOURCES/rhbz2039207.patch create mode 100644 SOURCES/rhbz2041526.patch create mode 100644 SOURCES/rhbz2047256.patch diff --git a/SOURCES/rhbz2027683.patch b/SOURCES/rhbz2027683.patch new file mode 100644 index 0000000..9ca6b52 --- /dev/null +++ b/SOURCES/rhbz2027683.patch @@ -0,0 +1,29 @@ +commit 39b5233271b997811632871e1b6620a89b384fe8 +Author: Martin Cermak +Date: Thu Jan 20 18:18:00 2022 +0100 + + Fix python probing rhbz2027683 + +diff --git a/tapset/python.stp b/tapset/python.stp +new file mode 100644 +index 000000000..b5d06fcd9 +--- /dev/null ++++ b/tapset/python.stp +@@ -0,0 +1,17 @@ ++/* Systemtap tapset to make it easier to trace Python */ ++ ++/* ++ Define python.function.entry/return: ++*/ ++probe python.function.entry = process("/usr/lib*/libpython*.so*").mark("function__entry") ++{ ++ filename = user_string($arg1); ++ funcname = user_string($arg2); ++ lineno = $arg3; ++} ++probe python.function.return = process("/usr/lib*/libpython*.so*").mark("function__return") ++{ ++ filename = user_string($arg1); ++ funcname = user_string($arg2); ++ lineno = $arg3; ++} diff --git a/SOURCES/rhbz2039207.patch b/SOURCES/rhbz2039207.patch new file mode 100644 index 0000000..a966d16 --- /dev/null +++ b/SOURCES/rhbz2039207.patch @@ -0,0 +1,80 @@ +commit 5abded54b +Author: Stan Cox +Date: Fri Jan 28 15:28:27 2022 -0500 + + Attempt to access string in userspace if kernel access fails + + Add kernel_or_user_string_quoted(_utf16 _utf32) tapsets to handle + situations where a kernelspace access was assumed but string is in + userspace. + +diff --git a/tapset/linux/conversions.stp b/tapset/linux/conversions.stp +index 82f535f6c..d3d3a0b5a 100644 +--- a/tapset/linux/conversions.stp ++++ b/tapset/linux/conversions.stp +@@ -72,6 +72,17 @@ function kernel_string_quoted:string (addr:long) + (unsigned long)(uintptr_t)STAP_ARG_addr); + %} + ++/** ++ * sfunction kernel_or_user_string_quoted - Retrieves and quotes string from kernel or user memory ++ * ++ * @addr: the kernel or user memory address to retrieve the string from ++ * ++ * Similar to kernel_string_quoted except user memory is a fallback method ++ */ ++function kernel_or_user_string_quoted:string (addr:long) { ++ try { return string_quoted(kernel_string(addr)) } catch { return string_quoted(user_string(addr)) } ++} ++ + /** + * sfunction kernel_string_n - Retrieves string of given length from kernel memory + * @addr: The kernel address to retrieve the string from +@@ -160,6 +171,16 @@ function kernel_string_quoted_utf32:string (addr:long) { + try { return string_quoted(kernel_string_utf32(addr)) } catch { return sprintf("0x%x", addr) } + } + ++/** ++ * sfunction kernel_or_user_string_quoted_utf32 - Retrieves and quotes UTF-32 string from kernel or user memory ++ * ++ * @addr: the kernel or user memory address to retrieve the string from ++ * ++ * Similar to kernel_string_quoted_utf32 except user memory is a fallback method ++ */ ++function kernel_or_user_string_quoted_utf32:string (addr:long) { ++ try { return string_quoted(kernel_string_utf32(addr)) } catch { return string_quoted(user_string_utf32(addr)) } ++} + + /** + * sfunction kernel_string_utf16 - Retrieves UTF-16 string from kernel memory +@@ -242,6 +263,17 @@ function kernel_string_quoted_utf16:string (addr:long) { + try { return string_quoted(kernel_string_utf16(addr)) } catch { return sprintf("0x%x", addr) } + } + ++/** ++ * sfunction kernel_or_user_string_quoted_utf16 - Retrieves and quotes UTF-16 string from kernel or user memory ++ * ++ * @addr: the kernel or user memory address to retrieve the string from ++ * ++ * Similar to kernel_string_quoted_utf16 except uses user memory as a fallback method ++ */ ++function kernel_or_user_string_quoted_utf16:string (addr:long) { ++ try { return string_quoted(kernel_string_utf16(addr)) } catch { return string_quoted(user_string_utf16(addr)) } ++} ++ + + /** + * sfunction kernel_long - Retrieves a long value stored in kernel memory +diff --git a/tapsets.cxx b/tapsets.cxx +index 8fc5146e2..8b8f1cad5 100644 +--- a/tapsets.cxx ++++ b/tapsets.cxx +@@ -3757,7 +3757,7 @@ dwarf_pretty_print::print_chars (Dwarf_Die* start_type, target_symbol* e, + return false; + } + +- string function = userspace_p ? "user_string_quoted" : "kernel_string_quoted"; ++ string function = userspace_p ? "user_string_quoted" : "kernel_or_user_string_quoted"; + Dwarf_Word size = (Dwarf_Word) -1; + dwarf_formudata (dwarf_attr_integrate (&type, DW_AT_byte_size, &attr), &size); + switch (size) diff --git a/SOURCES/rhbz2041526.patch b/SOURCES/rhbz2041526.patch new file mode 100644 index 0000000..c387e01 --- /dev/null +++ b/SOURCES/rhbz2041526.patch @@ -0,0 +1,167 @@ +diff --git a/tapset/linux/ioscheduler.stp b/tapset/linux/ioscheduler.stp +index abb24dac9..3096a73ea 100644 +--- a/tapset/linux/ioscheduler.stp ++++ b/tapset/linux/ioscheduler.stp +@@ -11,7 +11,9 @@ + // + %{ + #include ++#if LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0) + #include ++#endif + %} + + /** +@@ -76,7 +78,8 @@ probe ioscheduler.elv_completed_request + elevator_name = kernel_string( + @choose_defined($q->elevator->type->elevator_name, + @choose_defined($q->elevator->elevator_type->elevator_name, +- $q->elevator->elevator_name)), "") ++ @choose_defined($q->elevator->elevator_name, ++ 0))), "") + if($rq == 0) { + disk_major = -1 + disk_minor = -1 +@@ -114,7 +117,8 @@ probe ioscheduler.elv_add_request.kp = + elevator_name = kernel_string( + @choose_defined($q->elevator->type->elevator_name, + @choose_defined($q->elevator->elevator_type->elevator_name, +- $q->elevator->elevator_name)), "") ++ @choose_defined($q->elevator->elevator_name, ++ 0))), "") + q = $q + if($rq == 0) { + disk_major = -1 +@@ -152,7 +156,8 @@ probe ioscheduler.elv_add_request.tp = kernel.trace("block_rq_insert") ? + elevator_name = kernel_string( + @choose_defined($rq->q->elevator->type->elevator_name, + @choose_defined($rq->q->elevator->elevator_type->elevator_name, +- $rq->q->elevator->elevator_name)), "") ++ @choose_defined($rq->q->elevator->elevator_name, ++ 0))), "") + rq = $rq + + if ($rq == 0 || $rq->rq_disk ==0) { +@@ -201,7 +206,8 @@ probe ioscheduler_trace.elv_completed_request + elevator_name = kernel_string( + @choose_defined($rq->q->elevator->type->elevator_name, + @choose_defined($rq->q->elevator->elevator_type->elevator_name, +- $rq->q->elevator->elevator_name)), "") ++ @choose_defined($rq->q->elevator->elevator_name, ++ 0))), "") + + rq = $rq + +@@ -237,7 +243,8 @@ probe ioscheduler_trace.elv_issue_request + elevator_name = kernel_string( + @choose_defined($rq->q->elevator->type->elevator_name, + @choose_defined($rq->q->elevator->elevator_type->elevator_name, +- $rq->q->elevator->elevator_name)), "") ++ @choose_defined($rq->q->elevator->elevator_name, ++ 0))), "") + rq = $rq + + if ($rq == 0 || $rq->rq_disk ==0) { +@@ -272,7 +279,8 @@ probe ioscheduler_trace.elv_requeue_request + elevator_name = kernel_string( + @choose_defined($rq->q->elevator->type->elevator_name, + @choose_defined($rq->q->elevator->elevator_type->elevator_name, +- $rq->q->elevator->elevator_name)), "") ++ @choose_defined($rq->q->elevator->elevator_name, ++ 0))), "") + rq = $rq + + if ($rq == 0 || $rq->rq_disk ==0) { +@@ -306,7 +314,8 @@ probe ioscheduler_trace.elv_abort_request + elevator_name = kernel_string( + @choose_defined($rq->q->elevator->type->elevator_name, + @choose_defined($rq->q->elevator->elevator_type->elevator_name, +- $rq->q->elevator->elevator_name)), "") ++ @choose_defined($rq->q->elevator->elevator_name, ++ 0))), "") + rq = $rq + + if ($rq == 0 || $rq->rq_disk ==0) { +@@ -364,6 +373,9 @@ probe ioscheduler_trace.unplug_timer = kernel.trace("block_unplug_timer") ? + + function disk_major_from_request:long(var_q:long) + %{ /* pure */ ++#ifndef _ELEVATOR_H ++ STAP_ERROR ("unsupported (PR28634)"); ++#else + struct request_queue *q = (struct request_queue *)((uintptr_t)STAP_ARG_var_q); + + /* We need to make sure there isn't a deref hazard here when +@@ -382,10 +394,14 @@ function disk_major_from_request:long(var_q:long) + STAP_RETVALUE = kread(&(rq_disk->major)); + } + CATCH_DEREF_FAULT(); ++#endif + %} + + function disk_minor_from_request:long(var_q:long) + %{ /* pure */ ++#ifndef _ELEVATOR_H ++ STAP_ERROR ("unsupported (PR28634)"); ++#else + struct request_queue *q = (struct request_queue *)((uintptr_t)STAP_ARG_var_q); + + /* We need to make sure there isn't a deref hazard here when +@@ -404,4 +420,6 @@ function disk_minor_from_request:long(var_q:long) + STAP_RETVALUE = kread(&(rq_disk->first_minor)); + } + CATCH_DEREF_FAULT(); ++#endif + %} ++ +diff --git a/testsuite/systemtap.examples/io/iostat-scsi.stp b/testsuite/systemtap.examples/io/iostat-scsi.stp +index 6b1bf19ea..3faf32fe9 100755 +--- a/testsuite/systemtap.examples/io/iostat-scsi.stp ++++ b/testsuite/systemtap.examples/io/iostat-scsi.stp +@@ -26,6 +26,7 @@ probe module("sd_mod").function("sd_init_command") !, + %(kernel_v >= "2.6.31" %? + %{ + #include ++#include + %} + + function get_nr_sectors:long(rq:long) +@@ -47,13 +48,24 @@ probe sd_prep_fn = module("sd_mod").function("sd_prep_fn") !, + _cmd_flags = $rq->cmd_flags + } + ++function scsi_cmd_to_rq(scmd) { ++ return scmd - @cast_module_sizeof("kernel", "request") ++} ++ + probe sd_init_command = module("sd_mod").function("sd_init_command") !, + kernel.function("sd_init_command") + { +- device = kernel_string(@choose_defined($cmd, $SCpnt)->request->rq_disk->disk_name) +- sector_size = @choose_defined($cmd, $SCpnt)->device->sector_size +- nr_sectors = get_nr_sectors(@choose_defined($cmd, $SCpnt)->request) +- _cmd_flags = @choose_defined($cmd, $SCpnt)->request->cmd_flags ++ sector_size = @choose_defined($cmd, $SCpnt)->device->sector_size ++ # Kernel commits aa8e25e5006aac52c943c84e9056ab488630ee19 2266a2def97ce11ec979b6c58a1b637a16eca7dd ++ if (@defined(@choose_defined($cmd, $SCpnt)->request)) { ++ device = kernel_string(@choose_defined($cmd, $SCpnt)->request->rq_disk->disk_name) ++ nr_sectors = get_nr_sectors(@choose_defined($cmd, $SCpnt)->request) ++ _cmd_flags = @choose_defined($cmd, $SCpnt)->request->cmd_flags ++ } else { ++ device = kernel_string(@cast(scsi_cmd_to_rq(@choose_defined($cmd, $SCpnt)), "request", "kernel")->rq_disk->disk_name) ++ nr_sectors = get_nr_sectors(scsi_cmd_to_rq(@choose_defined($cmd, $SCpnt))) ++ _cmd_flags = @cast(scsi_cmd_to_rq(@choose_defined($cmd, $SCpnt)), "request", "kernel")->cmd_flags ++ } + } + + probe sd_prep_fn !, sd_init_command +@@ -71,7 +83,8 @@ probe sd_prep_fn !, sd_init_command + probe module("st").function("st_do_scsi").call !, + kernel.function("st_do_scsi").call + { +- device = kernel_string($STp->disk->disk_name) ++ # Kernel commit 45938335d0a9773d65a82a7ca722bb76e4b997a8 ++ device = kernel_string(@choose_defined($STp->disk->disk_name, $STp->name)) + devices[device] = 1 + if ($direction) + writes[device] <<< $bytes diff --git a/SOURCES/rhbz2047256.patch b/SOURCES/rhbz2047256.patch new file mode 100644 index 0000000..08260cd --- /dev/null +++ b/SOURCES/rhbz2047256.patch @@ -0,0 +1,179 @@ +diff --git a/analysis.cxx b/analysis.cxx +index a7a579e..d0d6a4f 100644 +--- a/analysis.cxx ++++ b/analysis.cxx +@@ -7,6 +7,7 @@ + // later version. + + #include "config.h" ++#include "session.h" + + #ifdef HAVE_DYNINST + +@@ -46,6 +47,8 @@ analysis::analysis(string name) + char *name_str = strdup(name.c_str()); + sts = NULL; + co = NULL; ++ SymtabAPI::Symtab *symTab; ++ bool isParsable; + + // Use cached information if available + if (cached_info.find(name) != cached_info.end()) { +@@ -56,6 +59,9 @@ analysis::analysis(string name) + + // Not not seen before + // Create a new binary code object from the filename argument ++ isParsable = SymtabAPI::Symtab::openFile(symTab, name_str); ++ if(!isParsable) goto cleanup; ++ + sts = new SymtabCodeSource(name_str); + if(!sts) goto cleanup; + +@@ -143,39 +149,40 @@ static const MachRegister dyninst_register_64[] = { + static const MachRegister dyninst_register_32[1]; // No 32-bit support + + #elif defined(__powerpc__) ++/* For ppc64 still use the ppc32 register names */ + static const MachRegister dyninst_register_64[] = { +- ppc64::r0, +- ppc64::r1, +- ppc64::r2, +- ppc64::r3, +- ppc64::r4, +- ppc64::r5, +- ppc64::r6, +- ppc64::r7, +- ppc64::r8, +- ppc64::r9, +- ppc64::r10, +- ppc64::r11, +- ppc64::r12, +- ppc64::r13, +- ppc64::r14, +- ppc64::r15, +- ppc64::r16, +- ppc64::r17, +- ppc64::r18, +- ppc64::r19, +- ppc64::r20, +- ppc64::r21, +- ppc64::r22, +- ppc64::r23, +- ppc64::r24, +- ppc64::r25, +- ppc64::r26, +- ppc64::r27, +- ppc64::r28, +- ppc64::r29, +- ppc64::r30, +- ppc64::r31 ++ ppc32::r0, ++ ppc32::r1, ++ ppc32::r2, ++ ppc32::r3, ++ ppc32::r4, ++ ppc32::r5, ++ ppc32::r6, ++ ppc32::r7, ++ ppc32::r8, ++ ppc32::r9, ++ ppc32::r10, ++ ppc32::r11, ++ ppc32::r12, ++ ppc32::r13, ++ ppc32::r14, ++ ppc32::r15, ++ ppc32::r16, ++ ppc32::r17, ++ ppc32::r18, ++ ppc32::r19, ++ ppc32::r20, ++ ppc32::r21, ++ ppc32::r22, ++ ppc32::r23, ++ ppc32::r24, ++ ppc32::r25, ++ ppc32::r26, ++ ppc32::r27, ++ ppc32::r28, ++ ppc32::r29, ++ ppc32::r30, ++ ppc32::r31 + }; + + static const MachRegister dyninst_register_32[] = { +@@ -218,14 +225,26 @@ static const MachRegister dyninst_register_32[] = { + typedef map precomputed_liveness; + static precomputed_liveness cached_liveness; + +-int liveness(string executable, ++int liveness(systemtap_session& s, ++ target_symbol *e, ++ string executable, + Dwarf_Addr addr, + location_context ctx) + { ++ try{ ++ // Doing this inside a try/catch because dyninst may require ++ // too much memory to parse the binary. + // should cache the executable names like the other things + analysis func_to_analyze(executable); + MachRegister r; + ++ // Punt if unsuccessful in parsing binary ++ if (!func_to_analyze.co){ ++ s.print_warning(_F("liveness analysis unable to parse binary %s", ++ executable.c_str()), e->tok); ++ return 0; ++ } ++ + // Determine whether 32-bit or 64-bit code as the register names are different in dyninst + int reg_width = func_to_analyze.co->cs()->getAddressWidth(); + +@@ -282,6 +301,11 @@ int liveness(string executable, + bool used; + la->query(iloc, LivenessAnalyzer::Before, r, used); + return (used ? 1 : -1); ++ } catch (std::bad_alloc & ex){ ++ s.print_warning(_F("unable to allocate memory for liveness analysis of %s", ++ executable.c_str()), e->tok); ++ return 0; ++ } + } + + #endif // HAVE_DYNINST +diff --git a/analysis.h b/analysis.h +index 9b6d115..6bea675 100644 +--- a/analysis.h ++++ b/analysis.h +@@ -17,13 +17,15 @@ + + #ifdef HAVE_DYNINST + +-extern int liveness(std::string executable, ++extern int liveness(systemtap_session& s, ++ target_symbol *e, ++ std::string executable, + Dwarf_Addr location, + location_context ctx); + + #else + +-#define liveness(executable, location, var) (0) ++#define liveness(session, target, executable, location, var) (0) + + #endif // HAVE_DYNINST + #endif // ANALYSIS_H +diff --git a/tapsets.cxx b/tapsets.cxx +index 60794bb..8fc5146 100644 +--- a/tapsets.cxx ++++ b/tapsets.cxx +@@ -4732,7 +4732,7 @@ dwarf_var_expanding_visitor::visit_target_symbol (target_symbol *e) + + // Now that have location information check if change to variable has any effect + if (lvalue) { +- if (liveness(q.dw.mod_info->elf_path, addr, ctx) < 0) { ++ if (liveness(q.sess, e, q.dw.mod_info->elf_path, addr, ctx) < 0) { + q.sess.print_warning(_F("write at %p will have no effect", + (void *)addr), e->tok); + } diff --git a/SOURCES/sdt-asm-glibc.patch b/SOURCES/sdt-asm-glibc.patch index 878a01d..0aa9261 100644 --- a/SOURCES/sdt-asm-glibc.patch +++ b/SOURCES/sdt-asm-glibc.patch @@ -116,6 +116,14 @@ index 4f2539c93..530a79175 100644 + else + printf("FAIL: %s (%d/%d != 42/43)\n", $$name, $arg1, $arg2) +} +commit 209b5a19c (HEAD -> master, origin/master, origin/HEAD) +Author: Stan Cox +Date: Tue Dec 7 09:55:01 2021 -0500 + + sys/sdt.h fp constraints: aarch64, s390 + + Remove float constraints as per commit 1d3653936 but for aarch64 and s390. + commit 1d3653936 (HEAD -> master, origin/master, origin/HEAD) Author: Frank Ch. Eigler Date: Mon Dec 6 12:06:06 2021 -0500 @@ -131,16 +139,16 @@ Date: Mon Dec 6 12:06:06 2021 -0500 We may need to restore previous constraints broadly, forcing the compiler to plop floating point parameters into integer storage. -diff --git a/includes/sys/sdt.h b/includes/sys/sdt.h -index 24d5e01c3..3e1f00b6c 100644 --- a/includes/sys/sdt.h +++ b/includes/sys/sdt.h -@@ -101,7 +101,7 @@ - # if defined __powerpc__ +@@ -102,9 +102,5 @@ # define STAP_SDT_ARG_CONSTRAINT nZr # elif defined __x86_64__ -# define STAP_SDT_ARG_CONSTRAINT norfxy +-# elif defined __aarch64__ +-# define STAP_SDT_ARG_CONSTRAINT norw +-# elif defined __s390__ || defined __s390x__ +-# define STAP_SDT_ARG_CONSTRAINT norf +# define STAP_SDT_ARG_CONSTRAINT norx - # elif defined __aarch64__ - # define STAP_SDT_ARG_CONSTRAINT norw - # elif defined __s390__ || defined __s390x__ + # else + # define STAP_SDT_ARG_CONSTRAINT nor diff --git a/SPECS/systemtap.spec b/SPECS/systemtap.spec index 57ca607..c0b1e8f 100644 --- a/SPECS/systemtap.spec +++ b/SPECS/systemtap.spec @@ -118,7 +118,7 @@ m stapdev stapdev Name: systemtap Version: 4.6 -Release: 4%{?release_override}%{?dist} +Release: 11%{?release_override}%{?dist} # for version, see also configure.ac @@ -157,6 +157,10 @@ Source: ftp://sourceware.org/pub/systemtap/releases/systemtap-%{version}.tar.gz Patch1: rhbz2025054python3.patch Patch2: rhbz1972798.patch Patch3: sdt-asm-glibc.patch +Patch4: rhbz2041526.patch +Patch5: rhbz2027683.patch +Patch6: rhbz2047256.patch +Patch7: rhbz2039207.patch # Build* BuildRequires: make @@ -581,6 +585,10 @@ systemtap-runtime-virthost machine to execute systemtap scripts. %patch1 -p1 %patch2 -p1 %patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 +%patch7 -p1 %build @@ -1277,6 +1285,22 @@ exit 0 # PRERELEASE %changelog +* Wed Feb 2 2022 Stan Cox - 4.6-11 +- rhbz2039207: Attempt userspace string access if kernel access fails + +* Tue Feb 1 2022 Martin Cermak - 4.6-10 +- rhbz2047256: [ppc64le] Assertion `index >= 0' failed + +* Fri Jan 21 2022 Martin Cermak - 4.6-9 +- rhbz2027683: python tapset regression +- rhbz2027683: systemtap.examples/io/iostat-scsi.stp PR28633 + +* Mon Jan 17 2022 Martin Cermak - 4.6-6 +- rhbz2041526/pr28634: move elevator.h to block/ + +* Tue Dec 07 2021 Stan Cox - 4.6.5 +- sys/sdt.h remove aarch64 and s390 float constraints + * Mon Dec 06 2021 Stan Cox - 4.6.4 - sys/sdt.h remove float constraints that may cause gcc reload issues.