Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: third_party/WebKit/Source/platform/heap/StackFrameDepth.cpp

Issue 1425243004: Overflow-proof the computation of stack region end. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "platform/heap/StackFrameDepth.h" 6 #include "platform/heap/StackFrameDepth.h"
7 7
8 #include "public/platform/Platform.h" 8 #include "public/platform/Platform.h"
9 9
10 #if OS(WIN) 10 #if OS(WIN)
(...skipping 24 matching lines...) Expand all
35 void StackFrameDepth::enableStackLimit() 35 void StackFrameDepth::enableStackLimit()
36 { 36 {
37 #if ENABLE(ASSERT) 37 #if ENABLE(ASSERT)
38 s_isEnabled = true; 38 s_isEnabled = true;
39 #endif 39 #endif
40 40
41 static const int kStackRoomSize = 1024; 41 static const int kStackRoomSize = 1024;
42 42
43 size_t stackSize = getUnderestimatedStackSize(); 43 size_t stackSize = getUnderestimatedStackSize();
44 if (stackSize) { 44 if (stackSize) {
45 size_t stackBase = reinterpret_cast<size_t>(getStackStart()); 45 Address stackBase = reinterpret_cast<Address>(getStackStart());
46 s_stackFrameLimit = stackBase - stackSize + kStackRoomSize; 46 RELEASE_ASSERT(stackSize > static_cast<const size_t>(kStackRoomSize));
47 size_t stackRoom = stackSize - kStackRoomSize;
48 RELEASE_ASSERT(stackBase > reinterpret_cast<Address>(stackRoom));
49 s_stackFrameLimit = reinterpret_cast<uintptr_t>(stackBase - stackRoom);
47 return; 50 return;
48 } 51 }
49 52
50 // Fallback version 53 // Fallback version
51 // Allocate a 32KB object on stack and query stack frame base after it. 54 // Allocate a 32KB object on stack and query stack frame base after it.
52 char dummy[kSafeStackFrameSize]; 55 char dummy[kSafeStackFrameSize];
53 s_stackFrameLimit = currentStackFrameBaseOnCallee(dummy); 56 s_stackFrameLimit = currentStackFrameBaseOnCallee(dummy);
54 57
55 // Assert that the stack frame can be used. 58 // Assert that the stack frame can be used.
56 dummy[sizeof(dummy) - 1] = 0; 59 dummy[sizeof(dummy) - 1] = 0;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return reinterpret_cast<void*>(__readgsqword(offsetof(NT_TIB64, StackBase))) ; 150 return reinterpret_cast<void*>(__readgsqword(offsetof(NT_TIB64, StackBase))) ;
148 #else 151 #else
149 return reinterpret_cast<void*>(__readfsdword(offsetof(NT_TIB, StackBase))); 152 return reinterpret_cast<void*>(__readfsdword(offsetof(NT_TIB, StackBase)));
150 #endif 153 #endif
151 #else 154 #else
152 #error Unsupported getStackStart on this platform. 155 #error Unsupported getStackStart on this platform.
153 #endif 156 #endif
154 } 157 }
155 158
156 } // namespace blink 159 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698