Skip to content

Commit ba1a090

Browse files
Ensure boot class loader classes have a null CodeSource
1 parent ceaf4df commit ba1a090

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHub.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1976,7 +1976,11 @@ public Object[] getSigners() {
19761976
@Substitute
19771977
public ProtectionDomain getProtectionDomain() {
19781978
if (companion.protectionDomain == null) {
1979-
companion.protectionDomain = ProtectionDomainSupport.allPermDomain();
1979+
if (getClassLoader() == null) {
1980+
companion.protectionDomain = ProtectionDomainSupport.bootAllPermDomain();
1981+
} else {
1982+
companion.protectionDomain = ProtectionDomainSupport.allPermDomain();
1983+
}
19801984
}
19811985
return companion.protectionDomain;
19821986
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ProtectionDomainSupport.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
import java.security.cert.Certificate;
3333
import java.util.function.Supplier;
3434

35-
import jdk.graal.compiler.options.Option;
36-
import jdk.graal.compiler.options.OptionType;
3735
import org.graalvm.nativeimage.ImageSingletons;
3836
import org.graalvm.nativeimage.Platform;
3937
import org.graalvm.nativeimage.Platforms;
@@ -42,6 +40,8 @@
4240
import com.oracle.svm.core.option.HostedOptionKey;
4341
import com.oracle.svm.core.util.LazyFinalReference;
4442

43+
import jdk.graal.compiler.options.Option;
44+
import jdk.graal.compiler.options.OptionType;
4545
import sun.security.util.SecurityConstants;
4646

4747
/**
@@ -69,10 +69,21 @@ public static class Options {
6969
}
7070

7171
private final LazyFinalReference<ProtectionDomain> allPermDomain = new LazyFinalReference<>(this::createAllPermDomain);
72+
private final LazyFinalReference<ProtectionDomain> bootAllPermDomain = new LazyFinalReference<>(ProtectionDomainSupport::createBootAllPermDomain);
7273

7374
/** Remains null as long as the reachability handler has not triggered. */
7475
Supplier<URL> executableURLSupplier;
7576

77+
public static ProtectionDomain bootAllPermDomain() {
78+
return ImageSingletons.lookup(ProtectionDomainSupport.class).bootAllPermDomain.get();
79+
}
80+
81+
private static ProtectionDomain createBootAllPermDomain() {
82+
java.security.Permissions perms = new java.security.Permissions();
83+
perms.add(SecurityConstants.ALL_PERMISSION);
84+
return new java.security.ProtectionDomain(null, perms);
85+
}
86+
7687
public static ProtectionDomain allPermDomain() {
7788
return ImageSingletons.lookup(ProtectionDomainSupport.class).allPermDomain.get();
7889
}

0 commit comments

Comments
 (0)