[strace/strace] [RFC] Add 64-bit LoongArch support (PR #205)

Dmitry V. Levin notifications at github.com
Fri Jan 7 18:01:46 UTC 2022


Well, the syscall cancellation itself seems to be working, it's the return value handling that is not implemented properly in the kernel:

```
[gcc401 src]$ cat close2.c
#include <unistd.h>
int main() {
	dup2(0, 42);
	close(42);
	close(42);
	return 0;
}
[gcc401 src]$ ./strace -qq -eclose ./close2
close(3)                                = 0
close(42)                               = 0
close(42)                               = -1 EBADF (Bad file descriptor)
[gcc401 src]$ ./strace -qq -eclose -einject=close:error=enosys:when=2 ./close2
close(3)                                = 0
close(42./strace: Failed to tamper with process 2758428: unexpectedly got no error (return value 0x2a, error 0)
)                               = 42 (INJECTED)
close(42)                               = 0
[gcc401 src]$ ./strace -qq -eclose -einject=close:retval=9:when=2 ./close2
close(3)                                = 0
close(42./strace: Failed to tamper with process 2758433: unexpectedly got no error (return value 0x2a, error 0)
)                               = 42 (INJECTED)
close(42)                               = 0
[gcc401 src]$ ./strace -qq -esignal=none -eptrace ./strace -qq -eclose -einject=close:error=enosys:when=2 -o/dev/null ./close2
...
ptrace(PTRACE_GET_SYSCALL_INFO, 2758442, 88, {op=PTRACE_SYSCALL_INFO_ENTRY, arch=AUDIT_ARCH_LOONGARCH64, instruction_pointer=0x7ffff2fab930, stack_pointer=0x7ffffbb55fb0, entry={nr=__NR_close, args=[0x2a, 0x2a, 0, 0x7ffff303c538, 0, 0x7ffff305af90]}}) = 80
ptrace(PTRACE_GETREGSET, 2758442, NT_PRSTATUS, {iov_base={regs=[0, 0x12000054c, 0x7ffff307af90, 0x7ffffbb55fb0, 0x2a, 0x2a, 0, 0x7ffff303c538, 0, 0x7ffff305af90, 0x7ffffbb56140, 0x39, 0x7ffff3079200, 0x8, 0x1200084f0, 0x7ffff3061090, 0x1, 0x101010101010101, 0x7f7f7f7f7f7f7f7f, 0x10, 0x2, 0x7ac0000, 0, 0x7ffffbb56148, 0x1, 0, 0x120000530, 0x7ffff3077228, 0, 0x7ffffbb56158, 0x120007e38, 0], csr_era=0x7ffff2fab930, csr_badv=0x7ffff2fab9f0, reserved=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}, iov_len=360}) = 0
ptrace(PTRACE_SETREGSET, 2758442, NT_PRSTATUS, {iov_base={regs=[0, 0x12000054c, 0x7ffff307af90, 0x7ffffbb55fb0, 0x2a, 0x2a, 0, 0x7ffff303c538, 0, 0x7ffff305af90, 0x7ffffbb56140, 0xffffffffffffffff, 0x7ffff3079200, 0x8, 0x1200084f0, 0x7ffff3061090, 0x1, 0x101010101010101, 0x7f7f7f7f7f7f7f7f, 0x10, 0x2, 0x7ac0000, 0, 0x7ffffbb56148, 0x1, 0, 0x120000530, 0x7ffff3077228, 0, 0x7ffffbb56158, 0x120007e38, 0], csr_era=0x7ffff2fab930, csr_badv=0x7ffff2fab9f0, reserved=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]}, iov_len=360}) = 0
ptrace(PTRACE_SYSCALL, 2758442, NULL, 0) = 0
ptrace(PTRACE_GET_SYSCALL_INFO, 2758442, 88, {op=PTRACE_SYSCALL_INFO_EXIT, arch=AUDIT_ARCH_LOONGARCH64, instruction_pointer=0x7ffff2fab934, stack_pointer=0x7ffffbb55fb0, exit={rval=42, is_error=0}}) = 33
./strace: Failed to tamper with process 2758442: unexpectedly got no error (return value 0x2a, error 0)
...
```

You can see from this example that in case of syscall cancellation the first syscall argument is returned unconditionally as the return value.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/strace/strace/pull/205#issuecomment-1007615226
You are receiving this because you are subscribed to this thread.

Message ID: <strace/strace/pull/205/c1007615226 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20220107/c01d45a8/attachment.htm>


More information about the Strace-devel mailing list