From: Michael Ellerman <mpe@ellerman.id.au>
To: "Dmitry V. Levin" <ldv@strace.io>,
Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Alexey Gladkov <legion@kernel.org>,
Oleg Nesterov <oleg@redhat.com>,
Eugene Syromyatnikov <evgsyr@gmail.com>,
Mike Frysinger <vapier@gentoo.org>,
Renzo Davoli <renzo@cs.unibo.it>,
Davide Berardi <berardi.dav@gmail.com>,
strace-devel@lists.strace.io,
Madhavan Srinivasan <maddy@linux.ibm.com>,
Nicholas Piggin <npiggin@gmail.com>,
Naveen N Rao <naveen@kernel.org>,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/7] powerpc: properly negate error in syscall_set_return_value()
Date: Sat, 25 Jan 2025 23:17:58 +1100 [thread overview]
Message-ID: <87jzajjde1.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <20250123234321.GA23582@strace.io>
"Dmitry V. Levin" <ldv@strace.io> writes:
> On Thu, Jan 23, 2025 at 08:28:15PM +0200, Dmitry V. Levin wrote:
...
>> After looking at system_call_exception() I doubt this inconsistency can be
>> easily avoided, so I don't see how this patch could be enhanced further,
>> and what else could I do with the patch besides dropping it and letting
>> !trap_is_scv case be unsupported by PTRACE_SET_SYSCALL_INFO API, which
>> would be unfortunate.
>
> If you say this would bring some consistency, I can extend the patch with
> something like this:
Yes that would improve things IMHO, with one caveat ....
> diff --git a/arch/powerpc/kernel/ptrace/ptrace.c b/arch/powerpc/kernel/ptrace/ptrace.c
> index 727ed4a14545..dda276a934fd 100644
> --- a/arch/powerpc/kernel/ptrace/ptrace.c
> +++ b/arch/powerpc/kernel/ptrace/ptrace.c
> @@ -207,7 +207,7 @@ static int do_seccomp(struct pt_regs *regs)
> * syscall parameter. This is different to the ptrace ABI where
> * both r3 and orig_gpr3 contain the first syscall parameter.
> */
> - regs->gpr[3] = -ENOSYS;
> + syscall_set_return_value(current, regs, -ENOSYS, 0);
>
> /*
> * We use the __ version here because we have already checked
> @@ -225,7 +225,7 @@ static int do_seccomp(struct pt_regs *regs)
> * modify the first syscall parameter (in orig_gpr3) and also
> * allow the syscall to proceed.
> */
> - regs->gpr[3] = regs->orig_gpr3;
> + syscall_set_return_value(current, regs, 0, regs->orig_gpr3);
This case should remain as-is. The orig_gpr3 value here is not a syscall
error code, it's the original r3 value, which is a syscall parameter.
If the tracer wants to fail the syscall it should have set something in
r3, not orig_gpr3.
> return 0;
> }
> @@ -315,7 +315,7 @@ long do_syscall_trace_enter(struct pt_regs *regs)
> * If we are aborting explicitly, or if the syscall number is
> * now invalid, set the return value to -ENOSYS.
> */
> - regs->gpr[3] = -ENOSYS;
> + syscall_set_return_value(current, regs, -ENOSYS, 0);
> return -1;
> }
>
> diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
> index aa17e62f3754..c921e0cb54b8 100644
> --- a/arch/powerpc/kernel/signal.c
> +++ b/arch/powerpc/kernel/signal.c
> @@ -229,14 +229,8 @@ static void check_syscall_restart(struct pt_regs *regs, struct k_sigaction *ka,
> regs_add_return_ip(regs, -4);
> regs->result = 0;
> } else {
> - if (trap_is_scv(regs)) {
> - regs->result = -EINTR;
> - regs->gpr[3] = -EINTR;
> - } else {
> - regs->result = -EINTR;
> - regs->gpr[3] = EINTR;
> - regs->ccr |= 0x10000000;
> - }
> + regs->result = -EINTR;
> + syscall_set_return_value(current, regs, -EINTR, 0);
> }
> }
cheers
next prev parent reply other threads:[~2025-01-25 12:18 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250113170925.GA392@strace.io>
2025-01-13 17:10 ` [PATCH v2 1/7] powerpc: properly negate error in syscall_set_return_value() Dmitry V. Levin
2025-01-13 17:34 ` Christophe Leroy
2025-01-13 17:54 ` Dmitry V. Levin
2025-01-14 17:04 ` Dmitry V. Levin
2025-01-20 13:51 ` Christophe Leroy
2025-01-20 17:12 ` Dmitry V. Levin
2025-01-21 11:13 ` Madhavan Srinivasan
2025-01-21 11:28 ` Christophe Leroy
2025-01-21 12:25 ` Madhavan Srinivasan
2025-01-21 12:42 ` Dmitry V. Levin
2025-01-23 18:28 ` Dmitry V. Levin
2025-01-23 19:11 ` Eugene Syromyatnikov
2025-01-23 22:16 ` Dmitry V. Levin
2025-01-23 22:07 ` Christophe Leroy
2025-01-23 22:35 ` Dmitry V. Levin
2025-01-27 11:20 ` Dmitry V. Levin
2025-01-27 11:36 ` Christophe Leroy
2025-01-27 11:44 ` Dmitry V. Levin
2025-01-27 12:04 ` Christophe Leroy
2025-01-27 12:26 ` Dmitry V. Levin
2025-01-23 23:43 ` Dmitry V. Levin
2025-01-24 15:18 ` Alexey Gladkov
2025-01-25 0:25 ` Dmitry V. Levin
2025-01-25 12:18 ` Michael Ellerman
2025-01-27 11:13 ` Dmitry V. Levin
2025-01-25 12:17 ` Michael Ellerman [this message]
2025-01-25 20:48 ` Dmitry V. Levin
2025-01-25 12:17 ` Michael Ellerman
2025-01-25 21:25 ` Dmitry V. Levin
2025-01-14 13:00 ` Alexey Gladkov
2025-01-14 13:48 ` Dmitry V. Levin
2025-01-14 14:53 ` Alexey Gladkov
2025-01-13 17:11 ` [PATCH v2 3/7] syscall.h: add syscall_set_arguments() and syscall_set_return_value() Dmitry V. Levin
2025-01-16 2:20 ` Charlie Jenkins
2025-01-17 0:59 ` H. Peter Anvin
2025-01-17 15:45 ` Eugene Syromyatnikov
2025-01-18 4:34 ` H. Peter Anvin
2025-01-13 17:11 ` [PATCH v2 4/7] syscall.h: introduce syscall_set_nr() Dmitry V. Levin
2025-01-16 2:20 ` Charlie Jenkins
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=87jzajjde1.fsf@mpe.ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=berardi.dav@gmail.com \
--cc=christophe.leroy@csgroup.eu \
--cc=evgsyr@gmail.com \
--cc=ldv@strace.io \
--cc=legion@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=naveen@kernel.org \
--cc=npiggin@gmail.com \
--cc=oleg@redhat.com \
--cc=renzo@cs.unibo.it \
--cc=strace-devel@lists.strace.io \
--cc=vapier@gentoo.org \
/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;
as well as URLs for NNTP newsgroup(s).