Skip to content

Commit

Permalink
8332865: ubsan: os::attempt_reserve_memory_between reports overflow
Browse files Browse the repository at this point in the history
Reviewed-by: stuefe, clanger
  • Loading branch information
MBaesken committed Jun 6, 2024
1 parent f15d423 commit 8de5d20
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/hotspot/share/runtime/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1935,7 +1935,11 @@ char* os::attempt_reserve_memory_between(char* min, char* max, size_t bytes, siz
return nullptr; // overflow
}

char* const hi_att = align_down(MIN2(max, absolute_max) - bytes, alignment_adjusted);
char* const hi_end = MIN2(max, absolute_max);
if ((uintptr_t)hi_end < bytes) {
return nullptr; // no need to go on
}
char* const hi_att = align_down(hi_end - bytes, alignment_adjusted);
if (hi_att > max) {
return nullptr; // overflow
}
Expand Down

3 comments on commit 8de5d20

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 8de5d20 Jul 31, 2024

Choose a reason for hiding this comment

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

@MBaesken Could not automatically backport 8de5d201 to openjdk/jdk21u-dev due to conflicts in the following files:

  • src/hotspot/share/runtime/os.cpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk21u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk21u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-MBaesken-8de5d201-master

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 8de5d2014a87d58d389eb8400f619d1b1fa3abe7

# Backport the commit
$ git cherry-pick --no-commit 8de5d2014a87d58d389eb8400f619d1b1fa3abe7
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 8de5d2014a87d58d389eb8400f619d1b1fa3abe7'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk21u-dev with the title Backport 8de5d2014a87d58d389eb8400f619d1b1fa3abe7.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 8de5d201 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 6 Jun 2024 and was reviewed by Thomas Stuefe and Christoph Langer.

Thanks!

Please sign in to comment.