nix icon indicating copy to clipboard operation
nix copied to clipboard

Add implementation of `PTRACE_{GET,SET}REGSET`

Open hack3ric opened this issue 2 years ago • 4 comments

This is related to https://github.com/nix-rust/nix/pull/1695, but have many issues solved here:

  • {get,set}regset now allows specifying which set of registers to read/write, as defined in RegisterSet. This should be the expected behavior.
  • Also added PTRACE_{GET,SET}REGS for most platforms other than x86 using aforementioned implementation.

hack3ric avatar May 23 '23 17:05 hack3ric

Changelog added.

test_ptrace on Linux aarch64 failed while previously passed. Debugging.

Edit: Can't reproduce on qemu-system-aarch64, with Debian sid arm64, Rust 1.71.0 and GCC 13.

hack3ric avatar Jul 21 '23 07:07 hack3ric

I've rebased this patch to master. Any updates?

hack3ric avatar Oct 29 '23 17:10 hack3ric

From my perspective, all the work is blocked by #2166

SteveLauC avatar Oct 30 '23 03:10 SteveLauC

Any updates?

canoriz avatar Dec 11 '23 16:12 canoriz

BTW, #1695 has a good test, can we port it to this PR?

SteveLauC avatar Mar 31 '24 03:03 SteveLauC

BTW, #1695 has a good test, can we port it to this PR?

Ported.

hack3ric avatar Mar 31 '24 04:03 hack3ric

Cannot reproduce aarch64 test errors on real hardware (Radxa Rock 5B, RK3588, rustc 1.70.0, Linux 5.10.110-20-rockchip)

hack3ric avatar Mar 31 '24 05:03 hack3ric

Cannot reproduce aarch64 test errors on real hardware (Radxa Rock 5B, RK3588, rustc 1.70.0, Linux 5.10.110-20-rockchip)

I think I will set up a Linux VM on my m1 Mac to give it a test. BTW, we run Nix's tests with sudo, though I am not sure if it is related

SteveLauC avatar Mar 31 '24 07:03 SteveLauC

I think I will set up a Linux VM on my m1 Mac to give it a test.

Sorry for the late reply, I tested it in a aarch64 Linux VM, and it also failed with EIO:

[steve@fedora steve]$ uname -a
Linux fedora 6.7.11-orbstack-00143-ge6b82e26cd22 #1 SMP Sat Mar 30 12:20:36 UTC 2024 aarch64 GNU/Linux

[steve@fedora test]$ sudo --preserve-env=HOME $(which cargo) test --all-features sys::test_ptrace::test_ptrace_syscall
    Finished test [unoptimized + debuginfo] target(s) in 0.01s
     Running unittests src/lib.rs (/home/steve/Documents/workspace/nix/target/debug/deps/nix-4701d15085df23b3)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 19 filtered out; finished in 0.00s

     Running test/test.rs (/home/steve/Documents/workspace/nix/target/debug/deps/test-637c83b07deea78d)

running 1 test
test sys::test_ptrace::test_ptrace_syscall ... FAILED

failures:

---- sys::test_ptrace::test_ptrace_syscall stdout ----
thread 'sys::test_ptrace::test_ptrace_syscall' panicked at test/sys/test_ptrace.rs:262:59:
called `Result::unwrap()` on an `Err` value: EIO
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    sys::test_ptrace::test_ptrace_syscall

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 347 filtered out; finished in 0.00s

error: test failed, to rerun pass `--test test`

Is there anything I can do to help debug the issue?

SteveLauC avatar Apr 13 '24 03:04 SteveLauC

It turns out to be my bad. I ran tests on non-root and it just skipped it.

After some research it seems aarch64 and riscv64 does not support PTRACE_PEEKUSER at all and will just fail with EIO. I'll make that part of the test x86-only.

hack3ric avatar Apr 13 '24 14:04 hack3ric

The CI is still failing due to an unused import, let me give it a fix:)

SteveLauC avatar Apr 14 '24 00:04 SteveLauC