8050978: Fix bad field access check in C1 and C2

Fri, 18 Jul 2014 09:04:01 +0200

author
goetz
date
Fri, 18 Jul 2014 09:04:01 +0200
changeset 6942
f72d8917322a
parent 6941
63e0c47ca943
child 6944
f619b069f2ca

8050978: Fix bad field access check in C1 and C2
Summary: JCK8 test vm/constantpool/accessControl/accessControl004/accessControl00402m3/accessControl00402m3.html fails with -Xbatch -Xcomp due to bad field access check in C1 and C2. Fix: In ciField::ciField(), just before the canonical holder is stored into the _holder variable (and which is used by ciField::will_link()) perform an additional access check with the holder declared in the class file. If this check fails, store the declared holder instead and ciField::will_link() will bail out compilation for this field later on. Then, the interpreter will throw an PrivilegedAccessException at runtime.
Reviewed-by: kvn, vlivanov
Contributed-by: andreas.schoesser@sap.com

src/share/vm/ci/ciField.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/ci/ciField.cpp	Thu Jul 17 10:21:31 2014 +0200
     1.2 +++ b/src/share/vm/ci/ciField.cpp	Fri Jul 18 09:04:01 2014 +0200
     1.3 @@ -138,6 +138,17 @@
     1.4      return;
     1.5    }
     1.6  
     1.7 +  // Access check based on declared_holder. canonical_holder should not be used
     1.8 +  // to check access because it can erroneously succeed. If this check fails,
     1.9 +  // propagate the declared holder to will_link() which in turn will bail out
    1.10 +  // compilation for this field access.
    1.11 +  if (!Reflection::verify_field_access(klass->get_Klass(), declared_holder->get_Klass(), canonical_holder, field_desc.access_flags(), true)) {
    1.12 +    _holder = declared_holder;
    1.13 +    _offset = -1;
    1.14 +    _is_constant = false;
    1.15 +    return;
    1.16 +  }
    1.17 +
    1.18    assert(canonical_holder == field_desc.field_holder(), "just checking");
    1.19    initialize_from(&field_desc);
    1.20  }

mercurial