8168699: Validate special case invocations

Reviewed-by: acorn, kvn, lfoltan, ctornqvi, ahgross, vlivanov
This commit is contained in:
Coleen Phillimore 2016-12-01 14:21:31 -05:00
parent f3a162f330
commit 1457155505
22 changed files with 193 additions and 35 deletions

View file

@ -720,7 +720,8 @@ void InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code byte
Thread* THREAD = thread;
// extract receiver from the outgoing argument list if necessary
Handle receiver(thread, NULL);
if (bytecode == Bytecodes::_invokevirtual || bytecode == Bytecodes::_invokeinterface) {
if (bytecode == Bytecodes::_invokevirtual || bytecode == Bytecodes::_invokeinterface ||
bytecode == Bytecodes::_invokespecial) {
ResourceMark rm(thread);
methodHandle m (thread, method(thread));
Bytecode_invoke call(m, bci(thread));
@ -783,16 +784,25 @@ void InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code byte
int index = info.resolved_method()->itable_index();
assert(info.itable_index() == index, "");
}
} else if (bytecode == Bytecodes::_invokespecial) {
assert(info.call_kind() == CallInfo::direct_call, "must be direct call");
} else {
assert(info.call_kind() == CallInfo::direct_call ||
info.call_kind() == CallInfo::vtable_call, "");
}
#endif
// Get sender or sender's host_klass, and only set cpCache entry to resolved if
// it is not an interface. The receiver for invokespecial calls within interface
// methods must be checked for every call.
InstanceKlass* sender = pool->pool_holder();
sender = sender->is_anonymous() ? sender->host_klass() : sender;
switch (info.call_kind()) {
case CallInfo::direct_call:
cp_cache_entry->set_direct_call(
bytecode,
info.resolved_method());
info.resolved_method(),
sender->is_interface());
break;
case CallInfo::vtable_call:
cp_cache_entry->set_vtable_call(