Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151779594
D33934.id101612.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D33934.id101612.diff
View Options
Index: contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
===================================================================
--- contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -2197,8 +2197,11 @@
}
if ((aslr_status & PROC_ASLR_ACTIVE) != 0) {
Printf("This sanitizer is not compatible with enabled ASLR "
- "and binaries compiled with PIE\n");
- Printf("Running anyway\n");
+ "and binaries compiled with PIE\n"
+ "ASLR will be disabled and the program re-executed.\n");
+ int aslr_ctl = PROC_ASLR_FORCE_DISABLE;
+ CHECK_NE(procctl(P_PID, 0, PROC_ASLR_CTL, &aslr_ctl), -1);
+ ReExec();
}
#else
// Do nothing
Index: contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
===================================================================
--- contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -46,7 +46,9 @@
#if SANITIZER_FREEBSD
#include <pthread_np.h>
+#include <stdlib.h>
#include <osreldate.h>
+#include <sys/auxv.h>
#include <sys/sysctl.h>
#define pthread_getattr_np pthread_attr_get_np
// The MAP_NORESERVE define has been removed in FreeBSD 11.x, and even before
@@ -865,7 +867,14 @@
void ReExec() {
const char *pathname = "/proc/self/exe";
-#if SANITIZER_NETBSD
+#if SANITIZER_FREEBSD
+ char exe_path[PATH_MAX];
+ if (elf_aux_info(AT_EXECPATH, exe_path, sizeof(exe_path)) == 0) {
+ char link_path[PATH_MAX];
+ if (realpath(exe_path, link_path))
+ pathname = link_path;
+ }
+#elif SANITIZER_NETBSD
static const int name[] = {
CTL_KERN,
KERN_PROC_ARGS,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 11, 3:15 PM (1 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31296584
Default Alt Text
D33934.id101612.diff (1 KB)
Attached To
Mode
D33934: compiler-rt: re-exec with ASLR disabled when necessary
Attached
Detach File
Event Timeline
Log In to Comment