mfabik / rpms / satyr

Forked from rpms/satyr 3 years ago
Clone
Blob Blame History Raw
From c1497bdb2a1deaa467fa75a80b1fb993a7d500f5 Mon Sep 17 00:00:00 2001
From: Martin Milata <mmilata@redhat.com>
Date: Mon, 8 Dec 2014 15:37:17 +0100
Subject: [PATCH 5/5] Disable hook unwind on kernels w/o PTRACE_SEIZE

Related to abrt/abrt#829.

Signed-off-by: Martin Milata <mmilata@redhat.com>
---
 lib/core_unwind.c          | 7 ++++---
 lib/core_unwind_elfutils.c | 6 ++++++
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/lib/core_unwind.c b/lib/core_unwind.c
index 8599f0f..cf9973a 100644
--- a/lib/core_unwind.c
+++ b/lib/core_unwind.c
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <errno.h>
 #include <sys/procfs.h> /* struct elf_prstatus */
+#include <sys/ptrace.h> /* PTRACE_SEIZE */
 
 #include "utils.h"
 #include "core/unwind.h"
@@ -52,19 +53,19 @@ sr_parse_coredump(const char *coredump_filename,
 
 #endif /* !defined WITH_LIBDWFL && !defined WITH_LIBUNWIND */
 
-#if !defined WITH_LIBDWFL
+#if (!defined WITH_LIBDWFL || !defined PTRACE_SEIZE)
 
 struct sr_core_stacktrace *
 sr_core_stacktrace_from_core_hook(pid_t thread_id,
                                   const char *executable_filename,
                                   int signum,
-                                  char **error_message);
+                                  char **error_message)
 {
     *error_message = sr_asprintf("satyr is built without live process unwind support");
     return NULL;
 }
 
-#endif /* !defined WITH_LIBDWFL */
+#endif /* !defined WITH_LIBDWFL || !defined PTRACE_SEIZE */
 
 /* FIXME: is there another way to pass the executable name to the find_elf
  * callback? */
diff --git a/lib/core_unwind_elfutils.c b/lib/core_unwind_elfutils.c
index eb366cd..1482dba 100644
--- a/lib/core_unwind_elfutils.c
+++ b/lib/core_unwind_elfutils.c
@@ -212,6 +212,10 @@ fail:
     return stacktrace;
 }
 
+/* If PTRACE_SEIZE is not defined (kernel < 3.4), stub function from
+ * core_unwind.c is used. */
+#ifdef PTRACE_SEIZE
+
 struct sr_core_stacktrace *
 sr_core_stacktrace_from_core_hook(pid_t tid,
                                   const char *executable,
@@ -344,4 +348,6 @@ fail:
     return stacktrace;
 }
 
+#endif /* PTRACE_SEIZE */
+
 #endif /* WITH_LIBDWFL */
-- 
2.4.3