From: "Dmitry V. Levin" <ldv@strace.io>
To: "Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
Andrew Morton <akpm@linux-foundation.org>,
Oleg Nesterov <oleg@redhat.com>,
Alexey Gladkov <legion@kernel.org>,
Eugene Syromyatnikov <evgsyr@gmail.com>,
strace-devel@lists.strace.io, linux-mips@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 3/6] syscall.h: introduce syscall_set_nr()
Date: Wed, 19 Feb 2025 20:24:52 +0200 [thread overview]
Message-ID: <20250219182451.GA14216@strace.io> (raw)
In-Reply-To: <alpine.DEB.2.21.2502191658530.65342@angie.orcam.me.uk>
On Wed, Feb 19, 2025 at 05:16:05PM +0000, Maciej W. Rozycki wrote:
> On Mon, 17 Feb 2025, Dmitry V. Levin wrote:
>
> > diff --git a/arch/mips/include/asm/syscall.h b/arch/mips/include/asm/syscall.h
> > index ea050b23d428..b956b015641c 100644
> > --- a/arch/mips/include/asm/syscall.h
> > +++ b/arch/mips/include/asm/syscall.h
> > @@ -41,6 +41,20 @@ static inline long syscall_get_nr(struct task_struct *task,
> > return task_thread_info(task)->syscall;
> > }
> >
> > +static inline void syscall_set_nr(struct task_struct *task,
> > + struct pt_regs *regs,
> > + int nr)
> > +{
> > + /*
> > + * New syscall number has to be assigned to regs[2] because
> > + * syscall_trace_entry() loads it from there unconditionally.
>
> That label is called `trace_a_syscall' in arch/mips/kernel/scall64-o32.S
> instead. To bring some order and avoid an inaccuracy here should the odd
> one be matched to the other three?
Apparently, there are two instances of syscall_trace_entry(), one
n32_syscall_trace_entry(), one trace_a_syscall(), and each of them
is calling syscall_trace_enter(), not to be confused with
syscall_trace_entry():
scall32-o32.S-syscall_trace_entry:
scall32-o32.S- SAVE_STATIC
scall32-o32.S- move a0, sp
scall32-o32.S-
scall32-o32.S: jal syscall_trace_enter
scall32-o32.S-
scall32-o32.S- bltz v0, 1f # seccomp failed? Skip syscall
scall32-o32.S-
scall32-o32.S- RESTORE_STATIC
scall32-o32.S- lw v0, PT_R2(sp) # Restore syscall (maybe modified)
--
scall64-n32.S-n32_syscall_trace_entry:
scall64-n32.S- SAVE_STATIC
scall64-n32.S- move a0, sp
scall64-n32.S: jal syscall_trace_enter
scall64-n32.S-
scall64-n32.S- bltz v0, 1f # seccomp failed? Skip syscall
scall64-n32.S-
scall64-n32.S- RESTORE_STATIC
scall64-n32.S- ld v0, PT_R2(sp) # Restore syscall (maybe modified)
--
scall64-n64.S-syscall_trace_entry:
scall64-n64.S- SAVE_STATIC
scall64-n64.S- move a0, sp
scall64-n64.S: jal syscall_trace_enter
scall64-n64.S-
scall64-n64.S- bltz v0, 1f # seccomp failed? Skip syscall
scall64-n64.S-
scall64-n64.S- RESTORE_STATIC
scall64-n64.S- ld v0, PT_R2(sp) # Restore syscall (maybe modified)
--
scall64-o32.S-trace_a_syscall:
scall64-o32.S- SAVE_STATIC
scall64-o32.S- sd a4, PT_R8(sp) # Save argument registers
scall64-o32.S- sd a5, PT_R9(sp)
scall64-o32.S- sd a6, PT_R10(sp)
scall64-o32.S- sd a7, PT_R11(sp) # For indirect syscalls
scall64-o32.S-
scall64-o32.S- move a0, sp
scall64-o32.S: jal syscall_trace_enter
scall64-o32.S-
scall64-o32.S- bltz v0, 1f # seccomp failed? Skip syscall
scall64-o32.S-
scall64-o32.S- RESTORE_STATIC
scall64-o32.S- ld v0, PT_R2(sp) # Restore syscall (maybe modified)
I'd change the wording of my comment rather than try to disentangle this.
After all, the most important here is that the new syscall number is
loaded from regs[2] right after the syscall_trace_enter() invocation.
Would you be OK with the following wording:
/*
* New syscall number has to be assigned to regs[2] because it is
* loaded from there unconditionally after syscall_trace_enter()
* invocation.
*
* Consequently, if the syscall was indirect and nr != __NR_syscall,
* then after this assignment the syscall will cease to be indirect.
*/
?
--
ldv
next prev parent reply other threads:[~2025-02-19 18:24 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-17 9:08 [PATCH v6 0/6] ptrace: introduce PTRACE_SET_SYSCALL_INFO API Dmitry V. Levin
2025-02-17 9:08 ` Dmitry V. Levin
2025-02-17 9:08 ` Dmitry V. Levin
2025-02-17 9:10 ` [PATCH v6 1/6] hexagon: add syscall_set_return_value() Dmitry V. Levin
2025-02-17 9:10 ` [PATCH v6 2/6] syscall.h: add syscall_set_arguments() Dmitry V. Levin
2025-02-17 9:10 ` Dmitry V. Levin
2025-02-17 9:10 ` Dmitry V. Levin
2025-02-19 17:15 ` Maciej W. Rozycki
2025-02-19 17:15 ` Maciej W. Rozycki
2025-02-19 17:15 ` Maciej W. Rozycki
2025-02-19 18:48 ` Dmitry V. Levin
2025-02-19 19:16 ` Maciej W. Rozycki
2025-02-17 9:10 ` [PATCH v6 3/6] syscall.h: introduce syscall_set_nr() Dmitry V. Levin
2025-02-17 9:10 ` Dmitry V. Levin
2025-02-17 9:10 ` Dmitry V. Levin
2025-02-19 17:16 ` Maciej W. Rozycki
2025-02-19 17:16 ` Maciej W. Rozycki
2025-02-19 17:16 ` Maciej W. Rozycki
2025-02-19 18:24 ` Dmitry V. Levin [this message]
2025-02-19 19:20 ` Maciej W. Rozycki
2025-02-19 19:30 ` Dmitry V. Levin
2025-02-20 23:19 ` Maciej W. Rozycki
2025-02-17 9:10 ` [PATCH v6 4/6] ptrace_get_syscall_info: factor out ptrace_get_syscall_info_op Dmitry V. Levin
2025-02-17 9:11 ` [PATCH v6 5/6] ptrace: introduce PTRACE_SET_SYSCALL_INFO request Dmitry V. Levin
2025-02-17 9:11 ` [PATCH v6 6/6] selftests/ptrace: add a test case for PTRACE_SET_SYSCALL_INFO Dmitry V. Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250219182451.GA14216@strace.io \
--to=ldv@strace.io \
--cc=akpm@linux-foundation.org \
--cc=evgsyr@gmail.com \
--cc=legion@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=macro@orcam.me.uk \
--cc=oleg@redhat.com \
--cc=strace-devel@lists.strace.io \
--cc=tsbogend@alpha.franken.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.