Bug 998997 - Use PROT_NONE on POSIX and PAGE_NOACCESS on Windows when protecting JIT code. (r=luke)

This commit is contained in:
Shu-yu Guo 2014-04-22 14:13:14 -07:00
Родитель 00f0b8ed2f
Коммит 37a4de0a84
3 изменённых файлов: 11 добавлений и 4 удалений

Просмотреть файл

@ -99,9 +99,10 @@ ExecutablePool::toggleAllCodeAsAccessible(bool accessible)
size_t size = m_freePtr - begin;
if (size) {
int flags = accessible
? PROT_READ | PROT_WRITE | PROT_EXEC
: PROT_READ | PROT_WRITE;
// N.B. Some systems, like 32bit Mac OS 10.6, implicitly add PROT_EXEC
// when mprotect'ing memory with any flag other than PROT_NONE. Be
// sure to use PROT_NONE when making inaccessible.
int flags = accessible ? PROT_READ | PROT_WRITE | PROT_EXEC : PROT_NONE;
if (mprotect(begin, size, flags))
MOZ_CRASH();
}

Просмотреть файл

@ -116,8 +116,10 @@ ExecutablePool::toggleAllCodeAsAccessible(bool accessible)
size_t size = m_freePtr - begin;
if (size) {
// N.B. DEP is not on automatically in Windows XP, so be sure to use
// PAGE_NOACCESS instead of PAGE_READWRITE when making inaccessible.
DWORD oldProtect;
int flags = accessible ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
int flags = accessible ? PAGE_EXECUTE_READWRITE : PAGE_NOACCESS;
if (!VirtualProtect(begin, size, flags, &oldProtect))
MOZ_CRASH();
}

Просмотреть файл

@ -0,0 +1,4 @@
// |jit-test| exitstatus: 6;
timeout(1);
for(;;);