Skip to content

8279545: Buffer overrun in reverse_words of sharedRuntime_x86_64.cpp:3517 #7053

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

Closed
wants to merge 2 commits into from

Conversation

hseigel
Copy link
Member

@hseigel hseigel commented Jan 12, 2022

Please review this small fix to prevent a potential integer overflow that can cause a buffer overrun. The fix was tested with Mach5 tiers 1-2 on Linux, Mac OS, and Windows, Mach5 tiers 3-5 on Linux x64, and Mach5 builds of the JDK on PPC and S390.

Thanks, Harold


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8279545: Buffer overrun in reverse_words of sharedRuntime_x86_64.cpp:3517

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7053/head:pull/7053
$ git checkout pull/7053

Update a local copy of the PR:
$ git checkout pull/7053
$ git pull https://git.openjdk.java.net/jdk pull/7053/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 7053

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7053.diff

Sorry, something went wrong.

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 12, 2022

👋 Welcome back hseigel! 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 Jan 12, 2022
@openjdk
Copy link

openjdk bot commented Jan 12, 2022

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

  • hotspot-compiler

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 hotspot-compiler hotspot-compiler-dev@openjdk.org label Jan 12, 2022
@hseigel
Copy link
Member Author

hseigel commented Jan 12, 2022

/label add hotspot-runtime

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Jan 12, 2022
@openjdk
Copy link

openjdk bot commented Jan 12, 2022

@hseigel
The hotspot-runtime label was successfully added.

@mlbridge
Copy link

mlbridge bot commented Jan 12, 2022

Webrevs

@@ -3246,8 +3246,8 @@ void SharedRuntime::montgomery_square(jint *a_ints, jint *n_ints,
// Make very sure we don't use so much space that the stack might
// overflow. 512 jints corresponds to an 16384-bit integer and
// will use here a total of 6k bytes of stack space.
guarantee(longwords <= 341, "must be");
Copy link
Contributor

Choose a reason for hiding this comment

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

I was mystified about this number. Can you make this instead like:

int thing = sizeof (unsigned long) * 3;
guarantee(longwords <= 8192 / thing, "must be");

Or is division just as unsafe?

Should this be uint64_t, not long ? Or change it to julong if it's a small change to match the x86 version.

Copy link
Member Author

Choose a reason for hiding this comment

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

How about just: guarantee(longwords <= 8092 / (sizeof(julong) * 3), "must be"); ?
I don't think that doing division is a problem.

Copy link
Contributor

@coleenp coleenp 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, thanks!

@openjdk
Copy link

openjdk bot commented Jan 13, 2022

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

8279545: Buffer overrun in reverse_words of sharedRuntime_x86_64.cpp:3517

Reviewed-by: coleenp, lfoltan

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

  • e8f494c: 8279825: JFR: JFCModel shouldn't need FilePermission to read predefined .jfc files
  • 9f30ec1: 8278398: jwebserver: Add test to confirm maximum request time
  • dd76a28: 8280000: Remove unused CardTable::find_covering_region_containing
  • 84976b4: 8278549: UNIX sun/font coding misses SUSE distro detection on recent distro SUSE 15
  • 965c64b: 8279699: Parallel: More precise boundary in ObjectStartArray::object_starts_in_range
  • 35172cd: 8278951: containers/cgroup/PlainRead.java fails on Ubuntu 21.10
  • 237f861: 8273143: Transition to _thread_in_vm when handling a polling page exception
  • 9209e6d: 8279877: Document IDEA IDE setup in docs/ide.md
  • 0a839b4: 8279801: EC KeyFactory and KeyPairGenerator do not have aliases for OID format
  • 6fcaa32: 8262442: (windows) Use all proxy configuration sources when java.net.useSystemProxies=true
  • ... and 16 more: https://git.openjdk.java.net/jdk/compare/f54ce84474c2ced340c92564814fa5c221415944...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 13, 2022
Copy link
Member

@lfoltan lfoltan 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.
Lois

@hseigel
Copy link
Member Author

hseigel commented Jan 14, 2022

Thanks Coleen and Lois for the reviews!

/integrate

@openjdk
Copy link

openjdk bot commented Jan 14, 2022

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

  • e8f494c: 8279825: JFR: JFCModel shouldn't need FilePermission to read predefined .jfc files
  • 9f30ec1: 8278398: jwebserver: Add test to confirm maximum request time
  • dd76a28: 8280000: Remove unused CardTable::find_covering_region_containing
  • 84976b4: 8278549: UNIX sun/font coding misses SUSE distro detection on recent distro SUSE 15
  • 965c64b: 8279699: Parallel: More precise boundary in ObjectStartArray::object_starts_in_range
  • 35172cd: 8278951: containers/cgroup/PlainRead.java fails on Ubuntu 21.10
  • 237f861: 8273143: Transition to _thread_in_vm when handling a polling page exception
  • 9209e6d: 8279877: Document IDEA IDE setup in docs/ide.md
  • 0a839b4: 8279801: EC KeyFactory and KeyPairGenerator do not have aliases for OID format
  • 6fcaa32: 8262442: (windows) Use all proxy configuration sources when java.net.useSystemProxies=true
  • ... and 16 more: https://git.openjdk.java.net/jdk/compare/f54ce84474c2ced340c92564814fa5c221415944...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jan 14, 2022

@hseigel Pushed as commit 35734ad.

💡 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
hotspot-compiler hotspot-compiler-dev@openjdk.org hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

None yet

3 participants