Skip to content

Commit 4995099

Browse files
authored
Fix MaybeReenterWithoutASLR() in docker (#1985)
In some docker configurations the `personality()` function may return inconsistent results. Double check if the persona has been updated before reentering, otherwise we risk infinite loop. Fixes #1984.
1 parent f921cfb commit 4995099

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/benchmark.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,13 @@ void MaybeReenterWithoutASLR(int /*argc*/, char** argv) {
845845
// Have we failed to change the personality? That may happen.
846846
if (prev_personality == -1) return;
847847

848+
// Make sure the parsona has been updated with the no-ASLR flag,
849+
// otherwise we will try to reenter infinitely.
850+
// This seems impossible, but can happen in some docker configurations.
851+
const auto new_personality = personality(0xffffffff);
852+
if ((internal::get_as_unsigned(new_personality) & ADDR_NO_RANDOMIZE) == 0)
853+
return;
854+
848855
execv(argv[0], argv);
849856
// The exec() functions return only if an error has occurred,
850857
// in which case we want to just continue as-is.

0 commit comments

Comments
 (0)