nix icon indicating copy to clipboard operation
nix copied to clipboard

PTRACE_GETREGSET and PTRACE_SETREGSET basic implementation on aarch64

Open irgstg opened this issue 3 years ago • 4 comments
trafficstars

As I mentioned in https://github.com/nix-rust/nix/issues/1419#issuecomment-1094251694 I had this code implemented in a personal project of mine.

As some of you might know, to read and modify tracee's registers with ptrace on aarch64, one need to do so by calling ptrace via iovec. (man ptrace under PTRACE_GETREGSET)

This current PR supports aarch64 linux and android and includes:

  • Two generic ptrace calls to receive and modify data via iovec: ptrace_get_iovec_data and ptrace_set_iovec_data.
  • Two pub functions that supports modify and read of tracee's registers: ptrace_getregset and ptrace_setregset
  • Test function, test_ptrace_regsets, that receives tracee's registers, modify one of them, and validate if the modification completed successfully.

I might will modify some minor changes.

I want to get you're special attention about this line from man ptrace: On return, the kernel modifies iov.len to indicate the actual number of bytes returned. In my original implemented I didn't add anything to validate that, and I'm not aware what'd this repo's conventions dictate in such occasion, so leave a comment and I will edit the code as necessery.

Please let me know if I forgot or missed something.

irgstg avatar Apr 10 '22 12:04 irgstg

any updates?

tiann avatar Aug 05 '22 05:08 tiann

any updates?

Seems like I did my job?

irgstg avatar Oct 03 '22 20:10 irgstg

Can someone review this PR?

2096779623 avatar Nov 05 '22 05:11 2096779623

I'm also waiting for this PR to merge.

dolby360 avatar Feb 22 '24 15:02 dolby360

Hi, plan to take a look at this PR this weekend, sorry for being so late, and I am not sure if we can have @irgstg back as it has been 2 years, if not, I will file a PR to supersede this one.

SteveLauC avatar Mar 26 '24 23:03 SteveLauC

I tend to merge #2044 as it:

  1. Allows users to specify the register set
  2. Has riscv64 supported as well

@irgstg, thanks for your work and this detailed description, it helps a lot! And I am sorry that I will close this PR:<

SteveLauC avatar Mar 31 '24 03:03 SteveLauC