JDK-8216597 : SIGBUS in Java_sun_security_pkcs11_wrapper_PKCS11_getNativeKeyInfo after JDK-6913047
  • Type: Bug
  • Component: security-libs
  • Sub-Component: javax.crypto:pkcs11
  • Affected Version: 8,11,13
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris
  • CPU: sparc
  • Submitted: 2019-01-13
  • Updated: 2020-02-19
  • Resolved: 2019-02-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 13 Other
11.0.4Fixed 13 b09Fixed openjdk8u232Fixed
Related Reports
Blocks :  
Relates :  
Sub Tasks
JDK-8217167 :  
Description
After the fix for JDK-6913047 we have a large number of crashes on Solaris


The failures all show something like

----------System.out:(21/1155)----------
nssLibDir: /usr/lib/mps/64/
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGBUS (0xa) at pc=0xffffffff5400b754, pid=26678, tid=20
#
# JRE version: Java(TM) SE Runtime Environment (13.0) (build 13-internal+0-jdk13-jdk.126)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (13-internal+0-jdk13-jdk.126, mixed mode, sharing, tiered, compressed oops, g1 gc, solaris-sparc)
# Problematic frame:
# C  [libj2pkcs11.so+0xb754]  Java_sun_security_pkcs11_wrapper_PKCS11_getNativeKeyInfo+0x2e4
#

Comments
Fix Request JDK-8 will be affected by this bug after backporting JDK-6913047. Patch applies cleanly, except for P11Key.java part (which simply reverts JDK-8217088).
19-07-2019

Fix Request JDK-11 will be affected by this bug after backporting 6913047.
17-05-2019

No new regression test as this is reproducible with running existing regression tests on Solaris-Sparc v9 under the jdk-tier4 target. Thus adding the @noreg-other label.
07-02-2019

The SIGBUS is caused by dereferencing the "wrappedKeySizePtr" variable which is declared to be (unsigned long*). Its pointer address is calculated as (nativeKeyInfoArrayRaw + sizeof(unsigned long)*2 + totalCkAttributesSize + totalDataSize) which may become un-aligned depending on the value of "totalDataSize". The simplest fix is to change the declaration of wrappedKeySizePtr to (jbyte*). Just to be safe, I have also changed another unsigned long* to use jbyte* and made corresponding adjustments. http://cr.openjdk.java.net/~valeriep/8216597/webrev.00/ Mach5 job with jdk-tier1, jdk-tier2, and jdk-tier4 completed w/ all tests passed.
01-02-2019

Mailing list discussion (security-dev): https://mail.openjdk.java.net/pipermail/security-dev/2019-January/019162.html
14-01-2019

[~mbalao], please look at this soon as it is causing test failures - thanks.
14-01-2019

This code looks suspicious: wrappedKeySizeWrappedKeyArrayPtr = (unsigned long*)(nativeKeyInfoWrappedKeyArrayRaw + sizeof(unsigned long)*2 + totalCkAttributesSize + totalDataSize); The resulting address will need to be 64-bit aligned.
13-01-2019