[PATCH] D41616: [hwasan] Add heap tag randomization.

Evgenii Stepanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 2 17:31:45 PST 2018


eugenis added inline comments.


================
Comment at: compiler-rt/lib/hwasan/hwasan_thread.cc:100
+      random_buffer_ = random_state_ = xorshift(random_state_);
+    CHECK(random_buffer_);
+    tag = random_buffer_ & 0xFF;
----------------
alekseyshl wrote:
> 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_;
>   }
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.



https://reviews.llvm.org/D41616





More information about the llvm-commits mailing list