src/cpu/x86/vm/templateTable_x86_64.cpp

Print this page
rev 5510 : 8027252: Crash in interpreter because get_unsigned_2_byte_index_at_bcp reads 4 bytes
Summary: Use 2-byte loads to load indexes from the byte code stream to avoid out of bounds reads.
Reviewed-by:

*** 566,576 **** locals_index(rbx); __ movptr(rax, aaddress(rbx)); } void TemplateTable::locals_index_wide(Register reg) { ! __ movl(reg, at_bcp(2)); __ bswapl(reg); __ shrl(reg, 16); __ negptr(reg); } --- 566,576 ---- locals_index(rbx); __ movptr(rax, aaddress(rbx)); } void TemplateTable::locals_index_wide(Register reg) { ! __ load_unsigned_short(reg, at_bcp(2)); __ bswapl(reg); __ shrl(reg, 16); __ negptr(reg); }
*** 1573,1583 **** --- 1573,1587 ---- InvocationCounter::counter_offset(); const ByteSize inv_offset = MethodCounters::invocation_counter_offset() + InvocationCounter::counter_offset(); // Load up edx with the branch displacement + if (is_wide) { __ movl(rdx, at_bcp(1)); + } else { + __ load_signed_short(rdx, at_bcp(1)); + } __ bswapl(rdx); if (!is_wide) { __ sarl(rdx, 16); }