From c6a588ad5d62e4bdf4287e1faf448b32f32ae721 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 18 Apr 2018 16:57:44 +0200 Subject: [PATCH] 3.2-10 - Add unwind-fallback.patch - rhbz1566422.patch --- rhbz1566422.patch | 46 ++++++++++++++++++++++++++++++++++++++++++++++ systemtap.spec | 20 +++++++++++++++++--- unwind-ksalr.patch | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 rhbz1566422.patch create mode 100644 unwind-ksalr.patch diff --git a/rhbz1566422.patch b/rhbz1566422.patch new file mode 100644 index 0000000..494e4c9 --- /dev/null +++ b/rhbz1566422.patch @@ -0,0 +1,46 @@ +commit db9c9d6e30c6cfd7b85475b5c79ee2cc51201934 +Author: Serhei Makarov +Date: Tue Apr 17 11:35:00 2018 -0400 + + RHBZ1566422 - fix spurious Build-id mismatch when probing reinserted kernel module + + Code for newer kernels did not clear the address of the notes-section + when a probed module was unloaded. This caused spurious Build-id mismatch + when the module was reinserted as new addresses are not computed for + dynamically loaded modules (see also: PR23068) and the Build-id check + was trying to read the notes section at the no-longer-valid old address. + + * runtime/sym.c (_stp_module_notifier): clear addresses on + MODULE_STATE_GOING in newer kernels (>=3.10) too. + * runtime/transport/symbols.c (_stp_kmodule_update_address): fix logic + error and clear notes section addr when reloc=NULL (aka. 'all'). + +diff --git a/runtime/sym.c b/runtime/sym.c +index c11a35a..b6e0fd6 100644 +--- a/runtime/sym.c ++++ b/runtime/sym.c +@@ -1045,7 +1045,7 @@ static void _stp_kmodule_update_address(const char* module, + if (strcmp (_stp_modules[mi]->name, module)) + continue; + +- if (reloc && !strcmp (note_sectname, reloc)) { ++ if (!reloc || !strcmp (note_sectname, reloc)) { + dbug_sym(1, "module %s special section %s address %#lx\n", + _stp_modules[mi]->name, + note_sectname, +diff --git a/runtime/transport/symbols.c b/runtime/transport/symbols.c +index 64c2aeb..076c562 100644 +--- a/runtime/transport/symbols.c ++++ b/runtime/transport/symbols.c +@@ -167,6 +167,11 @@ static int _stp_module_notifier (struct notifier_block * nb, + /* Verify build-id. */ + _stp_kmodule_check (mod->name); + } ++ else if (val == MODULE_STATE_GOING) { ++ /* Unregister all sections. */ ++ dbug_sym(2, "unregister sections\n"); ++ _stp_kmodule_update_address(mod->name, NULL, 0); ++ } + else if (val != MODULE_STATE_GOING) { + return NOTIFY_DONE; + } diff --git a/systemtap.spec b/systemtap.spec index 8ba9656..07ed111 100644 --- a/systemtap.spec +++ b/systemtap.spec @@ -74,7 +74,7 @@ Name: systemtap Version: 3.2 -Release: 9%{?dist} +Release: 10%{?dist} # for version, see also configure.ac Patch10: rhbz1504009.patch @@ -83,9 +83,17 @@ Patch10: rhbz1504009.patch # upstream: https://sourceware.org/bugzilla/show_bug.cgi?id=22551 Patch11: rhbz1546563.patch -# Partial fix for backstrace issues. Add a new kernel fallback unwinder. +# Add a new kernel fallback unwinder. # upstream: commit 553b6df07c9b7ab30ed468a6a4374cbdf73d1c0d Patch13: unwind-fallback.patch +# And make the kernel DWARF unwinder work with ksalr. +# upstream: commit 17ee540dd61113fe4f557f191db3480db875cca1 +Patch14: unwind-ksalr.patch + +# Build-id mismatch with (re)inserted/removed kernel module probe +# redhat: https://bugzilla.redhat.com/show_bug.cgi?id=1566422 +# upstream: db9c9d6e30c6cfd7b85475b5c79ee2cc51201934 +Patch15: rhbz1566422.patch # Packaging abstract: # @@ -253,7 +261,7 @@ URL: http://sourceware.org/systemtap/ # kernel variant (kernel-PAE, kernel-debug, etc.) devel package # installed. Requires: kernel-devel-uname-r -%{?fedora:Suggests: kernel-devel} +#%{?fedora:Suggests: kernel-devel} Requires: gcc make # Suggest: kernel-debuginfo @@ -492,6 +500,8 @@ cd .. %patch11 -p1 %patch13 -p1 +%patch14 -p1 +%patch15 -p1 %build @@ -1172,6 +1182,10 @@ done # PRERELEASE %changelog +* Wed Apr 18 2018 Mark Wielaard - 3.2-10 +- Add unwind-fallback.patch +- rhbz1566422.patch + * Tue Apr 17 2018 Mark Wielaard - 3.2-9 - Add unwind-fallback.patch. diff --git a/unwind-ksalr.patch b/unwind-ksalr.patch new file mode 100644 index 0000000..6ed43ee --- /dev/null +++ b/unwind-ksalr.patch @@ -0,0 +1,32 @@ +commit 17ee540dd61113fe4f557f191db3480db875cca1 +Author: Mark Wielaard +Date: Wed Apr 18 15:00:24 2018 +0200 + + Make kernel DWARF unwinder work with ksalr. + + The .debug_frame loaded from disk is already relocated against the + expected load offset of the kernel, but the actual static (load) + address might be different (with kaslr). So adjust the startLoc + for that difference when reading any address from the unwind table. + +diff --git a/runtime/unwind.c b/runtime/unwind.c +index 3a2d991..4c360d2 100644 +--- a/runtime/unwind.c ++++ b/runtime/unwind.c +@@ -724,10 +724,15 @@ adjustStartLoc (unsigned long startLoc, + dbug_unwind(2, "adjustStartLoc=%lx, ptrType=%s, m=%s, s=%s eh=%d\n", + startLoc, _stp_eh_enc_name(ptrType), m->path, s->name, is_ehframe); + if (startLoc == 0 +- || strcmp (m->name, "kernel") == 0 + || (strcmp (s->name, ".absolute") == 0 && !is_ehframe)) + return startLoc; + ++ /* The .debug_frame loaded from disk is already relocated against the ++ expected load offset of the kernel, but the actual static (load) ++ address might be different (with kaslr). */ ++ if (strcmp (m->name, "kernel") == 0) ++ return startLoc - s->sec_load_offset + s->static_addr; ++ + /* eh_frame data has been loaded in the kernel, so readjust offset. */ + if (is_ehframe) { + dbug_unwind(2, "eh_frame=%lx, eh_frame_addr=%lx\n", (unsigned long) m->eh_frame, m->eh_frame_addr);