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

8320798: Console read line with zero out should zero out underlying buffer #16861

Closed
wants to merge 5 commits into from

Conversation

naotoj
Copy link
Member

@naotoj naotoj commented Nov 28, 2023

It is best practice to zero out the underlying buffer after use.


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

Issue

  • JDK-8320798: Console read line with zero out should zero out underlying buffer (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16861

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 28, 2023

👋 Welcome back naoto! 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 rfr Pull request is ready for review label Nov 28, 2023
@openjdk
Copy link

openjdk bot commented Nov 28, 2023

@naotoj The following labels will be automatically applied to this pull request:

  • core-libs
  • nio

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

@openjdk openjdk bot added nio nio-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels Nov 28, 2023
@mlbridge
Copy link

mlbridge bot commented Nov 28, 2023

Webrevs


private void lockedFillZeroToPosition() throws IOException {
ensureOpen();
Arrays.fill(bb.array(), 0, bb.arrayOffset() + bb.position(), (byte)0);
Copy link
Member

Choose a reason for hiding this comment

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

Should the from parameter be zero or bb.arrayOffset()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right. Fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

The buffer is allocated in StreamDecoder so I assume the array offset is 0 anyway, so I think they will be the same.

Copy link
Member

@bplb bplb left a comment

Choose a reason for hiding this comment

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

Looks good now.

@openjdk
Copy link

openjdk bot commented Nov 28, 2023

@naotoj 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:

8320798: Console read line with zero out should zero out underlying buffer

Reviewed-by: bpb, lancea, joehw, alanb, jpai, mbaesken

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 90 new commits pushed to the master branch:

  • 8f1d40b: 8321114: Rename "Unnamed Classes" to "Implicitly Declared Classes" better
  • ecd335d: 8321107: Add more test cases for JDK-8319372
  • 2476be4: 8320716: ResolvedModule::reads includes self when configuration contains two or more automatic modules
  • 4ba94ef: 8320145: Compiler should accept final variable in Record Pattern
  • 02ffab1: 8321141: VM build issue on MacOS after JDK-8267532
  • 56d4c33: 8227529: With malformed --app-image the error messages are awful
  • 76fea80: 8320608: Many jtreg printing tests are missing the @printer keyword
  • c4732c2: 8320530: has_resolved_ref_index flag not restored after resetting entry
  • e96e191: 8318586: Explicitly handle upcall stub allocation failure
  • 630bafd: 8320826: call allocate_shared_strings_array after all strings are interned
  • ... and 80 more: https://git.openjdk.org/jdk/compare/82967f45db3b9555be03fcabdba380852ea21e2c...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 Nov 28, 2023
}

private void lockedFillZeroToPosition() throws IOException {
ensureOpen();
Copy link
Member

Choose a reason for hiding this comment

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

Hello Naoto, is this open check needed? Given that we are just zeroing out already read content, would it thus be OK to clear that content to zero even after this Reader instance has been closed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, Jai. Removed it.

@jaikiran
Copy link
Member

Given that the default JdkConsole provider implementation is the one that uses jline (in jdk.internal.le module), should we also do something to zero out this data in its implementation too. A brief glance suggests that it too uses an internal implementation class called jdk.internal.org.jline.reader.impl.BufferImpl.

@AlanBateman
Copy link
Contributor

Given that the default JdkConsole provider implementation is the one that uses jline (in jdk.internal.le module), should we also do something to zero out this data in its implementation too. A brief glance suggests that it too uses an internal implementation class called jdk.internal.org.jline.reader.impl.BufferImpl.

This PR is the console implementation in java.base, there will be other changes for jline.

@naotoj
Copy link
Member Author

naotoj commented Nov 30, 2023

Created an equivalent issue for addressing JLine: https://bugs.openjdk.org/browse/JDK-8321131

Copy link
Member

@jaikiran jaikiran left a comment

Choose a reason for hiding this comment

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

Thank you for the update Naoto. The changes look good to me.

@naotoj
Copy link
Member Author

naotoj commented Dec 1, 2023

Thanks all for the reviews!

/integrate

@openjdk
Copy link

openjdk bot commented Dec 1, 2023

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

  • 3087e14: 8320807: [PPC64][ZGC] C1 generates wrong code for atomics
  • 54957ac: 8312560: Annotation on Decomposed Record Component in Enhanced For Loop Fails Compilation
  • 3b30095: 8321130: Microbenchmarks do not build any more after 8254693 on 32 bit platforms
  • 8f1d40b: 8321114: Rename "Unnamed Classes" to "Implicitly Declared Classes" better
  • ecd335d: 8321107: Add more test cases for JDK-8319372
  • 2476be4: 8320716: ResolvedModule::reads includes self when configuration contains two or more automatic modules
  • 4ba94ef: 8320145: Compiler should accept final variable in Record Pattern
  • 02ffab1: 8321141: VM build issue on MacOS after JDK-8267532
  • 56d4c33: 8227529: With malformed --app-image the error messages are awful
  • 76fea80: 8320608: Many jtreg printing tests are missing the @printer keyword
  • ... and 83 more: https://git.openjdk.org/jdk/compare/82967f45db3b9555be03fcabdba380852ea21e2c...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Dec 1, 2023

@naotoj Pushed as commit d568562.

💡 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
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated nio nio-dev@openjdk.org
7 participants