[PATCH] D64453: [GWP-ASan] Add thread ID to PRNG seed.
Mitch Phillips via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 16 13:06:09 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366253: [GWP-ASan] Add thread ID to PRNG seed. (authored by hctim, committed by ).
Herald added a subscriber: delcypher.
Changed prior to commit:
https://reviews.llvm.org/D64453?vs=208827&id=210156#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64453/new/
https://reviews.llvm.org/D64453
Files:
compiler-rt/trunk/lib/gwp_asan/guarded_pool_allocator.h
compiler-rt/trunk/lib/gwp_asan/random.cpp
Index: compiler-rt/trunk/lib/gwp_asan/random.cpp
===================================================================
--- compiler-rt/trunk/lib/gwp_asan/random.cpp
+++ compiler-rt/trunk/lib/gwp_asan/random.cpp
@@ -7,12 +7,14 @@
//===----------------------------------------------------------------------===//
#include "gwp_asan/random.h"
+#include "gwp_asan/guarded_pool_allocator.h"
#include <time.h>
namespace gwp_asan {
uint32_t getRandomUnsigned32() {
- thread_local uint32_t RandomState = static_cast<uint64_t>(time(nullptr));
+ thread_local uint32_t RandomState =
+ time(nullptr) + GuardedPoolAllocator::getThreadID();
RandomState ^= RandomState << 13;
RandomState ^= RandomState >> 17;
RandomState ^= RandomState << 5;
Index: compiler-rt/trunk/lib/gwp_asan/guarded_pool_allocator.h
===================================================================
--- compiler-rt/trunk/lib/gwp_asan/guarded_pool_allocator.h
+++ compiler-rt/trunk/lib/gwp_asan/guarded_pool_allocator.h
@@ -132,6 +132,10 @@
// occur.
static void reportError(uintptr_t AccessPtr, Error E = Error::UNKNOWN);
+ // Get the current thread ID, or kInvalidThreadID if failure. Note: This
+ // implementation is platform-specific.
+ static uint64_t getThreadID();
+
private:
static constexpr size_t kInvalidSlotID = SIZE_MAX;
@@ -146,10 +150,6 @@
void markReadWrite(void *Ptr, size_t Size) const;
void markInaccessible(void *Ptr, size_t Size) const;
- // Get the current thread ID, or kInvalidThreadID if failure. Note: This
- // implementation is platform-specific.
- static uint64_t getThreadID();
-
// Get the page size from the platform-specific implementation. Only needs to
// be called once, and the result should be cached in PageSize in this class.
static size_t getPlatformPageSize();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64453.210156.patch
Type: text/x-patch
Size: 1824 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190716/410740df/attachment.bin>
More information about the llvm-commits
mailing list