[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87jzajjde1.fsf@mpe.ellerman.id.au>
Date: Sat, 25 Jan 2025 23:17:58 +1100
From: Michael Ellerman <mpe@...erman.id.au>
To: "Dmitry V. Levin" <ldv@...ace.io>, Christophe Leroy
<christophe.leroy@...roup.eu>
Cc: Alexey Gladkov <legion@...nel.org>, Oleg Nesterov <oleg@...hat.com>,
Eugene Syromyatnikov <evgsyr@...il.com>, Mike Frysinger
<vapier@...too.org>, Renzo Davoli <renzo@...unibo.it>, Davide Berardi
<berardi.dav@...il.com>, strace-devel@...ts.strace.io, Madhavan Srinivasan
<maddy@...ux.ibm.com>, Nicholas Piggin <npiggin@...il.com>, Naveen N Rao
<naveen@...nel.org>, linuxppc-dev@...ts.ozlabs.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/7] powerpc: properly negate error in
syscall_set_return_value()
"Dmitry V. Levin" <ldv@...ace.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
Powered by blists - more mailing lists