Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,11 @@ void MaybeReenterWithoutASLR(int /*argc*/, char** argv) {
if ((internal::get_as_unsigned(new_personality) & ADDR_NO_RANDOMIZE) == 0)
return;

// Some security profiles clear ADDR_NO_RANDOMIZE across exec even though the
// personality appears updated here. Avoid re-entering forever in that case.
constexpr const char* kAslrReexecEnv = "BENCHMARK_ASLR_NO_REEXEC";
if (std::getenv(kAslrReexecEnv) != nullptr) return;
if (setenv(kAslrReexecEnv, "1", 1) != 0) return;
execv(argv[0], argv);
// The exec() functions return only if an error has occurred,
// in which case we want to just continue as-is.
Expand Down