mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8166304: Skipping access check for classes generated by core reflection
Only allow boot and reflection class loader to load sub-types of jdk.internal.reflect Reviewed-by: acorn, lfoltan, rehn
This commit is contained in:
parent
81f1e7056b
commit
ccbb28f6a0
6 changed files with 161 additions and 9 deletions
|
@ -4349,13 +4349,34 @@ static void check_super_class_access(const InstanceKlass* this_klass, TRAPS) {
|
|||
assert(this_klass != NULL, "invariant");
|
||||
const Klass* const super = this_klass->super();
|
||||
if (super != NULL) {
|
||||
|
||||
// If the loader is not the boot loader then throw an exception if its
|
||||
// superclass is in package jdk.internal.reflect and its loader is not a
|
||||
// special reflection class loader
|
||||
if (!this_klass->class_loader_data()->is_the_null_class_loader_data()) {
|
||||
assert(super->is_instance_klass(), "super is not instance klass");
|
||||
PackageEntry* super_package = super->package();
|
||||
if (super_package != NULL &&
|
||||
super_package->name()->fast_compare(vmSymbols::jdk_internal_reflect()) == 0 &&
|
||||
!java_lang_ClassLoader::is_reflection_class_loader(this_klass->class_loader())) {
|
||||
ResourceMark rm(THREAD);
|
||||
Exceptions::fthrow(
|
||||
THREAD_AND_LOCATION,
|
||||
vmSymbols::java_lang_IllegalAccessError(),
|
||||
"class %s loaded by %s cannot access jdk/internal/reflect superclass %s",
|
||||
this_klass->external_name(),
|
||||
this_klass->class_loader_data()->loader_name(),
|
||||
super->external_name());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reflection::VerifyClassAccessResults vca_result =
|
||||
Reflection::verify_class_access(this_klass, super, false);
|
||||
if (vca_result != Reflection::ACCESS_OK) {
|
||||
ResourceMark rm(THREAD);
|
||||
char* msg = Reflection::verify_class_access_msg(this_klass, super, vca_result);
|
||||
if (msg == NULL) {
|
||||
ResourceMark rm(THREAD);
|
||||
Exceptions::fthrow(
|
||||
THREAD_AND_LOCATION,
|
||||
vmSymbols::java_lang_IllegalAccessError(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue