Skip to content

Avoid repeated ASLR re-exec attempts#2193

Open
kiwigitops wants to merge 1 commit into
google:mainfrom
kiwigitops:fix-aslr-reexec-loop
Open

Avoid repeated ASLR re-exec attempts#2193
kiwigitops wants to merge 1 commit into
google:mainfrom
kiwigitops:fix-aslr-reexec-loop

Conversation

@kiwigitops
Copy link
Copy Markdown

Summary

  • add an environment sentinel before re-execing after ADDR_NO_RANDOMIZE is set
  • skip the re-exec if the process already attempted the ASLR-disable path once
  • avoid re-execing if the sentinel cannot be recorded

Context

This addresses the AppArmor case from #2184 where personality() reports ADDR_NO_RANDOMIZE as set before execv(), but the new process image loses that flag and re-enters the same code path forever.

Testing

  • git diff --check

I did not add a direct unit test because the behavior depends on Linux exec/personality interaction under an AppArmor-constrained process tree.

Comment thread src/benchmark.cc Outdated

// Some security profiles clear ADDR_NO_RANDOMIZE across exec even though the
// personality appears updated here. Avoid re-entering forever in that case.
static const char kAslrReexecEnv[] = "BENCHMARK_ASLR_NO_REEXEC";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this an array of strings if we only need a single string?

@kiwigitops kiwigitops force-pushed the fix-aslr-reexec-loop branch from a593ebd to eacc9ca Compare May 21, 2026 01:43
@kiwigitops
Copy link
Copy Markdown
Author

Updated to use a constexpr const char* for the env var name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants