vestigia

Detect where execution depends on secrets.
git clone git://git.ppad.tech/vestigia.git
Log | Files | Refs | README | LICENSE

norandom.c (709B)


      1 /*
      2  * norandom.c: address-space randomisation off for this process and
      3  * every process it starts.
      4  *
      5  * Copyright (c) 2026 Jared Tobin
      6  * License: MIT
      7  *
      8  * Runs compared to find where a secret mattered must lay memory out
      9  * alike, or every address differs between them and none of the
     10  * differences means anything. The personality is inherited across
     11  * fork and exec, so setting it before starting QEMU covers the guest.
     12  */
     13 #ifdef __linux__
     14 #include <sys/personality.h>
     15 
     16 int vestigia_no_randomize(void) {
     17   int p = personality(0xffffffff);
     18   if (p == -1) return -1;
     19   return personality((unsigned long)p | ADDR_NO_RANDOMIZE) == -1 ? -1 : 0;
     20 }
     21 #else
     22 int vestigia_no_randomize(void) { return -1; }
     23 #endif