<p></p>
<blockquote>
<p dir="auto">I'm puzzled here. I think the original problem is if syscall_enter_from_user_mode() return -1 by ptrace we should make the syscall return -ENOSYS. And we don't need to do anything if tracehook_report_syscall_entry() return 0. Because if tracehook_report_syscall_entry() return 0, then syscall_enter_from_user_mode() also return 0 (there is no SYSCALL_WORK_SYSCALL_EMU on LoongArch), and then do_syscall() will do the real syscall.</p>
</blockquote>
<p dir="auto">The problem is that <code>syscall_enter_from_user_mode</code> does a few different things but has a single return value - the new syscall nr. In particular, it calls both <code>arch_syscall_enter_tracehook</code> and <code>__secure_computing</code>, each of them can change pt_regs, but they have different semantics: while <code>__secure_computing</code> is guaranteed to call <code>syscall_set_return_value</code> e.g. in case of <code>SECCOMP_RET_ERRNO</code>, <code>arch_syscall_enter_tracehook</code> has no such option because <code>syscall_set_return_value</code> is not exposed to userspace and regs[4] is used for different purposes on entering and exiting syscall.</p>
<p dir="auto">btw, another problem with the current implementation of <code>do_syscall</code> is that unlike other architectures, here the ptracer cannot change the first syscall argument on entering syscall.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/strace/strace/pull/205#issuecomment-1008265907">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AOVBTRZPD4J6ZPFTWGP6JZTUVFLXXANCNFSM5KYUVD5Q">unsubscribe</a>.<br />Triage notifications on the go with GitHub Mobile for <a href="https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675">iOS</a> or <a href="https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub">Android</a>.
<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AOVBTR6CQBRLY7NGAZFIWXTUVFLXXA5CNFSM5KYUVD52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHQMOVMY.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><strace/strace/pull/205/c1008265907</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/strace/strace/pull/205#issuecomment-1008265907",
"url": "https://github.com/strace/strace/pull/205#issuecomment-1008265907",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>