about summary refs log tree commit diff
path: root/utils/libdislocator/libdislocator.so.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2022-04-25 10:14:19 +0200
committerGitHub <noreply@github.com>2022-04-25 10:14:19 +0200
commitc7bb0a9638a8929a5b664f16032c23a55a84be70 (patch)
tree2fb8cee9897c46a53e756e898de732c63f2a8842 /utils/libdislocator/libdislocator.so.c
parentac80678592ea4a790ab2eedccfec4e3bc9f96447 (diff)
parentee409d18a6678c3f5948f51db8964148cae021dc (diff)
downloadafl++-c7bb0a9638a8929a5b664f16032c23a55a84be70.tar.gz
Merge pull request #1392 from AFLplusplus/dev
push to stable
Diffstat (limited to 'utils/libdislocator/libdislocator.so.c')
-rw-r--r--utils/libdislocator/libdislocator.so.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/utils/libdislocator/libdislocator.so.c b/utils/libdislocator/libdislocator.so.c
index 103da9d5..bd08a678 100644
--- a/utils/libdislocator/libdislocator.so.c
+++ b/utils/libdislocator/libdislocator.so.c
@@ -39,6 +39,7 @@
 
 #if (defined(__linux__) && !defined(__ANDROID__)) || defined(__HAIKU__)
   #include <unistd.h>
+  #include <sys/prctl.h>
   #ifdef __linux__
     #include <sys/syscall.h>
     #include <malloc.h>
@@ -66,6 +67,10 @@
       } while (0)
 
   #endif
+  #ifndef PR_SET_VMA
+    #define PR_SET_VMA 0x53564d41
+    #define PR_SET_VMA_ANON_NAME 0
+  #endif
 #endif
 
 #include "config.h"
@@ -251,6 +256,20 @@ static void *__dislocator_alloc(size_t len) {
 
   }
 
+#if defined(USENAMEDPAGE)
+  #if defined(__linux__)
+  // in the /proc/<pid>/maps file, the anonymous page appears as
+  // `<start>-<end> ---p 00000000 00:00 0 [anon:libdislocator]`
+  if (prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)ret, tlen,
+            (unsigned long)"libdislocator") < 0) {
+
+    DEBUGF("prctl() failed");
+
+  }
+
+  #endif
+#endif
+
   /* Set PROT_NONE on the last page. */
 
   if (mprotect(ret + PG_COUNT(rlen + 8) * PAGE_SIZE, PAGE_SIZE, PROT_NONE))