<p></p>
<blockquote>
<p dir="auto">On Sun, Jan 09, 2022 at 05:58:44AM -0800, Huacai Chen wrote: > > With <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/chenhuacai/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/chenhuacai">@chenhuacai</a>'s <a href="%5Bxen0n/linux@593f8c0%5D(https://github.com/xen0n/linux/commit/593f8c0180fc1056e3ea0ca91ce9a8096f40b7ef)">latest patch</a>, every test passes except this: > > Yes, this looks plausible. > > As I said earlier, 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 because it is currently stored in <code>regs->orig_a0</code> which is out of reach of ptracers. What do you think about exposing <code>regs->orig_a0</code> to ptracers? Exposing orig_a0 means modifying user_pt_regs, gpr_get(), gpr_set() and all tracers (gdb, strace, etc) and don't need to overriding arch_syscall_enter_tracehook(), right?<br>
Yes, exposing orig_a0 means modifying user_pt_regs, gpr_get(), gpr_set(), and all tracers. This would allow to do regs->regs[4] = -ENOSYS; in do_syscall() right before the syscall_enter_from_user_mode() invocation, and there won't be any need to override arch_syscall_enter_tracehook() then.</p>
</blockquote>
<p dir="auto">Hmm, there is a more simple solution, overide arch_syscall_enter_tracehook() as below:</p>
<p dir="auto">static inline __must_check int arch_syscall_enter_tracehook(struct pt_regs *regs)<br>
{<br>
int ret = tracehook_report_syscall_entry(regs);</p>
<pre><code>    regs->orig_a0 = regs->regs[4];
    syscall_set_return_value(current, regs, -ENOSYS, 0);

    return ret;
</code></pre>
<p dir="auto">}</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-1010777457">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AOVBTR5DMRJA5F3PPL3VRKDUVU44JANCNFSM5KYUVD5Q">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/AOVBTR7NMKMLFIQ2KSKRYADUVU44JA5CNFSM5KYUVD52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHQ7T24I.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/c1010777457</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-1010777457",
"url": "https://github.com/strace/strace/pull/205#issuecomment-1010777457",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>