-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8371918: aarch64: Incorrect pointer dereference in TemplateInterpreterGenerator::generate_native_entry #28327
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
Conversation
…rGenerator::generate_native_entry Remove errant aarch64 hotspot assembly instruction that was reading from libjvm.so .text segment.
|
👋 Welcome back kurt! A progress list of the required criteria for merging this PR into |
|
@bsdkurt 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: 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 41 new commits pushed to the
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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@theRealAph, @shipilev) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
Here is a gdb session on OpenBSD/aarch64 without this patch showing the SEGFAULT where the |
|
It looks like RISCV is broken in the same way. |
|
According to InterpreterRuntime::prepare_native_call(), if there is a signal handler, which is checked first, then there should be a native function. So I wonder if we can remove the check for the native function from all CPU ports. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, I see.
The mistake was mine: I thought __ cmpptr(rax, unsatisfied.addr(), rscratch1) meant
__ cmpptr(rax, unsatisfied, rscratch1). In other words, I missed the significance of .addr().
Fired new JBS for RISC-V: https://bugs.openjdk.org/browse/JDK-8371966 |
|
@theRealAph Thank you for the review. /integrate |
shipilev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable.
|
I did also wonder how it is not breaking now with uninitialized native entries. But I see we are doing this init as part of signature handler resolution: jdk/src/hotspot/cpu/aarch64/templateInterpreterGenerator_aarch64.cpp Lines 1323 to 1334 in 54893dc
|
|
/sponsor |
|
Going to push as commit ae4d9c2.
Your commit was automatically rebased without conflicts. |
|
@shipilev Thank you for the review and sponsor. I was wondering why this issue had not been discovered previously. It does appear that the check against unsatisfied link may be unnecessary. |
…rGenerator::generate_native_entry
I believe there's a incorrect pointer deference in
TemplateInterpreterGenerator::generate_native_entry()in this part of the code:If I understand this correctly, the entry point for unsatisfied link error is loaded into
rscratch2. The next instruction,ldr(rscratch2, rscratch2), dereferences that pointer and reads from the text segment the initial instructions at the entry point intorscratch2. It then compares the native method entry point inr10with the initial instructions loaded intorscratch2which will never match. I believe the intent here was to compare the native method entry point with the unsatisfied link error entry point and theldr(rscratch2, rscratch2)instruction should be removed.This was found on OpenBSD/aarch64. OpenBSD has a security feature where the text segments are marked execute only and do not allow reads independent of execution. the
ldr(rscratch2, rscratch2)instruction causes a segfault because it is reading the text segment. While this bug was found on OpenBSD I believe it applies to all OS on aaarch64.This change removes the errant aarch64 hotspot assembly instruction that was reading from libjvm.so .text segment.
Updated comment with markdown for code.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28327/head:pull/28327$ git checkout pull/28327Update a local copy of the PR:
$ git checkout pull/28327$ git pull https://git.openjdk.org/jdk.git pull/28327/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 28327View PR using the GUI difftool:
$ git pr show -t 28327Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28327.diff
Using Webrev
Link to Webrev Comment