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

Dmitry V. Levin notifications at github.com
Fri Jan 7 22:20:56 UTC 2022

> The problematic piece of kernel code is
> ```
>         if ((nr == -1UL) && (onr != -1UL))
>                 goto out; /* Don't set -ENOSYS for SECCOMP */
> ```
> Here the `Don't set -ENOSYS for SECCOMP` is the culprit: when the syscall is cancelled by ptrace/seccomp, the return value must be set properly to -ENOSYS.

This piece of code is correct for SECCOMP because the latter calls `syscall_set_return_value` itself.

Unfortunately, this approach is not applicable for ptrace:
ptracer cannot set syscall return value on entering syscall
because the register used for the return value is often used for other purposes.
For example, on x86 it's also used for the syscall nr, and on loongarch it's also used for the first syscall argument.

I'm afraid `syscall_enter_from_user_mode` needs to be changed before it could be used on loongarch.
Besides loongarch, the only architecture where `syscall_enter_from_user_mode` is used
is x86 where `rax` is initialized to `-ENOSYS` before `syscall_enter_from_user_mode` is invoked.

Reply to this email directly or view it on GitHub:
You are receiving this because you are subscribed to this thread.

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

More information about the Strace-devel mailing list