diff options
author | Alexander Potapenko <glider@google.com> | 2017-11-23 08:34:32 +0000 |
---|---|---|
committer | Alexander Potapenko <glider@google.com> | 2017-11-23 08:34:32 +0000 |
commit | 391804f54b2a98f163b685ee72f8f890c8094405 (patch) | |
tree | 9fac7da72c0555c8dc42747eff42263be9d2c933 /llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | |
parent | 270ced2bce385d69fa16d16a3bfc90eb90ab396d (diff) | |
download | bcm5719-llvm-391804f54b2a98f163b685ee72f8f890c8094405.tar.gz bcm5719-llvm-391804f54b2a98f163b685ee72f8f890c8094405.zip |
[MSan] Move the access address check before the shadow access for that address
MSan used to insert the shadow check of the store pointer operand
_after_ the shadow of the value operand has been written.
This happens to work in the userspace, as the whole shadow range is
always mapped. However in the kernel the shadow page may not exist, so
the bug may cause a crash.
This patch moves the address check in front of the shadow access.
llvm-svn: 318901
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp index 459e2b39b32..30b15195e8c 100644 --- a/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -830,10 +830,9 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> { StoreInst *NewSI = IRB.CreateAlignedStore(Shadow, ShadowPtr, SI->getAlignment()); DEBUG(dbgs() << " STORE: " << *NewSI << "\n"); - (void)NewSI; if (ClCheckAccessAddress) - insertShadowCheck(Addr, SI); + insertShadowCheck(Addr, NewSI); if (SI->isAtomic()) SI->setOrdering(addReleaseOrdering(SI->getOrdering())); |