Blame SOURCES/rhbz1566422.patch

e9129b
commit db9c9d6e30c6cfd7b85475b5c79ee2cc51201934
e9129b
Author: Serhei Makarov <smakarov@redhat.com>
e9129b
Date:   Tue Apr 17 11:35:00 2018 -0400
e9129b
e9129b
    RHBZ1566422 - fix spurious Build-id mismatch when probing reinserted kernel module
e9129b
    
e9129b
    Code for newer kernels did not clear the address of the notes-section
e9129b
    when a probed module was unloaded. This caused spurious Build-id mismatch
e9129b
    when the module was reinserted as new addresses are not computed for
e9129b
    dynamically loaded modules (see also: PR23068) and the Build-id check
e9129b
    was trying to read the notes section at the no-longer-valid old address.
e9129b
    
e9129b
    * runtime/sym.c (_stp_module_notifier): clear addresses on
e9129b
    MODULE_STATE_GOING in newer kernels (>=3.10) too.
e9129b
    * runtime/transport/symbols.c (_stp_kmodule_update_address): fix logic
e9129b
    error and clear notes section addr when reloc=NULL (aka. 'all').
e9129b
e9129b
diff --git a/runtime/sym.c b/runtime/sym.c
e9129b
index c11a35a..b6e0fd6 100644
e9129b
--- a/runtime/sym.c
e9129b
+++ b/runtime/sym.c
e9129b
@@ -1045,7 +1045,7 @@ static void _stp_kmodule_update_address(const char* module,
e9129b
       if (strcmp (_stp_modules[mi]->name, module))
e9129b
         continue;
e9129b
 
e9129b
-      if (reloc && !strcmp (note_sectname, reloc)) {
e9129b
+      if (!reloc || !strcmp (note_sectname, reloc)) {
e9129b
         dbug_sym(1, "module %s special section %s address %#lx\n",
e9129b
                  _stp_modules[mi]->name,
e9129b
                  note_sectname,
e9129b
diff --git a/runtime/transport/symbols.c b/runtime/transport/symbols.c
e9129b
index 64c2aeb..076c562 100644
e9129b
--- a/runtime/transport/symbols.c
e9129b
+++ b/runtime/transport/symbols.c
e9129b
@@ -167,6 +167,11 @@ static int _stp_module_notifier (struct notifier_block * nb,
e9129b
 		/* Verify build-id. */
e9129b
 		_stp_kmodule_check (mod->name);
e9129b
         }
e9129b
+        else if (val == MODULE_STATE_GOING) {
e9129b
+		/* Unregister all sections. */
e9129b
+		dbug_sym(2, "unregister sections\n");
e9129b
+		_stp_kmodule_update_address(mod->name, NULL, 0);
e9129b
+        }
e9129b
         else if (val != MODULE_STATE_GOING) {
e9129b
 		return NOTIFY_DONE;
e9129b
         }