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

8155246: Throw error if default java.security file is missing #9747

Closed
wants to merge 5 commits into from

Conversation

coffeys
Copy link
Contributor

@coffeys coffeys commented Aug 4, 2022

In the broken case where the conf/security/java.security configuration file doesn't exist, the JDK should throw an Error.

CSR in progress.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires a CSR request to be approved

Issues

  • JDK-8155246: Throw error if default java.security file is missing
  • JDK-8291891: Throw error if default java.security file is missing (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9747/head:pull/9747
$ git checkout pull/9747

Update a local copy of the PR:
$ git checkout pull/9747
$ git pull https://git.openjdk.org/jdk pull/9747/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9747

View PR using the GUI difftool:
$ git pr show -t 9747

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9747.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 4, 2022

👋 Welcome back coffeys! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Aug 4, 2022
@openjdk
Copy link

openjdk bot commented Aug 4, 2022

@coffeys The following label will be automatically applied to this pull request:

  • security

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the security security-dev@openjdk.org label Aug 4, 2022
@coffeys coffeys marked this pull request as ready for review August 8, 2022 10:19
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 8, 2022
@mlbridge
Copy link

mlbridge bot commented Aug 8, 2022

Webrevs

@ascarpino
Copy link
Contributor

What's the need for this change? Perhaps I'm missing the bigger problem here. Certainly not having a java.security file is sub-optimal and I suspect very very rare, but throwing exceptions that breaks existing apps seems like a big hammer and would now need a property added to override

Doing this change for jdk-dev only I could see, but as the CSR points toward backporting, that seems more risky

@coffeys
Copy link
Contributor Author

coffeys commented Aug 8, 2022

Hi Tony,

there are a few points for the change IMO:

  • The fall back to the "static" security policy file is broken since JDK 9/Modules. Some providers don't register correctly. See JDK-8291888
  • The fall back mode used a minimal security config setting and is not actively maintained. I'd argue that it's dangerous - all the JDK protection aids added via the java.security file aren't available if the default one is missing. One is still free to override the property file, as before. We just ensure that $JDK/conf/security/java.security exists. It's a bad JDK install if such a file doesn't exist. This might only make JDK 20 - perhaps we review feedback from that release and decide if we want to proceed with backports then.

regards,
Sean.

@@ -47,6 +47,10 @@
* implementation-specific location, which is typically the properties file
* {@code conf/security/java.security} in the Java installation directory.
*
* @implNote If the master security properties file is missing, the JDK
* implementation will throw an {@code InternalError} when initializing the
* {@code Security} class.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "master security properties file" the right term here? The only use of "master" in this class seems to be a deprecated method.

I'm also not sure about the word "missing" as there can be many reasons why opening a file may fail, e.g. something changes the permissions or file owner so that it can't be opened for example.

The implNote need not be specific on the exception that is thrown, it could say "will throw an unspecified exception ..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The opening line of the java.security file denotes it as the "master security properties file". I think it works well but open to suggestions. Maybe we can re-use the terminology from previous paragraph.

Fair point about the "missing" and error clause -- perhaps:

@implNote If the file containing the default values of security properties fails to load,
* the JDK implementation will throw an unspecified error when initializing the
* {@code Security} class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you just said "If this properties file ..." it would be sufficient, as the previous paragraph provided enough context as to what you are referring to.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw the current code does not handlmissing or unreadable overwrite files very well. PropsLoaded will be true even when the replacing overwrite file could not be loaded (resulting in an empty list).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a fair point @ecki -- the 2nd loadedProps = true; call is redundant since the code block is not executed unless the security.overridePropertiesFile is set to true by reading the props from default/master file.

one option here might be to delay the re-initialization of props until we successfully load the override security props file

i.e. push this code block down

            if (overrideAll) {
                props = new Properties();
                if (sdebug != null) {
                    sdebug.println
                        ("overriding other security properties files!");
                }
            }

I'll log another JBS issue to track that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ecki -- Logged JDK-8292297 to track the issue you raised

@@ -47,6 +47,9 @@
* implementation-specific location, which is typically the properties file
* {@code conf/security/java.security} in the Java installation directory.
*
* @implNote If this property file fails to load, the JDK implementation will
* throw an unspecified error when initializing the {@code Security} class.
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd probably use "the property file" rather than "this property file" here but otherwise the implNote looks okay to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change "property file" to "properties file".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd probably use "the property file" rather than "this property file" here but otherwise the implNote looks okay to me.

Ok with me.

@@ -47,6 +47,9 @@
* implementation-specific location, which is typically the properties file
* {@code conf/security/java.security} in the Java installation directory.
*
* @implNote If this property file fails to load, the JDK implementation will
* throw an unspecified error when initializing the {@code Security} class.
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change "property file" to "properties file".

@@ -47,6 +47,9 @@
* implementation-specific location, which is typically the properties file
* {@code conf/security/java.security} in the Java installation directory.
*
* @implNote If this property file fails to load, the JDK implementation will
* throw an unspecified error when initializing the {@code Security} class.
*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd probably use "the property file" rather than "this property file" here but otherwise the implNote looks okay to me.

Ok with me.

@@ -22,6 +22,9 @@
# the command line, set the key security.overridePropertiesFile
# to false in the master security properties file. It is set to true
# by default.
#
# If this property file fails to load, the JDK implementation will throw
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change "property file" to "properties file".

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Aug 13, 2022
@openjdk
Copy link

openjdk bot commented Aug 13, 2022

@coffeys This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8155246: Throw error if default java.security file is missing

Reviewed-by: mullan

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 129 new commits pushed to the master branch:

  • e70747b: 8292305: [BACKOUT] JDK-8289208 Test DrawRotatedStringUsingRotatedFont.java occasionally crashes on MacOS
  • 22d6d31: 8284313: Improve warning messages when CDS archive fails to load
  • 00decca: 8289208: Test DrawRotatedStringUsingRotatedFont.java occasionally crashes on MacOS
  • 9f8cc42: 8292218: Convert PackageEntryTable to ResourceHashtable
  • 871b7da: 8291266: RenderPerfTest: missing content while rendering some primitives
  • 0c40128: 7194212: NPE in Flow.visitIdent
  • 6eb7c3a: 8290732: JNI DestroyJavaVM can start shutdown when one non-daemon thread remains
  • 083e014: 8292233: Increase symtab hash table size
  • 45e5b31: 8292244: Remove unnecessary include directories
  • 9bfffa0: 8291945: Add OSInfo API for static OS information
  • ... and 119 more: https://git.openjdk.org/jdk/compare/af76c0c1991f6051ba95f05b79121a7eeef8e7d3...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 13, 2022
@coffeys
Copy link
Contributor Author

coffeys commented Aug 15, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Aug 15, 2022

Going to push as commit 9d7c13e.
Since your change was applied there have been 135 commits pushed to the master branch:

  • e89abb7: 8292190: [IR Framework] Remove redundant regex matching for failing counts constraints
  • 77cd917: Merge
  • 967a28c: 8292260: [BACKOUT] JDK-8279219: [REDO] C2 crash when allocating array of size too large
  • 1c1c441: 8292072: NMT: repurpose Tracking overhead counter as global malloc counter
  • d546d13: 8292319: ProblemList 2 runtime/cds/appcds tests due to JDK-8292313
  • 8353a33: 8286313: [macos] Voice over reads the boolean value as null in the JTable
  • e70747b: 8292305: [BACKOUT] JDK-8289208 Test DrawRotatedStringUsingRotatedFont.java occasionally crashes on MacOS
  • 22d6d31: 8284313: Improve warning messages when CDS archive fails to load
  • 00decca: 8289208: Test DrawRotatedStringUsingRotatedFont.java occasionally crashes on MacOS
  • 9f8cc42: 8292218: Convert PackageEntryTable to ResourceHashtable
  • ... and 125 more: https://git.openjdk.org/jdk/compare/af76c0c1991f6051ba95f05b79121a7eeef8e7d3...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 15, 2022
@openjdk openjdk bot closed this Aug 15, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 15, 2022
@openjdk
Copy link

openjdk bot commented Aug 15, 2022

@coffeys Pushed as commit 9d7c13e.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated security security-dev@openjdk.org
5 participants