Re: [PATCH v2 6/7] ptrace: introduce PTRACE_SET_SYSCALL_INFO request

Dmitry V. Levin
2025-01-15T17:36:44Z

On Wed, Jan 15, 2025 at 05:38:09PM +0100, Oleg Nesterov wrote:
[...]
> > + syscall_set_nr(child, regs, nr);
> > + /*
> > + * If the syscall number is set to -1, setting syscall arguments is not
> > + * just pointless, it would also clobber the syscall return value on
> > + * those architectures that share the same register both for the first
> > + * argument of syscall and its return value.
> > + */
> > + if (nr != -1)
> > + syscall_set_arguments(child, regs, args);
>
> Thanks, much better than I tried to suggest in my reply to V1.
>
> But may be
>
> if (syscall_get_nr() != -1)
> syscall_set_arguments(...);
>
> will look a bit more consistent?

I'm sorry, but I didn't follow. As we've just set the syscall number with
syscall_set_nr(), why would we want to call syscall_get_nr() right after
that to obtain the syscall number?

--
ldv