Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow startup because of low entropy for PRNG #2075

Open
ago1024 opened this issue Feb 25, 2024 · 0 comments
Open

Slow startup because of low entropy for PRNG #2075

ago1024 opened this issue Feb 25, 2024 · 0 comments

Comments

@ago1024
Copy link

ago1024 commented Feb 25, 2024

Describe the bug

b3607a7 changed JCEEncryptor to use SecureRandom.getInstanceStrong(). In OpenJDK on Unix systems this is NativePRNG.Blocking which will stall if the kernel does not provide enough entropy.

We've noticed this behaviour on our CI systems where EclipseLink 2.714 startup would stall the tests.

   java.lang.Thread.State: RUNNABLE
        at java.io.FileInputStream.readBytes(java.base@11.0.22/Native Method)
        at java.io.FileInputStream.read(java.base@11.0.22/FileInputStream.java:279)
        at java.io.FilterInputStream.read(java.base@11.0.22/FilterInputStream.java:133)
        at sun.security.provider.NativePRNG$RandomIO.readFully(java.base@11.0.22/NativePRNG.java:424)
        at sun.security.provider.NativePRNG$RandomIO.ensureBufferValid(java.base@11.0.22/NativePRNG.java:526)
        at sun.security.provider.NativePRNG$RandomIO.implNextBytes(java.base@11.0.22/NativePRNG.java:545)
        - locked <0x00000000fcca7318> (a java.lang.Object)
        at sun.security.provider.NativePRNG$Blocking.engineNextBytes(java.base@11.0.22/NativePRNG.java:268)
        at java.security.SecureRandom.nextBytes(java.base@11.0.22/SecureRandom.java:751)
        at org.eclipse.persistence.internal.security.JCEEncryptor$Synergizer.getIvGCM(JCEEncryptor.java:243)
        at org.eclipse.persistence.internal.security.JCEEncryptor$Synergizer.access$4(JCEEncryptor.java:235)
        at org.eclipse.persistence.internal.security.JCEEncryptor.encryptPassword(JCEEncryptor.java:102)
        - locked <0x00000000ff7ea7e8> (a org.eclipse.persistence.internal.security.JCEEncryptor)
        at org.eclipse.persistence.sessions.DatasourceLogin.setPassword(DatasourceLogin.java:416)
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updateLogins(EntityManagerSetupImpl.java:2483)
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updateSession(EntityManagerSetupImpl.java:2806)
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:751)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:222)
        - locked <0x00000000fcd757a8> (a org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:330)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:350)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:313)

To Reproduce
Steps/resources to reproduce the behavior:

  • EclipseLink version 2.7.14
  • Java/JDK version JDK8/11/17/21

Expected behavior
The codepath should use the nonblocking PRNG to avoid a blocked startup because of low entropy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant