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

Restrict direct access to sun.misc.Unsafe #43479

Closed
laurentgo opened this issue Jul 30, 2024 · 1 comment
Closed

Restrict direct access to sun.misc.Unsafe #43479

laurentgo opened this issue Jul 30, 2024 · 1 comment

Comments

@laurentgo
Copy link
Collaborator

Describe the enhancement requested

sun.misc.Unsafe is a Java internal class only accessible to classes loaded of the boot classloader, unless one uses reflection to bypass this restriction.

org.apache.arrow.memory.util.MemoryUtil makes it available as a public field to any java classes which is kind of opening a pandora box. As a first step towards switching from sun.misc.Unsafe to safer memory access methods (which may become a requirement at some point as discussed in JEP 471 ), remove direct access to sun.misc.Unsafe instance.

Component(s)

Java

laurentgo added a commit to laurentgo/arrow that referenced this issue Jul 30, 2024
`MemoryUtil.UNSAFE` field is a public field which provides unrestricted
access to `sun.misc.Unsafe` instance which may cause misusage and
possibly JVM crashes.

Make the field private and only allow indirect use of Unsafe through
`MemoryUtil` methods
danepitkin pushed a commit that referenced this issue Jul 30, 2024
### Rationale for this change

`MemoryUtil.UNSAFE` field is a public field which provides unrestricted access to `sun.misc.Unsafe` instance which may cause misusage and possibly JVM crashes.

### What changes are included in this PR?

Make the field (and other related fields) private and only allow indirect use of Unsafe through `MemoryUtil` methods

### Are these changes tested?

Yes.

### Are there any user-facing changes?

No

**This PR includes breaking changes to public APIs.** 

Code using `MemoryUtil.UNSAFE` would break as the visibility of the field was changed to private
* GitHub Issue: #43479

Authored-by: Laurent Goujon <[email protected]>
Signed-off-by: Dane Pitkin <[email protected]>
@danepitkin danepitkin added this to the 18.0.0 milestone Jul 30, 2024
@danepitkin
Copy link
Member

Issue resolved by pull request 43480
#43480

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants