diff options
Diffstat (limited to 'compiler-rt/lib/hwasan/hwasan_thread.cc')
-rw-r--r-- | compiler-rt/lib/hwasan/hwasan_thread.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/compiler-rt/lib/hwasan/hwasan_thread.cc b/compiler-rt/lib/hwasan/hwasan_thread.cc index ad2afb29939..75b831b3192 100644 --- a/compiler-rt/lib/hwasan/hwasan_thread.cc +++ b/compiler-rt/lib/hwasan/hwasan_thread.cc @@ -29,7 +29,7 @@ HwasanThread *HwasanThread::Create(thread_callback_t start_routine, thread->start_routine_ = start_routine; thread->arg_ = arg; thread->destructor_iterations_ = GetPthreadDestructorIterations(); - thread->random_state_ = RandomSeed(); + thread->random_state_ = flags()->random_tags ? RandomSeed() : 0; return thread; } @@ -97,11 +97,15 @@ static u32 xorshift(u32 state) { tag_t HwasanThread::GenerateRandomTag() { tag_t tag; do { - if (!random_buffer_) - random_buffer_ = random_state_ = xorshift(random_state_); - CHECK(random_buffer_); - tag = random_buffer_ & 0xFF; - random_buffer_ >>= 8; + if (flags()->random_tags) { + if (!random_buffer_) + random_buffer_ = random_state_ = xorshift(random_state_); + CHECK(random_buffer_); + tag = random_buffer_ & 0xFF; + random_buffer_ >>= 8; + } else { + tag = random_state_ = (random_state_ + 1) & 0xFF; + } } while (!tag); return tag; } |