summaryrefslogtreecommitdiff
path: root/lib/ubsan
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-09-17 19:15:54 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2015-09-17 19:15:54 +0000
commit15fcbfa83e8ccc2b1f20aff116590456a2513bc7 (patch)
tree2c2ba0b419f474abf9143eb4e6fe3a342fd41544 /lib/ubsan
parent27a3ba7df8436deb21883a787f1b3c955a79d684 (diff)
Revert "ubsan: Implement memory permission validation for vtables."
This reverts r247484 and two follow-up commits. Breaks ppc and x86_64 sanitizer bots. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@247921 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ubsan')
-rw-r--r--lib/ubsan/ubsan_type_hash_itanium.cc39
1 files changed, 0 insertions, 39 deletions
diff --git a/lib/ubsan/ubsan_type_hash_itanium.cc b/lib/ubsan/ubsan_type_hash_itanium.cc
index 3687c533e..b84e88d4c 100644
--- a/lib/ubsan/ubsan_type_hash_itanium.cc
+++ b/lib/ubsan/ubsan_type_hash_itanium.cc
@@ -17,7 +17,6 @@
#include "ubsan_type_hash.h"
#include "sanitizer_common/sanitizer_common.h"
-#include "sanitizer_common/sanitizer_procmaps.h"
// The following are intended to be binary compatible with the definitions
// given in the Itanium ABI. We make no attempt to be ODR-compatible with
@@ -192,45 +191,7 @@ struct VtablePrefix {
/// The type_info object describing the most-derived class type.
std::type_info *TypeInfo;
};
-
-#if SANITIZER_LINUX && !defined(__powerpc64__)
-bool isValidVptr(void *Vtable) {
- // Validate the memory permissions of the vtable pointer and the first
- // function pointer in the vtable. They should be r-- or r-x and r-x
- // respectively. Only enabled for Linux; this hasn't been tested on FreeBSD,
- // and vtables are writable on Mac (PR24782) so this won't work there.
- uptr FirstFunctionPtr = *reinterpret_cast<uptr *>(Vtable);
- bool ValidVtable = false, ValidFirstFunctionPtr = false;
- MemoryMappingLayout Layout(/*cache_enabled=*/true);
- uptr Start, End, Prot;
- while (Layout.Next(&Start, &End, 0, 0, 0, &Prot)) {
- if (Start <= ((uptr)Vtable) && ((uptr)Vtable) <= End &&
- (Prot == MemoryMappingLayout::kProtectionRead ||
- Prot == (MemoryMappingLayout::kProtectionRead |
- MemoryMappingLayout::kProtectionExecute)))
- ValidVtable = true;
- if (Start <= FirstFunctionPtr && FirstFunctionPtr <= End &&
- Prot == (MemoryMappingLayout::kProtectionRead |
- MemoryMappingLayout::kProtectionExecute))
- ValidFirstFunctionPtr = true;
- if (ValidVtable && ValidFirstFunctionPtr)
- return true;
- }
- return false;
-}
-#else // !SANITIZER_LINUX || __powerpc64__
-bool isValidVptr(void *Vtable) {
- return true;
-}
-#endif
-
VtablePrefix *getVtablePrefix(void *Vtable) {
- if (!IsAccessibleMemoryRange((uptr)Vtable, sizeof(void *)))
- return 0;
-
- if (!isValidVptr(Vtable))
- return 0;
-
VtablePrefix *Vptr = reinterpret_cast<VtablePrefix*>(Vtable);
if (!Vptr)
return 0;