<p></p>
<blockquote>
<blockquote>
<p dir="auto">Hmm, can we keep do_syscall() as is and solve the ptrace problem by overriding arch_syscall_enter_tracehook() like this?<br>
static inline __must_check int arch_syscall_enter_tracehook(struct pt_regs *regs) {</p>
<pre><code> ret = tracehook_report_syscall_entry(regs);
if (ret)
syscall_set_return_value(current, current_pt_regs(), -ENOSYS, 0);
</code></pre>
</blockquote>
<p dir="auto">It's better to use <code>regs</code> instead of <code>current_pt_regs()</code> here.</p>
<blockquote>
<pre><code>return ret;
</code></pre>
<pre><code>
}
</code></pre>
</blockquote>
<p dir="auto">No, this cannot help to solve the problem because syscall tampering doesn't make <code>tracehook_report_syscall_entry</code> return a nonzero value.<br>
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>
<blockquote>
<p dir="auto">However, this approach makes sense for a different reason - the lengthy comment before <code>tracehook_report_syscall_entry</code> says: <em>Returns zero normally, or nonzero if the calling arch code should abort the system call. That must prevent normal entry so no system call is made. If <a class="user-mention" data-hovercard-type="user" data-hovercard-url="/users/task/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/task">@task</a> ever returns to user mode after this, its register state is unspecified, but should be something harmless like an %ENOSYS error return.</em></p>
</blockquote>
<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-1008246186">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AOVBTRY2GZHH7DOZOJVJ5WDUVE3ZFANCNFSM5KYUVD5Q">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/AOVBTR6LPFTCAVPRDSYW3GDUVE3ZFA5CNFSM5KYUVD52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOHQMJ3KQ.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/c1008246186</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-1008246186",
"url": "https://github.com/strace/strace/pull/205#issuecomment-1008246186",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>