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

Fix alignment of uc_mcontext in ucontext_t on arm64 android #3894

Merged
merged 1 commit into from
Sep 24, 2024

Conversation

CUB3D
Copy link
Contributor

@CUB3D CUB3D commented Sep 1, 2024

On ARM64 Android there should be padding between uc_sigmask and uc_mcontext in libc::ucontext_t, see here

Now core::mem::offset_of!(libc::ucontext_t, uc_mcontext) is the expected value of 0xB0

fixes #3655

@rustbot
Copy link
Collaborator

rustbot commented Sep 1, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @tgross35 (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@tgross35
Copy link
Contributor

tgross35 commented Sep 1, 2024

Thanks! Does [u8; 1024 / 8 - size_of::<sigset_t>()] work here to mirror the source? The field also needs to be public, otherwise this isn't possible to construct (I suspect there will be a CI error edit: nevermind, we don't run aarch64 android).

@CUB3D
Copy link
Contributor Author

CUB3D commented Sep 1, 2024

Thanks! Does [u8; 1024 / 8 - size_of::<sigset_t>()] work here to mirror the source? The field also needs to be public, otherwise this isn't possible to construct (I suspect there will be a CI error edit: nevermind, we don't run aarch64 android).

Apparently it does! Also fixed the visibility, although you still won't be able to construct a ucontext_t because of the sigset_t

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

Thanks!

Since this is a fix to a tier 2 target, it should be okay to backport.

@rustbot label +stable-nominated

@rustbot rustbot added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Sep 24, 2024
@tgross35 tgross35 added this pull request to the merge queue Sep 24, 2024
Merged via the queue into rust-lang:main with commit 707d32c Sep 24, 2024
41 checks passed
@tgross35
Copy link
Contributor

Hey @maurer would you mind sanity checking this? I was going to backport it but figure it is worth double checking since this is a breaking change.

@maurer
Copy link

maurer commented Oct 15, 2024

tl;dr: Change is fine, but I think we have this bug for aarch64 on base Linux, and need to update riscv as well in the same places, am I missing something?

This both seems correct and should be safe to backport, but I think it's actually incomplete.

For Android, this is also the case in riscv - we should probably add it to the rust-side riscv

However, I think this may be even worse - I checked the Linux headers for an unmodified upstream kernel - they also have this padding, but our aarch64-linux implementation currently doesn't.

tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Nov 6, 2024
@tgross35 tgross35 mentioned this pull request Nov 6, 2024
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Nov 6, 2024
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Nov 6, 2024
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Nov 7, 2024
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Nov 7, 2024
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Nov 7, 2024
[ change `core` to `::core` for backport - Trevor ]
(backport <rust-lang#3894>)
(cherry picked from commit 707d32c)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Nov 7, 2024
[ change `core` to `::core` and move ucontext_t to s_no_extra_traits for
  backport - Trevor ]
(backport <rust-lang#3894>)
(cherry picked from commit 707d32c)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Nov 7, 2024
[ change `core` to `::core` and move ucontext_t to s_no_extra_traits for
  backport - Trevor ]
(backport <rust-lang#3894>)
(cherry picked from commit 707d32c)
tgross35 pushed a commit to tgross35/rust-libc that referenced this pull request Nov 7, 2024
[ change `core` to `::core` and move ucontext_t to s_no_extra_traits for
  backport - Trevor ]
(backport <rust-lang#3894>)
(cherry picked from commit 707d32c)
@github-actions github-actions bot mentioned this pull request Nov 7, 2024
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review stable-applied This PR has been cherry-picked to libc's stable release branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The offset of mcontext_t inside the libc::ucontext_t struct is incorrect
4 participants