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

8345296: AArch64: VM crashes with SIGILL when prctl is disallowed #1222

Closed
wants to merge 2 commits into from

Conversation

krk
Copy link
Contributor

@krk krk commented Dec 11, 2024

Ref. openjdk/jdk#22479

We have caught this in some prod environments, where prctl is forbidden by the sandboxing mechanism. This fails the JVM

Does not apply cleanly, the backport depends on FloatRegister changes from JDK-8339063 which are included in src/hotspot/cpu/aarch64/register_aarch64.hpp.

Additional testing:

  • Verified the bug is fixed with the seccomp repro from JDK-8345296: Segfault without the patch, works with.

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
  • JDK-8345296 needs maintainer approval

Issue

  • JDK-8345296: AArch64: VM crashes with SIGILL when prctl is disallowed (Bug - P3 - Approved)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk21u-dev.git pull/1222/head:pull/1222
$ git checkout pull/1222

Update a local copy of the PR:
$ git checkout pull/1222
$ git pull https://git.openjdk.org/jdk21u-dev.git pull/1222/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1222

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk21u-dev/pull/1222.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 11, 2024

👋 Welcome back krk! 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 Dec 11, 2024

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

8345296: AArch64: VM crashes with SIGILL when prctl is disallowed

Reviewed-by: shade, phh
Backport-of: 3c60f0b2bb75150d49da9ab94d88b767275de5e2

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

  • 29c1188: 8314909: tools/jpackage/windows/Win8282351Test.java fails with java.lang.AssertionError: Expected [0]. Actual [1618]:
  • a021113: 8320916: jdk/jfr/event/gc/stacktrace/TestParallelMarkSweepAllocationPendingStackTrace.java failed with "OutOfMemoryError: GC overhead limit exceeded"
  • e7111b2: 8346108: [21u][BACKOUT] 8337994: [REDO] Native memory leak when not recording any events

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 (@phohensee, @shipilev) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot changed the title Backport 3c60f0b2bb75150d49da9ab94d88b767275de5e2 8345296: AArch64: VM crashes with SIGILL when prctl is disallowed Dec 11, 2024
@openjdk
Copy link

openjdk bot commented Dec 11, 2024

This backport pull request has now been updated with issue from the original commit.

@openjdk openjdk bot added backport rfr Pull request is ready for review labels Dec 11, 2024
@mlbridge
Copy link

mlbridge bot commented Dec 11, 2024

Webrevs

@phohensee
Copy link
Member

/issue JDK-8339063

@openjdk
Copy link

openjdk bot commented Dec 11, 2024

@phohensee Only the author (@krk) is allowed to issue the /issue command.

Copy link
Member

@phohensee phohensee left a comment

Choose a reason for hiding this comment

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

Please add "/issue JDK-8339063" (I'm unsure of the exact syntax, but it's something like that :)), since it's included. Otherwise lgtm.

@krk
Copy link
Contributor Author

krk commented Dec 11, 2024

/issue JDK-8339063

@openjdk
Copy link

openjdk bot commented Dec 11, 2024

@krk
Adding additional issue to issue list: 8339063: [aarch64] Skip verify_sve_vector_length after native calls if SVE supports 128 bits VL only.

@openjdk
Copy link

openjdk bot commented Dec 12, 2024

⚠️ @krk This change is now ready for you to apply for maintainer approval. This can be done directly in each associated issue or by using the /approval command.

@shipilev
Copy link
Member

Seeing the report for Corretto 21 that demonstrates this issue affects some MacOS and Alpine configs:
corretto/corretto-21#85

@shipilev
Copy link
Member

shipilev commented Dec 12, 2024

I am not entirely convinced the modifications that JDK-8339063 does to this code are 100% safe. It tries to install the max vector size and exits the VM if not possible? That sounds like a behavioral change with unknown consequences. And unfortunately, that patch is only in JDK 24, so we do not yet know the impact well. Looks like we are mixing that backport because we need access to new FloatRegister constants?

If so, I think it would be safer to just take that particular hunk in register_aarch64.hpp only. Then if/when we do JDK-8339063 backport, it would slide right in. And meanwhile, we keep our reliability posture better.

@krk
Copy link
Contributor Author

krk commented Dec 12, 2024

Thanks for the details. Yes, it was to access the new FloatRegister constants. Simplifying this now.

@krk krk force-pushed the JDK-8345296-prctl-SIGILL branch from 8ec87dc to 3fc2808 Compare December 12, 2024 13:05
@openjdk
Copy link

openjdk bot commented Dec 12, 2024

@krk Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

@krk
Copy link
Contributor Author

krk commented Dec 12, 2024

Picked only the necessary hunks from JDK-8339063.

@shipilev
Copy link
Member

Also need /issue remove JDK-8339063 now?

@krk
Copy link
Contributor Author

krk commented Dec 12, 2024

