This is an archive of the discontinued LLVM Phabricator instance.

[hwasan] Add heap tag randomization.
ClosedPublic

Authored by eugenis on Dec 28 2017, 1:34 PM.

Details

Summary

Generate tags for heap allocations from a pseudo-random sequence
seeded with getrandom(), where available.

Diff Detail

Repository
rL LLVM

Event Timeline

eugenis created this revision.Dec 28 2017, 1:34 PM
alekseyshl accepted this revision.Dec 31 2017, 1:11 PM
alekseyshl added inline comments.
compiler-rt/lib/hwasan/hwasan_thread.cc
100 ↗(On Diff #128304)

GetRandom and xorshift can result in 0, right? Maybe this and drop CHECK:

if (!random_buffer_) {
  random_state_ = xorshift(random_state_);
  while (!random_state)
    random_state = RandomSeed();
  random_buffer_ = random_state_;
}
This revision is now accepted and ready to land.Dec 31 2017, 1:11 PM
eugenis updated this revision to Diff 128482.Jan 2 2018, 5:31 PM

avoid zero random seed

compiler-rt/lib/hwasan/hwasan_thread.cc
100 ↗(On Diff #128304)

Good point, RandomSeed can be zero, but xorshift, as far as i can see, will never turn non-zero to zero. Fixed with a loop in RandomSeed.

This revision was automatically updated to reflect the committed changes.