8307185: pkcs11 native libraries make JNI calls into java code while holding GC lock
Reviewed-by: alanb, valeriep
This commit is contained in:
parent
bae2247938
commit
354c6605e3
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
|
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
|
||||||
@ -155,7 +155,10 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1Encrypt
|
|||||||
} else {
|
} else {
|
||||||
outBufP = (*env)->GetPrimitiveArrayCritical(env, jOut, NULL);
|
outBufP = (*env)->GetPrimitiveArrayCritical(env, jOut, NULL);
|
||||||
if (outBufP == NULL) {
|
if (outBufP == NULL) {
|
||||||
goto cleanup;
|
if (directIn == 0) {
|
||||||
|
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,15 +169,13 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1Encrypt
|
|||||||
(CK_BYTE_PTR)(outBufP + jOutOfs),
|
(CK_BYTE_PTR)(outBufP + jOutOfs),
|
||||||
&ckEncryptedLen);
|
&ckEncryptedLen);
|
||||||
|
|
||||||
ckAssertReturnValueOK(env, rv);
|
if (directIn == 0) {
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (directIn == 0 && inBufP != NULL) {
|
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
|
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
|
||||||
}
|
}
|
||||||
if (directOut == 0 && outBufP != NULL) {
|
if (directOut == 0) {
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, 0);
|
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, 0);
|
||||||
}
|
}
|
||||||
|
ckAssertReturnValueOK(env, rv);
|
||||||
return ckEncryptedLen;
|
return ckEncryptedLen;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -221,7 +222,10 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1EncryptUpdate
|
|||||||
} else {
|
} else {
|
||||||
outBufP = (*env)->GetPrimitiveArrayCritical(env, jOut, NULL);
|
outBufP = (*env)->GetPrimitiveArrayCritical(env, jOut, NULL);
|
||||||
if (outBufP == NULL) {
|
if (outBufP == NULL) {
|
||||||
goto cleanup;
|
if (directIn == 0) {
|
||||||
|
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,15 +236,13 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1EncryptUpdate
|
|||||||
(CK_BYTE_PTR)(outBufP + jOutOfs),
|
(CK_BYTE_PTR)(outBufP + jOutOfs),
|
||||||
&ckEncryptedPartLen);
|
&ckEncryptedPartLen);
|
||||||
|
|
||||||
ckAssertReturnValueOK(env, rv);
|
if (directIn == 0) {
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (directIn == 0 && inBufP != NULL) {
|
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
|
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
|
||||||
}
|
}
|
||||||
if (directOut == 0 && outBufP != NULL) {
|
if (directOut == 0) {
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, 0);
|
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, 0);
|
||||||
}
|
}
|
||||||
|
ckAssertReturnValueOK(env, rv);
|
||||||
return ckEncryptedPartLen;
|
return ckEncryptedPartLen;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -391,7 +393,10 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1Decrypt
|
|||||||
} else {
|
} else {
|
||||||
outBufP = (*env)->GetPrimitiveArrayCritical(env, jOut, NULL);
|
outBufP = (*env)->GetPrimitiveArrayCritical(env, jOut, NULL);
|
||||||
if (outBufP == NULL) {
|
if (outBufP == NULL) {
|
||||||
goto cleanup;
|
if (directIn == 0) {
|
||||||
|
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ckOutLen = jOutLen;
|
ckOutLen = jOutLen;
|
||||||
@ -401,15 +406,13 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1Decrypt
|
|||||||
(CK_BYTE_PTR)(outBufP + jOutOfs),
|
(CK_BYTE_PTR)(outBufP + jOutOfs),
|
||||||
&ckOutLen);
|
&ckOutLen);
|
||||||
|
|
||||||
ckAssertReturnValueOK(env, rv);
|
if (directIn == 0) {
|
||||||
|
|
||||||
cleanup:
|
|
||||||
if (directIn == 0 && inBufP != NULL) {
|
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
|
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
|
||||||
}
|
}
|
||||||
if (directOut == 0 && outBufP != NULL) {
|
if (directOut == 0) {
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, 0);
|
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, 0);
|
||||||
}
|
}
|
||||||
|
ckAssertReturnValueOK(env, rv);
|
||||||
return ckOutLen;
|
return ckOutLen;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -456,7 +459,10 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptUpdate
|
|||||||
} else {
|
} else {
|
||||||
outBufP = (*env)->GetPrimitiveArrayCritical(env, jOut, NULL);
|
outBufP = (*env)->GetPrimitiveArrayCritical(env, jOut, NULL);
|
||||||
if (outBufP == NULL) {
|
if (outBufP == NULL) {
|
||||||
goto cleanup;
|
if (directIn == 0) {
|
||||||
|
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,15 +471,14 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptUpdate
|
|||||||
(CK_BYTE_PTR)(inBufP + jInOfs), jInLen,
|
(CK_BYTE_PTR)(inBufP + jInOfs), jInLen,
|
||||||
(CK_BYTE_PTR)(outBufP + jOutOfs),
|
(CK_BYTE_PTR)(outBufP + jOutOfs),
|
||||||
&ckDecryptedPartLen);
|
&ckDecryptedPartLen);
|
||||||
ckAssertReturnValueOK(env, rv);
|
|
||||||
|
|
||||||
cleanup:
|
if (directIn == 0) {
|
||||||
if (directIn == 0 && inBufP != NULL) {
|
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
|
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
|
||||||
}
|
}
|
||||||
if (directOut == 0 && outBufP != NULL) {
|
if (directOut == 0) {
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, 0);
|
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, 0);
|
||||||
}
|
}
|
||||||
|
ckAssertReturnValueOK(env, rv);
|
||||||
return ckDecryptedPartLen;
|
return ckDecryptedPartLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8080462 8229243
|
* @bug 8080462 8229243 8307185
|
||||||
* @library /test/lib ..
|
* @library /test/lib ..
|
||||||
* @modules jdk.crypto.cryptoki
|
* @modules jdk.crypto.cryptoki
|
||||||
* @run main TestGCMKeyAndIvCheck
|
* @run main TestGCMKeyAndIvCheck
|
||||||
|
Loading…
Reference in New Issue
Block a user