Skip to content

Commit 7be1de1

Browse files
authoredMar 3, 2025··
Merge pull request #873 from JinhangZhang/forbid3rdproviderInCRIU
Prohibit the insertion of 3rd-party provider
2 parents f76b432 + 2889bca commit 7be1de1

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed
 

‎src/java.base/share/classes/java/security/Security.java

+16-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
/*
2727
* ===========================================================================
28-
* (c) Copyright IBM Corp. 2022, 2024 All Rights Reserved
28+
* (c) Copyright IBM Corp. 2022, 2025 All Rights Reserved
2929
* ===========================================================================
3030
*/
3131

@@ -347,14 +347,26 @@ public static String getAlgorithmProperty(String algName,
347347
*/
348348
public static synchronized int insertProviderAt(Provider provider,
349349
int position) {
350+
String providerName = provider.getName();
351+
checkInsertProvider(providerName);
352+
ProviderList list = Providers.getFullProviderList();
350353

351354
/*[IF CRIU_SUPPORT]*/
355+
if (InternalCRIUSupport.enableCRIUSecProvider()) {
356+
for (Provider existingProvider : list.providers()) {
357+
if ("CRIUSEC".equals(existingProvider.getName())) {
358+
if (criuDebug) {
359+
System.out.println("Trying to insert + " + providerName
360+
+ " during the pre-checkpoint which is not allowed.");
361+
}
362+
throw new RuntimeException("Inserting " + providerName
363+
+ " during the pre-checkpoint is not allowed");
364+
}
365+
}
366+
}
352367
CRIUConfigurator.invalidateAlgorithmCache();
353368
/*[ENDIF] CRIU_SUPPORT */
354369

355-
String providerName = provider.getName();
356-
checkInsertProvider(providerName);
357-
ProviderList list = Providers.getFullProviderList();
358370
ProviderList newList = ProviderList.insertAt(list, provider, position - 1);
359371
if (list == newList) {
360372
return -1;

0 commit comments

Comments
 (0)
Please sign in to comment.