I only included an independeny chunk, not implementing JDK-8339063. It could be independently reviewed.

@krk
Copy link
Contributor Author

krk commented Dec 12, 2024

/issue remove JDK-8339063

@openjdk
Copy link

openjdk bot commented Dec 12, 2024

@krk
Removing additional issue from issue list: 8339063.

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.

This looks correct.

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.

Right, include as well.

@krk
Copy link
Contributor Author

krk commented Dec 12, 2024

/approval request Fix VM crash on production workloads when prctl is disallowed, on AArch64 with SVE.

@openjdk
Copy link

openjdk bot commented Dec 12, 2024

@krk
8345296: The approval request has been created successfully.

@openjdk openjdk bot added the approval label Dec 12, 2024
@mrserb
Copy link
Member

mrserb commented Dec 12, 2024

@GoeLin We should consider fixing this bug in the upcoming January 2025 release. Jvm crash on different platforms, tested Alpine, AL2, AL2023, macOS 15.2+docker.
@shipilev please confirm

@shipilev
Copy link
Member

@GoeLin We should consider fixing this bug in the upcoming January 2025 release. Jvm crash on different platforms, tested Alpine, AL2, AL2023, macOS 15.2+docker. @shipilev please confirm

Yes, we are planning to pick this fix in Corretto release for January. I think this patch is beneficial to have in all January releases as well. This is ultimately 21u and 17u maintainers' call.

@jerboaa
Copy link
Contributor

jerboaa commented Dec 13, 2024

/approve yes

Since this is related to prctl returning -1 in some Docker environments on newer MacOS 15.2+. It does not seem reproducible on native Aarch64 Linux or MacOSX 15.2 and there is a work-around, -XX:UseSVE=0, lets keep this on the April schedule for now. It should be a safe change, but I don't see the urgency either.

@openjdk
Copy link

openjdk bot commented Dec 13, 2024

@jerboaa
8345296: The approval request has been approved.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed approval labels Dec 13, 2024
@krk
Copy link
Contributor Author

krk commented Dec 13, 2024

/sponsor

@openjdk
Copy link

openjdk bot commented Dec 13, 2024

@krk Only Committers are allowed to sponsor changes.

@krk
Copy link
Contributor Author

krk commented Dec 13, 2024

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Dec 13, 2024
@openjdk
Copy link

openjdk bot commented Dec 13, 2024

@krk
Your change (at version 704459c) is now ready to be sponsored by a Committer.

@shipilev
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Dec 13, 2024

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

  • 29c1188: 8314909: tools/jpackage/windows/Win8282351Test.java fails with java.lang.AssertionError: Expected [0]. Actual [1618]:
  • a021113: 8320916: jdk/jfr/event/gc/stacktrace/TestParallelMarkSweepAllocationPendingStackTrace.java failed with "OutOfMemoryError: GC overhead limit exceeded"
  • e7111b2: 8346108: [21u][BACKOUT] 8337994: [REDO] Native memory leak when not recording any events

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Dec 13, 2024

@shipilev @krk Pushed as commit 21b76f3.

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

@lprimak
Copy link

lprimak commented Dec 16, 2024

Hi @shipilev @krk

Looking a bit further into this, I do not understand what the "root cause" of this issue is.
Is this PR a workaround?
For example, running on any Arm machines I have access to (Mac, Graviton Linux, etc.) I cannot get the
-XX:UseSVE=1 to actually work.

What architecture does this support currently, if any?
It doesn't work on Mac M4, Mac M1, and under VM in Mac M1 or M4, etc.
Is the root cause somewhere in MacOS? If it is, I can't find one.

Thank you

@shipilev
Copy link
Member

Looking a bit further into this, I do not understand what the "root cause" of this issue is. Is this PR a workaround?

This fix makes sure VM does not crash if lower layer (whether native OS or whatever sandbox/virtualization layer) does not allow us to execute prctl(PR_SVE_GET_VL) to get SVE vector length. Whether this is a fix or a workaround depends on whether prohibiting prctl(PR_SVE_GET_VL) is a bug or not from the lower layer perspective :) I tend to think the innocuous prctl-s should be enabled, so I tend to think about this fix as the workaround.

What architecture does this support currently, if any? It doesn't work on Mac M4, Mac M1, and under VM in Mac M1 or M4, etc. Is the root cause somewhere in MacOS? If it is, I can't find one.

By "this" you mean SVE? SVE is a feature of modern AArch64 CPUs. AFAIU, this means Apple M4+, Graviton 3+, etc.

@lprimak
Copy link

lprimak commented Dec 16, 2024

Ok. I think I get it now.
the only machine with SVE I have access to is M4 Mac. My Graviton machines are G1 so they wouldn’t work.

So the root cause is that Sonoma 15.2 introduced a regression that breaks SVE.
it makes it unavailable natively and crashes JVM under a virtualization environments

thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

6 participants