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

Added AddressType type to ptrace::linux + peek/poke user fix #958

Merged
merged 2 commits into from Oct 30, 2018

Conversation

@xd009642
Copy link
Contributor

@xd009642 xd009642 commented Oct 22, 2018

This was added to the BSD ptrace API and probably should have been added to the linux API to make it easier to write code for both platforms without the user having to reexport the types to their own crate.

I went to use the latest nix myself and found that having this added would improve usability for nix users.

Could potentially add a type for what they return (BSDs: c_int, linux: c_long). Data input might be trickier as linux is *mut c_void and BSD just takes data as c_int.

@xd009642 xd009642 changed the title Added AddressType type to ptrace::linux Added AddressType type to ptrace::linux + peek/poke user fix Oct 22, 2018
@xd009642
Copy link
Contributor Author

@xd009642 xd009642 commented Oct 22, 2018

I also realised I accidentally conflated (PEEK|POKE)_USER with the peeks and pokes for text and data which are equivalent, whereas user refers to the user struct. This is technically a regression although the functionality is deprecated so don't know if you guys want it reverted or not?

@xd009642
Copy link
Contributor Author

@xd009642 xd009642 commented Oct 24, 2018

@asomers do you have time to have a look at this?

@asomers
Copy link
Member

@asomers asomers commented Oct 24, 2018

So the PTRACE_PEEKUSER mistake crept in in PR #949 ? Then you should fix it. It isn't really a regression from the users' point of view, because there hasn't been a release since then. I think this PR is fine, but you do need to update the existing CHANGELOG entry for 949 with the additional PR link.

@xd009642
Copy link
Contributor Author

@xd009642 xd009642 commented Oct 24, 2018

Yeah there's no tests for it so I didn't realise I'd made a mistake. Unfortunately it's pretty hard to test as it relies on knowledge of the user struct and what's happening in the test executable - unless you can think of a better way?

@xd009642 xd009642 force-pushed the xd009642:AddressType branch from 5a2f529 to 802534c Oct 24, 2018
@asomers
Copy link
Member

@asomers asomers commented Oct 24, 2018

No. I'm not even clear on what PTRACE_PEEK_USER does. Is it redundant with PTRACE_GETREGS?

@xd009642
Copy link
Contributor Author

@xd009642 xd009642 commented Oct 24, 2018

I think it might be, PTRACE_PEEK_USER reads a single word from a given offset into the user struct, from looking at the man page it seems PTRACE_GETREGS reads the entire user struct not just one word.

This was added to the BSD ptrace API and probably should have been added to tyhe linux API to make it easier to write code for both platforms without the user having to reexport the types to their own crate.
@xd009642 xd009642 force-pushed the xd009642:AddressType branch from 802534c to b5dc2d3 Oct 24, 2018
@@ -30,6 +30,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
([#949](https://github.com/nix-rust/nix/pull/949))
- Added a `acct` wrapper module for enabling and disabling process accounting
([#952](https://github.com/nix-rust/nix/pull/952))
([#949](https://github.com/nix-rust/nix/pull/949)) ([#958](https://github.com/nix-rust/nix/pull/958))

This comment has been minimized.

@asomers

asomers Oct 24, 2018
Member

Looks like you got a merge error when you rebased.

@xd009642 xd009642 force-pushed the xd009642:AddressType branch from b5dc2d3 to bf8da70 Oct 24, 2018
- Added a `acct` wrapper module for enabling and disabling process accounting
([#952](https://github.com/nix-rust/nix/pull/952))
([#949](https://github.com/nix-rust/nix/pull/949))

This comment has been minimized.

@asomers

asomers Oct 26, 2018
Member

CHANGELOG still isn't right.

@xd009642 xd009642 force-pushed the xd009642:AddressType branch from bf8da70 to 12578de Oct 28, 2018
@xd009642
Copy link
Contributor Author

@xd009642 xd009642 commented Oct 30, 2018

Fixed (I hope)

Copy link
Member

@asomers asomers left a comment

bors r+

bors bot added a commit that referenced this pull request Oct 30, 2018
Merge #958
958: Added AddressType type to ptrace::linux + peek/poke user fix r=asomers a=xd009642

This was added to the BSD ptrace API and probably should have been added to the linux API to make it easier to write code for both platforms without the user having to reexport the types to their own crate.

I went to use the latest nix myself and found that having this added would improve usability for nix users.

Could potentially add a type for what they return (BSDs: `c_int`, linux: `c_long`). Data input might be trickier as linux is `*mut c_void` and BSD just takes data as `c_int`.

Co-authored-by: xd009642 <danielmckenna93@gmail.com>
@bors bors bot merged commit 12578de into nix-rust:master Oct 30, 2018
4 checks passed
4 checks passed
bors Build succeeded
Details
buildbot/nix-rust/nix amd64_fbsd11 Build done.
Details
buildbot/nix-rust/nix i386_fbsd11 Build done.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants