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

Add ptrace::read_user and ptrace::write_user #1697

Merged
merged 1 commit into from
May 15, 2022

Conversation

nbaksalyar
Copy link
Contributor

No description provided.

@nbaksalyar
Copy link
Contributor Author

Hmm, the Linux armv7 build failure seems to be unrelated to changes made in this PR.

CHANGELOG.md Outdated
@@ -64,6 +64,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- Added `Ipv6DontFrag` for android, iOS, linux and macOS.
- Added `IpDontFrag` for iOS, macOS.
(#[1692](https://github.com/nix-rust/nix/pull/1692))
- Added `ptrace::read_user` and `ptrace::write_user` for Linux.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you rebase such that this is in the latest unreleased section (the current changes it's near are part of the 0.24.0 release) and also add a link back to this PR, like the other items in the CHANGELOG?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks!

@nbaksalyar nbaksalyar force-pushed the ptrace-user branch 2 times, most recently from 6620faa to 4930d37 Compare May 15, 2022 17:36
// Find the offset of `user.regs.rax` (or `eax` for x86)
let user_struct = std::mem::MaybeUninit::<libc::user>::uninit();
let user_struct_ptr = user_struct.as_ptr();
let rax_offset = get_rax_offset(user_struct_ptr) as usize - user_struct_ptr as usize;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nix already depends on the memoffset crate conditionally, and we can use it in our tests (may need to update Cargo.toml to do so).

It should be possible to use memoffset::offset_of to simplify this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great suggestion, that should be done 👍

Copy link
Collaborator

@rtzoeller rtzoeller left a comment

Choose a reason for hiding this comment

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

bors r+

@bors bors bot merged commit 6639c59 into nix-rust:master May 15, 2022
@nbaksalyar nbaksalyar deleted the ptrace-user branch May 15, 2022 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants