mfabik / rpms / satyr

Forked from rpms/satyr 3 years ago
Clone

Blame SOURCES/satyr-0.13-disable-hook-unwind-on-kernels-w-o-PTRACE_SEIZE.patch

0e0bbf
From c1497bdb2a1deaa467fa75a80b1fb993a7d500f5 Mon Sep 17 00:00:00 2001
0e0bbf
From: Martin Milata <mmilata@redhat.com>
0e0bbf
Date: Mon, 8 Dec 2014 15:37:17 +0100
0e0bbf
Subject: [PATCH 5/5] Disable hook unwind on kernels w/o PTRACE_SEIZE
0e0bbf
0e0bbf
Related to abrt/abrt#829.
0e0bbf
0e0bbf
Signed-off-by: Martin Milata <mmilata@redhat.com>
0e0bbf
---
0e0bbf
 lib/core_unwind.c          | 7 ++++---
0e0bbf
 lib/core_unwind_elfutils.c | 6 ++++++
0e0bbf
 2 files changed, 10 insertions(+), 3 deletions(-)
0e0bbf
0e0bbf
diff --git a/lib/core_unwind.c b/lib/core_unwind.c
0e0bbf
index 8599f0f..cf9973a 100644
0e0bbf
--- a/lib/core_unwind.c
0e0bbf
+++ b/lib/core_unwind.c
0e0bbf
@@ -25,6 +25,7 @@
0e0bbf
 #include <string.h>
0e0bbf
 #include <errno.h>
0e0bbf
 #include <sys/procfs.h> /* struct elf_prstatus */
0e0bbf
+#include <sys/ptrace.h> /* PTRACE_SEIZE */
0e0bbf
 
0e0bbf
 #include "utils.h"
0e0bbf
 #include "core/unwind.h"
0e0bbf
@@ -52,19 +53,19 @@ sr_parse_coredump(const char *coredump_filename,
0e0bbf
 
0e0bbf
 #endif /* !defined WITH_LIBDWFL && !defined WITH_LIBUNWIND */
0e0bbf
 
0e0bbf
-#if !defined WITH_LIBDWFL
0e0bbf
+#if (!defined WITH_LIBDWFL || !defined PTRACE_SEIZE)
0e0bbf
 
0e0bbf
 struct sr_core_stacktrace *
0e0bbf
 sr_core_stacktrace_from_core_hook(pid_t thread_id,
0e0bbf
                                   const char *executable_filename,
0e0bbf
                                   int signum,
0e0bbf
-                                  char **error_message);
0e0bbf
+                                  char **error_message)
0e0bbf
 {
0e0bbf
     *error_message = sr_asprintf("satyr is built without live process unwind support");
0e0bbf
     return NULL;
0e0bbf
 }
0e0bbf
 
0e0bbf
-#endif /* !defined WITH_LIBDWFL */
0e0bbf
+#endif /* !defined WITH_LIBDWFL || !defined PTRACE_SEIZE */
0e0bbf
 
0e0bbf
 /* FIXME: is there another way to pass the executable name to the find_elf
0e0bbf
  * callback? */
0e0bbf
diff --git a/lib/core_unwind_elfutils.c b/lib/core_unwind_elfutils.c
0e0bbf
index eb366cd..1482dba 100644
0e0bbf
--- a/lib/core_unwind_elfutils.c
0e0bbf
+++ b/lib/core_unwind_elfutils.c
0e0bbf
@@ -212,6 +212,10 @@ fail:
0e0bbf
     return stacktrace;
0e0bbf
 }
0e0bbf
 
0e0bbf
+/* If PTRACE_SEIZE is not defined (kernel < 3.4), stub function from
0e0bbf
+ * core_unwind.c is used. */
0e0bbf
+#ifdef PTRACE_SEIZE
0e0bbf
+
0e0bbf
 struct sr_core_stacktrace *
0e0bbf
 sr_core_stacktrace_from_core_hook(pid_t tid,
0e0bbf
                                   const char *executable,
0e0bbf
@@ -344,4 +348,6 @@ fail:
0e0bbf
     return stacktrace;
0e0bbf
 }
0e0bbf
 
0e0bbf
+#endif /* PTRACE_SEIZE */
0e0bbf
+
0e0bbf
 #endif /* WITH_LIBDWFL */
0e0bbf
-- 
0e0bbf
2.4.3
0e0bbf