diff --git a/PR23879-PR24875.patch b/PR23879-PR24875.patch new file mode 100644 index 0000000..c024b7c --- /dev/null +++ b/PR23879-PR24875.patch @@ -0,0 +1,42 @@ +From 4ae4592f1106e941023a5768d34c2381cc869631 Mon Sep 17 00:00:00 2001 +From: "Frank Ch. Eigler" +Date: Wed, 21 Aug 2019 19:29:45 -0400 +Subject: [PATCH] PR23879, PR24875: fix task-finder-vma on f29+ + +It was reported & rediscovered that some vma-dependent runtime +facilities have been broken: @vma() and *ubacktrace(). It turns out +that modern gcc/ld.so links/loads binaries in slightly different ways +than older toolchains. Specifically, the first page of ELF files is +now loaded only r--p instead of r-xp protection flags. The +_stp_vma_mmap_cb() routine now accepts the r--p case too. It now +ignores the flags entirely. +--- + runtime/vma.c | 11 ++++++++--- + 1 file changed, 8 insertions(+), 3 deletions(-) + +diff --git a/runtime/vma.c b/runtime/vma.c +index 7021725d6..02f9bf849 100644 +--- a/runtime/vma.c ++++ b/runtime/vma.c +@@ -157,10 +157,15 @@ static int _stp_vma_mmap_cb(struct stap_task_finder_target *tgt, + dbug_task_vma(1, + "mmap_cb: tsk %d:%d path %s, addr 0x%08lx, length 0x%08lx, offset 0x%lx, flags 0x%lx\n", + tsk->pid, tsk->tgid, path, addr, length, offset, vm_flags); +- // We are only interested in the first load of the whole module that +- // is executable. We register whether or not we know the module, ++ ++ // We used to be only interested in the first load of the whole module that ++ // is executable. But with modern enough gcc/ld.so, executables are mapped ++ // in more small pieces (r--p,r-xp,rw-p, instead of r-xp, rw-p). To establish ++ // the virtual base address, we initially look for an offset=0 mapping. ++ // ++ // We register whether or not we know the module, + // so we can later lookup the name given an address for this task. +- if (path != NULL && offset == 0 && (vm_flags & VM_EXEC) ++ if (path != NULL && offset == 0 + && stap_find_vma_map_info(tsk, addr, NULL, NULL, NULL, NULL) != 0) { + for (i = 0; i < _stp_num_modules; i++) { + // PR20433: papering over possibility of NULL pointers +-- +2.21.0 + diff --git a/PR24904-changes-wit.patch b/PR24904-changes-wit.patch new file mode 100644 index 0000000..e2dc237 --- /dev/null +++ b/PR24904-changes-wit.patch @@ -0,0 +1,26 @@ +From f4f0da6db3be523472b25a219ea245fd6d3489f9 Mon Sep 17 00:00:00 2001 +From: "Frank Ch. Eigler" +Date: Tue, 20 Aug 2019 22:17:02 -0400 +Subject: [PATCH] PR24904: support linux 5.2's stacktrace.c changes with + -DDEBUG_UNWIND too + +--- + runtime/stack.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/runtime/stack.c b/runtime/stack.c +index bf59b2909..6ec7b2602 100644 +--- a/runtime/stack.c ++++ b/runtime/stack.c +@@ -56,7 +56,7 @@ _stp_init_stack(void) + { + stack_trace_save_regs_fn = (void*) kallsyms_lookup_name("stack_trace_save_regs"); + dbug_unwind(1, "stack_trace_saves_regs_fn=%lx for _stp_stack_print_fallback().\n", +- (unsigned long) save_trace_save_regs_fn); ++ (unsigned long) stack_trace_save_regs_fn); + return 0; + } + +-- +2.21.0 + diff --git a/PR24904-changes.patch b/PR24904-changes.patch new file mode 100644 index 0000000..5a9005d --- /dev/null +++ b/PR24904-changes.patch @@ -0,0 +1,130 @@ +From 49fa913a61e7f2941bb59c11d72a1aafa6930162 Mon Sep 17 00:00:00 2001 +From: "Frank Ch. Eigler" +Date: Tue, 20 Aug 2019 21:20:40 -0400 +Subject: [PATCH] PR24904: support linux 5.2's stacktrace.c changes + +The following kernel commit disabled the older struct stack_trace APIs +on architectures that support the newer stackwalk APIs. Provide an +adaptation layer to stack_trace_save_regs(). + +commit 214d8ca6ee854f696f75e75511fe66b409e656db +Author: Thomas Gleixner +Date: Thu Apr 25 11:45:21 2019 +0200 + + stacktrace: Provide common infrastructure +--- + buildrun.cxx | 2 + + .../linux/autoconf-stack-trace-save-regs.c | 8 ++++ + runtime/stack.c | 37 +++++++++++++++++-- + 3 files changed, 44 insertions(+), 3 deletions(-) + create mode 100644 runtime/linux/autoconf-stack-trace-save-regs.c + +diff --git a/buildrun.cxx b/buildrun.cxx +index 5e8d3b961..6ed744707 100644 +--- a/buildrun.cxx ++++ b/buildrun.cxx +@@ -485,6 +485,8 @@ compile_pass (systemtap_session& s) + output_autoconf(s, o, "autoconf-bio-bi_opf.c", "STAPCONF_BIO_BI_OPF", NULL); + output_autoconf(s, o, "autoconf-linux-sched_headers.c", + "STAPCONF_LINUX_SCHED_HEADERS", NULL); ++ output_autoconf(s, o, "autoconf-stack-trace-save-regs.c", ++ "STAPCONF_STACK_TRACE_SAVE_REGS", NULL); + + // used by runtime/linux/netfilter.c + output_exportconf(s, o, "nf_register_hook", "STAPCONF_NF_REGISTER_HOOK"); +diff --git a/runtime/linux/autoconf-stack-trace-save-regs.c b/runtime/linux/autoconf-stack-trace-save-regs.c +new file mode 100644 +index 000000000..8bf33391f +--- /dev/null ++++ b/runtime/linux/autoconf-stack-trace-save-regs.c +@@ -0,0 +1,8 @@ ++#include ++ ++unsigned int foo () ++{ ++ unsigned long e[10]; ++ struct pt_regs* r = 0; ++ return stack_trace_save_regs (r, & e[0], 10, 0); ++} +diff --git a/runtime/stack.c b/runtime/stack.c +index 0f649e8da..bf59b2909 100644 +--- a/runtime/stack.c ++++ b/runtime/stack.c +@@ -39,6 +39,7 @@ + #include "linux/uprobes-inc.h" + + #include ++ + #if defined(STAPCONF_KERNEL_STACKTRACE) || defined(STAPCONF_KERNEL_STACKTRACE_NO_BP) + #include + #endif +@@ -47,6 +48,20 @@ + #include + #endif + ++#if defined(STAPCONF_STACK_TRACE_SAVE_REGS) /* linux 5.2+ apprx. */ ++static __typeof__(stack_trace_save_regs) (*stack_trace_save_regs_fn); /* not exported */ ++ ++static int ++_stp_init_stack(void) ++{ ++ stack_trace_save_regs_fn = (void*) kallsyms_lookup_name("stack_trace_save_regs"); ++ dbug_unwind(1, "stack_trace_saves_regs_fn=%lx for _stp_stack_print_fallback().\n", ++ (unsigned long) save_trace_save_regs_fn); ++ return 0; ++} ++ ++#else /* ! STAPCONF_STACK_TRACE_SAVE_REGS */ ++ + static void (*(save_stack_trace_regs_fn))(struct pt_regs *regs, + struct stack_trace *trace); + +@@ -60,6 +75,10 @@ _stp_init_stack(void) + return 0; + } + ++#endif /* STAPCONF_STACK_TRACE_SAVE_REGS */ ++ ++ ++ + static void _stp_stack_print_fallback(unsigned long, struct pt_regs*, int, int, int); + + #ifdef STP_USE_DWARF_UNWINDER +@@ -168,9 +187,19 @@ static void _stp_stack_print_fallback(unsigned long sp, struct pt_regs *regs, + int sym_flags, + int levels, int skip) { + unsigned long entries[MAXBACKTRACE]; +- struct stack_trace trace; +- int i; ++ unsigned i; ++ unsigned num_entries; ++ ++#if defined(STAPCONF_STACK_TRACE_SAVE_REGS) /* linux 5.2+ apprx. */ ++ if (!stack_trace_save_regs_fn) { ++ dbug_unwind(1, "no fallback kernel stacktrace (giving up)\n"); ++ _stp_print_addr(0, sym_flags | _STP_SYM_INEXACT, NULL); ++ return; ++ } + ++ num_entries = (*stack_trace_save_regs_fn)(regs, &entries[0], MAXBACKTRACE, skip); ++#else ++ struct stack_trace trace; + /* If don't have save_stack_trace_regs unwinder, just give up. */ + if (!save_stack_trace_regs_fn) { + dbug_unwind(1, "no fallback kernel stacktrace (giving up)\n"); +@@ -189,9 +218,11 @@ static void _stp_stack_print_fallback(unsigned long sp, struct pt_regs *regs, + dbug_unwind(1, "trace.nr_entries: %d\n", trace.nr_entries); + dbug_unwind(1, "trace.max_entries: %d\n", trace.max_entries); + dbug_unwind(1, "trace.skip %d\n", trace.skip); ++ num_entries = trace.nr_entries; ++#endif + + /* save_stack_trace_reg() adds a ULONG_MAX after last valid entry. Ignore it. */ +- for (i=0; i - 4.2-0.20190827 +- PR23879,PR24875 - fix task finder vma on f29 +- PR24904 - support linux 5.2 stacktrace.c changes +- PR24904 - support linux 5.2 stacktrace.c changes with -DDEBUG_UNWIND too + * Wed Aug 07 2019 Frank Ch. Eigler - 4.2-0.20190807gitebfc300ec2ad - Automated weekly rawhide release - Applied spec changes from upstream git