Index: compiler-rt/lib/scudo/standalone/mem_map_base.h =================================================================== --- compiler-rt/lib/scudo/standalone/mem_map_base.h +++ compiler-rt/lib/scudo/standalone/mem_map_base.h @@ -25,6 +25,7 @@ // only a suggestion to the system. bool map(uptr Addr, uptr Size, const char *Name, uptr Flags = 0) { DCHECK(!isAllocated()); + DCHECK_EQ(Flags & ~AllowedMapFlags, 0); return invokeImpl(&Derived::mapImpl, Addr, Size, Name, Flags); } @@ -42,6 +43,7 @@ bool remap(uptr Addr, uptr Size, const char *Name, uptr Flags = 0) { DCHECK(isAllocated()); DCHECK((Addr >= getBase()) && (Addr + Size <= getBase() + getCapacity())); + DCHECK_EQ(Flags & ~AllowedMapFlags, 0); return invokeImpl(&Derived::remapImpl, Addr, Size, Name, Flags); } @@ -50,6 +52,7 @@ void setMemoryPermission(uptr Addr, uptr Size, uptr Flags) { DCHECK(isAllocated()); DCHECK((Addr >= getBase()) && (Addr + Size <= getBase() + getCapacity())); + DCHECK_EQ(Flags & ~MAP_NOACCESS, 0); return static_cast(this)->setMemoryPermissionImpl(Addr, Size, Flags); } @@ -80,6 +83,11 @@ R invokeImpl(R (Derived::*MemFn)(Args...), Args... args) { return (static_cast(this)->*MemFn)(args...); } + +private: + static const uptr AllowedMapFlags = MAP_ALLOWNOMEM | MAP_NOACCESS | + MAP_MEMTAG | MAP_PRECOMMIT | + MAP_RESIZABLE; }; // `ReservedMemory` is a special memory handle which can be viewed as a page @@ -96,6 +104,7 @@ // Reserve a chunk of memory at a suggested address. bool create(uptr Addr, uptr Size, const char *Name, uptr Flags = 0) { DCHECK(!isCreated()); + DCHECK_EQ(Flags & ~MAP_ALLOWNOMEM, 0); return invokeImpl(&Derived::createImpl, Addr, Size, Name, Flags); }