Bug 595033 - nanojit: harden via random function alignment (wmaddox,nnethercote,edwsmith)

Introduce a random number of 'int3' instructions inbetween JIT'd methods.

NOTE: this feature is currently disabled

--HG--
extra : convert_revision : d75d0a918f8e048b92127188f47f4e1efcee9004
This commit is contained in:
Rick Reitmaier 2010-10-14 18:54:07 -07:00
Родитель c362275ffa
Коммит f269219ada
3 изменённых файлов: 14 добавлений и 0 удалений

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

@ -2815,6 +2815,16 @@ namespace nanojit
NanoAssert(!_inExit); NanoAssert(!_inExit);
if (!_nIns) if (!_nIns)
codeAlloc(codeStart, codeEnd, _nIns verbose_only(, codeBytes)); codeAlloc(codeStart, codeEnd, _nIns verbose_only(, codeBytes));
// add some random padding, so functions aren't predictably placed.
if (_config.harden_function_alignment)
{
int32_t pad = _noise->getValue(LARGEST_UNDERRUN_PROT);
underrunProtect(pad);
_nIns -= pad;
VMPI_memset(_nIns, INT3_OP, pad);
PERFM_NVPROF("hardening:func-align", pad);
}
} }
// enough room for n bytes // enough room for n bytes

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

@ -92,6 +92,7 @@ namespace nanojit
i386_use_cmov = (features & (1<<15)) != 0; i386_use_cmov = (features & (1<<15)) != 0;
i386_fixed_esp = false; i386_fixed_esp = false;
#endif #endif
harden_function_alignment = false;
#if defined(NANOJIT_ARM) #if defined(NANOJIT_ARM)

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

@ -94,6 +94,9 @@ namespace nanojit
// If true, use softfloat for all floating point operations, // If true, use softfloat for all floating point operations,
// whether or not an FPU is present. (ARM only for now, but might also includes MIPS in the future) // whether or not an FPU is present. (ARM only for now, but might also includes MIPS in the future)
uint32_t soft_float:1; uint32_t soft_float:1;
// If true, compiler will insert a random amount of space in between functions (x86-32 only)
uint32_t harden_function_alignment:1;
}; };
} }