RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2099840 - rh1991003 patch breaks sun.security.pkcs11.wrapper.PKCS11.getInstance() [rhel-8, openjdk-17]
Summary: rh1991003 patch breaks sun.security.pkcs11.wrapper.PKCS11.getInstance() [rhel...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: java-17-openjdk
Version: 8.7
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Andrew John Hughes
QA Contact: OpenJDK QA
URL:
Whiteboard:
Depends On:
Blocks: 2099913 2099914
TreeView+ depends on / blocked
 
Reported: 2022-06-21 19:35 UTC by Andrew John Hughes
Modified: 2022-11-08 10:16 UTC (History)
3 users (show)

Fixed In Version: java-17-openjdk-17.0.3.0.7-4.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2099913 2099914 (view as bug list)
Environment:
Last Closed: 2022-11-08 09:32:03 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github rh-openjdk jdk pull 8 0 None Merged RH2036462: sun.security.pkcs11.wrapper.PKCS11.getInstance breakage 2022-10-19 15:44:13 UTC
Red Hat Issue Tracker RHELPLAN-125906 0 None None None 2022-06-21 19:58:07 UTC
Red Hat Product Errata RHBA-2022:6691 0 None None None 2022-11-08 09:32:35 UTC

Description Andrew John Hughes 2022-06-21 19:35:34 UTC
This bug was initially created as a copy of Bug #2097152

I am copying this bug because: 

Need to cover OpenJDK 17 on RHEL 8 too

This bug was initially created as a copy of Bug #2036462

I am copying this bug because: 

Original is for Fedora and we have a RHEL customer issue related to this now.

Description of problem:

The sun.security.pkcs11.wrapper.PKCS11 class contains a public method, getInstance with 4 arguments. The patch related to bug 1991003, modifies this method by adding an additional 5th argument, fipsKeyImporter, of type MethodHandle.

https://src.fedoraproject.org/rpms/java-1.8.0-openjdk/blob/f35/f/rh1991003-enable_fips_keys_import.patch#_446

Possibly due to an oversight, the patch lacks public API compatible method with the same argument count to use with existing software. Due to this, existing applications could fail, showing exceptions like the following:

java.lang.NoSuchMethodError: sun.security.pkcs11.wrapper.PKCS11.getInstance(Ljava/lang/String;Ljava/lang/String;Lsun/security/pkcs11/wrapper/CK_C_INITIALIZE_ARGS;Z)Lsun/security/pkcs11/wrapper/PKCS11;


Version-Release number of selected component (if applicable):

java-1.8.0-openjdk-1.8.0.312.b07-2.fc35

And likely the equivalent in other versions (11, etc.).


How reproducible:

Always.


Steps to Reproduce:
1. Create a file Test.java with the following:

class Test {
    public static void main(String[] args) throws Exception {
        sun.security.pkcs11.wrapper.CK_C_INITIALIZE_ARGS initArgs = new sun.security.pkcs11.wrapper.CK_C_INITIALIZE_ARGS();
        initArgs.flags = 0;
        sun.security.pkcs11.wrapper.PKCS11 pkcs11 = sun.security.pkcs11.wrapper.PKCS11.getInstance("/usr/lib64/opensc-pkcs11.so", "C_GetFunctionList", initArgs, false);

        long[] slotList = pkcs11.C_GetSlotList(true);
        for (long slot : slotList) {
            sun.security.pkcs11.wrapper.CK_TOKEN_INFO tokenInfo = pkcs11.C_GetTokenInfo(slot);
            System.out.println("Slot info:\n" + tokenInfo.toString());
        }
    }
}

2. save and compile with: javac Test.java


Actual results:

test.java:5: error: method getInstance in class PKCS11 cannot be applied to given types;
        sun.security.pkcs11.wrapper.PKCS11 pkcs11 = sun.security.pkcs11.wrapper.PKCS11.getInstance("/usr/lib64/opensc-pkcs11.so", "C_GetFunctionList", initArgs, false);
                                                                                      ^
  required: String,String,CK_C_INITIALIZE_ARGS,boolean,MethodHandle
  found: String,String,CK_C_INITIALIZE_ARGS,boolean
  reason: actual and formal argument lists differ in length
1 error


Expected results:

It builds as is.


Additional info:

The affected API is widely used by applications needing to handle available tokens and their slots also for handle public certificates on tokens without requiring login.

If you add a null as a 5th argument, it builds. But will fail to run on JREs not affected by the patch.

If you build the source from a JDK not affected by the patch and run the class with java Test on an affected JRE, it will fail as mentioned in the "Description of problem" section.

Comment 10 errata-xmlrpc 2022-11-08 09:32:03 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (java-17-openjdk bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:6691


Note You need to log in before you can comment on or make changes to this bug.