mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Dmitry V. Levin" <ldv@strace.io>
To: "Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Guo Ren <guoren@kernel.org>,
	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-csky@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 2/6] syscall.h: add syscall_set_arguments()
Date: Wed, 19 Feb 2025 20:48:52 +0200	[thread overview]
Message-ID: <20250219184852.GB14216@strace.io> (raw)
In-Reply-To: <alpine.DEB.2.21.2502191642590.65342@angie.orcam.me.uk>

On Wed, Feb 19, 2025 at 05:15:48PM +0000, Maciej W. Rozycki wrote:
> On Mon, 17 Feb 2025, Dmitry V. Levin wrote:
[...]
> > diff --git a/arch/csky/include/asm/syscall.h b/arch/csky/include/asm/syscall.h
> > index 0de5734950bf..30403f7a0487 100644
> > --- a/arch/csky/include/asm/syscall.h
> > +++ b/arch/csky/include/asm/syscall.h
> > @@ -59,6 +59,19 @@ syscall_get_arguments(struct task_struct *task, struct pt_regs *regs,
> >  	memcpy(args, &regs->a1, 5 * sizeof(args[0]));
> >  }
> >  
> > +static inline void
> > +syscall_set_arguments(struct task_struct *task, struct pt_regs *regs,
> > +		      const unsigned long *args)
> > +{
> > +	memcpy(&regs->a0, args, 6 * sizeof(regs->a0));
> > +	/*
> > +	 * Also copy the first argument into orig_x0
>                                                   ^
>  Typo here, s/orig_x0/orig_a0/; see below.
> 
> > +	 * so that syscall_get_arguments() would return it
> > +	 * instead of the previous value.
> > +	 */
> > +	regs->orig_a0 = regs->a0;

Indeed, thanks for spotting this.

>  Also:
> 
> > diff --git a/arch/mips/include/asm/syscall.h b/arch/mips/include/asm/syscall.h
> > index 056aa1b713e2..ea050b23d428 100644
> > --- a/arch/mips/include/asm/syscall.h
> > +++ b/arch/mips/include/asm/syscall.h
> > @@ -120,6 +137,21 @@ static inline void syscall_get_arguments(struct task_struct *task,
> >  		mips_get_syscall_arg(args++, task, regs, i++);
> >  }
> >  
> > +static inline void syscall_set_arguments(struct task_struct *task,
> > +					 struct pt_regs *regs,
> > +					 unsigned long *args)
> > +{
> > +	unsigned int i = 0;
> > +	unsigned int n = 6;
> > +
> > +	/* O32 ABI syscall() */
> > +	if (mips_syscall_is_indirect(task, regs))
> > +		i++;
> 
> -- given MIPS syscall_set_nr() implementation in 3/6 this conditional is 
> supposed to never be true.  Should it be BUG_ON() or discarded entirely?

I agree it should be discarded: given that the syscall number read from
regs[2] after syscall_trace_enter() invocation is not treated in any
special way with regards to __NR_syscall, it would be incorrect to do
it here either.  In fact, user space is allowed to set regs[2] to
__NR_syscall, even though it's pointless, but it's definitely not a
BUG_ON() situation.

I'll remove this check, thanks for the review!


-- 
ldv

  reply	other threads:[~2025-02-19 18:48 UTC|newest]

Thread overview: 15+ 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: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-19 17:15   ` Maciej W. Rozycki
2025-02-19 18:48     ` Dmitry V. Levin [this message]
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-19 17:16   ` Maciej W. Rozycki
2025-02-19 18:24     ` Dmitry V. Levin
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=20250219184852.GB14216@strace.io \
    --to=ldv@strace.io \
    --cc=akpm@linux-foundation.org \
    --cc=evgsyr@gmail.com \
    --cc=guoren@kernel.org \
    --cc=legion@kernel.org \
    --cc=linux-csky@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®