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

8323562: SaslInputStream.read() may return wrong value #17365

Closed
wants to merge 1 commit into from

Conversation

mrserb
Copy link
Member

@mrserb mrserb commented Jan 11, 2024

SaslInputStream.read() should return a value in the range from 0 to 255 per the spec of InputStream.read() but it returns the signed byte from the inBuf as is.


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-8323562: SaslInputStream.read() may return wrong value (Bug - P4)

Reviewers

Contributors

  • Aleksey Shipilev <shade@openjdk.org>

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 17365

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 11, 2024

👋 Welcome back serb! 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
Copy link

openjdk bot commented Jan 11, 2024

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

  • core-libs

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 core-libs core-libs-dev@openjdk.org label Jan 11, 2024
@mrserb mrserb marked this pull request as ready for review January 12, 2024 00:57
@mrserb
Copy link
Member Author

mrserb commented Jan 12, 2024

I'll wait until GA will be fixed.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 12, 2024
@mlbridge
Copy link

mlbridge bot commented Jan 12, 2024

Webrevs

@AlanBateman
Copy link
Contributor

Just curious if this was found by inspection or when debugging some issue with LDAP authentication? Asking on whether it is feasible or not to have more tests in this area.

@mrserb
Copy link
Member Author

mrserb commented Jan 12, 2024

/contributor add @shipilev

@openjdk
Copy link

openjdk bot commented Jan 12, 2024

@mrserb
Contributor Aleksey Shipilev <shade@openjdk.org> successfully added.

@mrserb
Copy link
Member Author

mrserb commented Jan 12, 2024

Just curious if this was found by inspection or when debugging some issue with LDAP authentication? Asking on whether it is feasible or not to have more tests in this area.

It was found by the code inspection.

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

Looks fine. I think the common style is to use capitalized 0xFF, but that one is not enforced consistently. This will do as well.

@shipilev
Copy link
Member

Just curious if this was found by inspection or when debugging some issue with LDAP authentication? Asking on whether it is feasible or not to have more tests in this area.

No need, that one is an easy target for static analyzers. This bug was found by one :)

@openjdk
Copy link

openjdk bot commented Jan 12, 2024

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

8323562: SaslInputStream.read() may return wrong value

Co-authored-by: Aleksey Shipilev <shade@openjdk.org>
Reviewed-by: shade, dfuchs

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

  • 65a0672: 8319773: Avoid inflating monitors when installing hash codes for LM_LIGHTWEIGHT
  • e22ab10: 8322537: Parallel: Remove experimental adjustment in PSAdaptiveSizePolicy
  • be900f1: 8323425: JFR: Auto-generated filename doesn't work with time-limited recording
  • 68c4286: 8323008: filter out harmful -std* flags added by autoconf from CXX
  • 7dc9dd6: 8234502: Merge GenCollectedHeap and SerialHeap
  • ed18222: 8323190: Segfault during deoptimization of C2-compiled code
  • 3e19bf8: 8323529: Relativize test image dependencies in microbenchmarks
  • ba23025: 8322957: Generational ZGC: Relocation selection must join the STS
  • 7c3a39f: 8323297: Fix incorrect placement of precompiled.hpp include lines
  • e72723d: 8323296: java/lang/Thread/virtual/stress/GetStackTraceALotWhenPinned.java#id1 timed out
  • ... and 21 more: https://git.openjdk.org/jdk/compare/b530c0281b5082994065b10addeb8366ffa58e2f...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 Jan 12, 2024
@AlanBateman
Copy link
Contributor

No need, that one is an easy target for static analyzers. This bug was found by one :)

I think this one will require digging into whether the no-arg read is used in the authentication or not. It might not be, in which case it's not testable with something that emulates LDAPv3. However if it is used then we should have fuzzing or other tests to exercise it. I'm not saying it should be part of this PR but finding a 15+ year issue in authentication code is concerning so will need follow-up.

@@ -78,7 +78,7 @@ public int read() throws IOException {
byte[] inBuf = new byte[1];
int count = read(inBuf, 0, 1);
if (count > 0) {
return inBuf[0];
return inBuf[0] & 0xff;
} else {
return -1;
Copy link
Member

@jaikiran jaikiran Jan 12, 2024

Choose a reason for hiding this comment

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

As a separate follow up, even this else block might need some review on whether count can practically be 0 here and if so whether it's OK to return -1 (implying EOF) in such cases.

@AlanBateman
Copy link
Contributor

I think this one will require digging into whether the no-arg read is used in the authentication or not.

Digging into this, it seems this was looked at last year and the conclusion was this code is not used, but for some reason there wasn't a follow up JBS issue created at the time.

@dfuch
Copy link
Member

dfuch commented Jan 12, 2024

I think this one will require digging into whether the no-arg read is used in the authentication or not. It might not be, in which case it's not testable with something that emulates LDAPv3. However if it is used then we should have fuzzing or other tests to exercise it. I'm not saying it should be part of this PR but finding a 15+ year issue in authentication code is concerning so will need follow-up.

AFAICT the no arg read() method is never called by the JNDI/LDAP stack. This explains why it never made any test fail.

@mrserb
Copy link
Member Author

mrserb commented Jan 12, 2024

/integrate

@openjdk
Copy link

openjdk bot commented Jan 12, 2024

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

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jan 12, 2024

@mrserb Pushed as commit 5cf7947.

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

@mrserb mrserb deleted the JDK-8323562 branch January 12, 2024 23:52
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
Development

Successfully merging this pull request may close these issues.

5 participants