[#1161] Keep bc-fips from seeding its DRBG from RDSEED in the test JVMs - #1168
Conversation
maximthomas
left a comment
There was a problem hiding this comment.
praise: The flag goes where the failing JVM is, and it does not slow the suite.
- Both test argLines carry it (
pom.xml:68and thejdk17.optionsone atpom.xml:744), and the comment atpom.xml:62-67tells the next editor to keep them in step.opendj-server-legacy/pom.xml:1285<argLine>@{argLine}</argLine>is the only override, so the failsafe fork gets it on JDK 11 and on JDK 17+. org.bouncycastle.native.cpu_variant/javamatch the constants and the "java support only" branch in bc-fips 2.1.3NativeLoader.- The Linux
build-mavencells took 2h19m-2h40m at this head, against 2h11m-2h34m at the base: no measurable cost from dropping the native AES/SHA code.
question (non-blocking): Should the setup and server JVMs that AdsTrustStoreInstallTestCase starts also run without the bc-fips native libraries?
opendj-server-legacy/src/test/java/org/opends/quicksetup/AdsTrustStoreInstallTestCase.java:385, :276, :315; opendj-server-legacy/src/main/java/org/opends/quicksetup/util/ServerController.java:373
runSetup starts the packaged setup with new ProcessBuilder(args). The argLine property does not cross a process boundary, and nothing sets OPENDJ_JAVA_ARGS or JAVA_TOOL_OPTIONS for the child. ServerController.startServerViaAnotherProcess removes OPENDJ_JAVA_ARGS before start-ds anyway. testInstalledServerStartsOnTheProvisionedTrustStore needs that server to generate ads-certificate (asserted at :315) through BCFIPS with the native libraries loaded, which is the road of the #1161 occurrence. So that class can still go red with RDSEED persistently failed to produce entropy after "Fixes #1161" has closed the issue. The exposure is a handful of key generations per run, against hundreds in the fork. If the description's "Only the test JVMs change" was meant to leave these JVMs on the native path, saying that #1161 is fixed for the in-JVM road only would be enough. If not, JAVA_TOOL_OPTIONS survives ServerController's env edits and reaches both JVMs. The output asserts in this class use contains(), so the JVM's "Picked up JAVA_TOOL_OPTIONS" line does not break them:
final ProcessBuilder builder = new ProcessBuilder(args).redirectErrorStream(true).redirectOutput(output);
// ServerController drops OPENDJ_JAVA_ARGS before start-ds; JAVA_TOOL_OPTIONS reaches setup and the server it starts.
builder.environment().put("JAVA_TOOL_OPTIONS", "-Dorg.bouncycastle.native.cpu_variant=java");
final Process process = builder.start();suggestion (non-blocking): Nothing fails if the flag is dropped from either argLine.
pom.xml:68, :744
The two argLines are kept in step by hand, and jdk17.options replaces the default one on JDK 17+. If a later edit loses the flag from one of them, every cell stays green until the rare RDSEED event comes back on that JDK. That mutant is the base, 4870ff3, which ran green on every Linux cell.
package org.opends.server;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;
/** Pins the test argLine flag that keeps bc-fips off RDSEED, see issue #1161. */
@SuppressWarnings("javadoc")
public class BcFipsTestJvmTestCase extends DirectoryServerTestCase
{
@Test
public void testJvmRunsBcFipsWithoutNativeLibraries()
{
assertEquals(System.getProperty("org.bouncycastle.native.cpu_variant"), "java",
"the test argLine lost the bc-fips cpu_variant flag, see #1161");
}
}Pin: this case fails on the JDK 11 cell when the flag leaves pom.xml:68, and on the JDK 17+ cells when it leaves pom.xml:744.
…DSEED in the test JVMs On busy CI hosts the CPU's RDSEED instruction runs dry, and bc-fips 2.1.3 fails with "RDSEED persistently failed to produce entropy" while the embedded test server generates its self-signed certificates. The test class that starts the server then fails and the rest of it is skipped. Run the test JVMs with -Dorg.bouncycastle.native.cpu_variant=java, in both the default argLine and the jdk17.options one, so that bc-fips does not load its native libraries and seeds its DRBG from the JDK instead. The packaged server and the "Test on Unix FIPS" step are not affected. Fixes OpenIdentityPlatform#1161
…ts start from the package, and pin it The argLine flag stays inside the failsafe fork. AdsTrustStoreInstallTestCase and QuickSetupTestCase start the packaged setup, and ServerControllerTest starts start-ds through ServerController, which keeps the environment of the fork and drops only OPENDJ_JAVA_ARGS and CLASSPATH. Those servers generate their certificates through bc-fips with the native libraries loaded, which is the road of OpenIdentityPlatform#1161. Set JAVA_TOOL_OPTIONS in the failsafe environment of opendj-server-legacy, so that every JVM started from the fork reads the flag as well. Pin both places: BcFipsNativeLibrariesOffTestCase in opendj-core fails when either root argLine loses the flag (LDAPServer generates its key pairs with bc-fips there, and the module takes the root argLine as it is), and BcFipsNativeLibrariesOffTest in opendj-server-legacy fails when the fork loses JAVA_TOOL_OPTIONS.
|
Thanks, both points are taken in 8607401 (the branch is also rebased onto the current question (child JVMs): you are right, and it is wider than So the flag now goes into the environment of the fork instead: the
The description now says "the test JVMs and the JVMs they start". suggestion (pin): taken, in two pins rather than one. With
|
maximthomas
left a comment
There was a problem hiding this comment.
praise: The second commit closes the road the argLine cannot reach, and both halves of the fix are pinned.
opendj-server-legacy/pom.xml:1291-1293hands the flag tosetupandstart-dsthroughJAVA_TOOL_OPTIONS. It is the one road that survivesServerController's env edits, which remove onlyOPENDJ_JAVA_ARGSandCLASSPATH.- Both root argLines (
pom.xml:69,:745) carry the flag, andBcFipsNativeLibrariesOffTestCasepins each one on its JDK range.
Fixes #1161
Problem
On the Linux
build-mavenlegs the embedded test server sometimes fails to start: bc-fips 2.1.3 seeds its DRBG from the CPU's RDSEED instruction through its native libraries, and on a busy CI host RDSEED runs dry while the server generates its self-signed certificates (RDSEED persistently failed to produce entropy). The class that starts the server fails in@BeforeClassand the rest of it is skipped.Change
Both test
argLinevalues in the rootpom.xml(the default one and thejdk17.optionsone) now carry-Dorg.bouncycastle.native.cpu_variant=java. With it bc-fips does not load its native libraries, andFipsDRBG.getDefaultEntropySourceProvider()falls back toSecureRandom.getInstanceStrong()from the JDK. Theopendj-server-legacyfailsafe configuration picks it up through@{argLine}.The argLine does not cross a process boundary.
AdsTrustStoreInstallTestCaseandQuickSetupTestCasestart the packagedsetup, andServerControllerTeststartsstart-dsthroughServerController, which keeps the environment of the fork and drops onlyOPENDJ_JAVA_ARGSandCLASSPATH. Those servers generate their certificates through bc-fips too, so theopendj-server-legacyfailsafe execution also setsJAVA_TOOL_OPTIONSto the same flag in<environmentVariables>, and every JVM started from the fork reads it.Two pins:
BcFipsNativeLibrariesOffTestCase(opendj-core) fails when either root argLine loses the flag.LDAPServergenerates its key pairs with bc-fips in that module, and the module takes the root argLine as it is: the default one below JDK 17, thejdk17.optionsone from JDK 17 on.BcFipsNativeLibrariesOffTest(opendj-server-legacy) fails when the failsafe fork losesJAVA_TOOL_OPTIONS.Only the test JVMs and the JVMs they start change. The product (start scripts,
setup) keeps loading the native libraries, and the "Test on Unix FIPS" step inbuild.yml, which runs the packaged server outside Maven, still exercises that path.Verification
mvn help:evaluate -Dexpression=argLineshows the property withjdk17.optionsactive, with it disabled, and inopendj-server-legacy.A small program that makes the same
KeyPairGeneratorcall asPlatform.newKeyPair(), run against bc-fips 2.1.3 in aneclipse-temurin:17linux/amd64 container on a CPU withrdseed:cpu_variant=javaREADY/avxUNSUPPORTED/ nonetrue/truefalse/falseFipsDRBG$1(NativeEntropySource, RDSEED)BasicEntropySourceProvider(JDK)Reactor run (JDK 26):
BcFipsNativeLibrariesOffTestCase1/1,AdsTrustStoreInstallTestCase6/6,ServerControllerTest2/2,BcFipsNativeLibrariesOffTest2/2. The JVM'sPicked up JAVA_TOOL_OPTIONSline breaks nothing.The built package's
setupandstart-ds, run with the fork's environment:setup,start-dsand the server'slogs/server.outall printPicked up JAVA_TOOL_OPTIONS: -Dorg.bouncycastle.native.cpu_variant=java, and the server generatesads-certificate.Mutants: flag removed from the default argLine →
opendj-corepin red on JDK 11; removed from thejdk17.optionsargLine → red on JDK 26 (both green at the head);JAVA_TOOL_OPTIONSmissing →BcFipsNativeLibrariesOffTestred.The RDSEED failure itself cannot be reproduced on demand, so the CI legs are the end-to-end check.
Follow-up, not in this PR
bc-fips 2.1.4 (a release candidate, see bcgit/bc-java#2434, not yet on Maven Central) adds
org.bouncycastle.native.rand=NONE, which turns off only the hardware RNG and keeps the native AES/SHA acceleration, and raises the RDSEED retry limit to 1500. That is the better fit for the product side (start scripts,setup) once it is released.