File systemtap-make-kernel-dwarf-unwinder-work-with-kaslr.patch of Package systemtap-headers.14366

From: Mark Wielaard <mark@klomp.org>
Date: Wed Apr 18 15:00:24 2018 +0200
Subject: Make kernel DWARF unwinder work with kaslr
Git-commit: 17ee540dd61113fe4f557f191db3480db875cca1
References: bsc#1159449
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
Acked-by: Tony Jones <tonyj@suse.de>

    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 3a2d991c3..4c360d295 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);
openSUSE Build Service is sponsored by