Skip to content

Commit 676dcb5

Browse files
committed
Bug 1090598: Once we have hit the ah_crap_handler, allow any process (such as gdb) to ptrace us. r=froydnj
1 parent 3481ab9 commit 676dcb5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

toolkit/xre/nsSigHandlers.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <sys/resource.h>
2727
#include <unistd.h>
2828
#include <stdlib.h> // atoi
29+
#include <sys/prctl.h>
2930
#ifndef ANDROID // no Android impl
3031
# include <ucontext.h>
3132
#endif
@@ -44,6 +45,13 @@ static unsigned int _gdb_sleep_duration = 300;
4445
#define CRAWL_STACK_ON_SIGSEGV
4546
#endif
4647

48+
#ifndef PR_SET_PTRACER
49+
#define PR_SET_PTRACER 0x59616d61
50+
#endif
51+
#ifndef PR_SET_PTRACER_ANY
52+
#define PR_SET_PTRACER_ANY ((unsigned long)-1)
53+
#endif
54+
4755
#if defined(CRAWL_STACK_ON_SIGSEGV)
4856

4957
#include <unistd.h>
@@ -87,6 +95,9 @@ ah_crap_handler(int signum)
8795
_progname,
8896
getpid());
8997

98+
// Allow us to be ptraced by gdb on Linux with Yama restrictions enabled.
99+
prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
100+
90101
sleep(_gdb_sleep_duration);
91102

92103
printf("Done sleeping...\n");

0 commit comments

Comments
 (0)