From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from vmicros1.altlinux.org (vmicros1.altlinux.org [194.107.17.57]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DF8D3D76 for ; Sat, 25 Jan 2025 20:48:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.107.17.57 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737838100; cv=none; b=hIhSie2b9lNglngk5dCzOtNTUE74tpqhizfp+rj58QLL+SEWqHiDBqYuUWWKylqUDRcHgaWY3tbW+Fs5DYduWy5CS6Gn9S2nB4E+IF1IgDtWjmA6rID+UIUfR+BPJGvnxla6OKSg2B3inQBULOcnRBErx9zXFE3h8yNSAONnkmk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737838100; c=relaxed/simple; bh=1dWeo7CnE/SgZAy2xF45RQQb3pKZLuCTJoeiOP4EU3A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=K27vsmAMmzoG/WId7MZ4hVHXjZb7AdFhqj8Kh3bFAGZ439Lvu70aQMXIAyuhZIjBzpTLba+QaZHcpQv4upc20nHR8Q50ElUYhHLbpqYcBJ1qzgN4W2Lqnn6BXjkiidnZ+uF4dDnVquozs2MEh6lddwYNbiVXoEi64JSTO+Xeb3o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strace.io; spf=pass smtp.mailfrom=altlinux.org; arc=none smtp.client-ip=194.107.17.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strace.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=altlinux.org Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id 61BEB72C8CC; Sat, 25 Jan 2025 23:48:15 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id 4EA297CCB3A; Sat, 25 Jan 2025 22:48:15 +0200 (IST) Date: Sat, 25 Jan 2025 22:48:15 +0200 From: "Dmitry V. Levin" To: Michael Ellerman Cc: Christophe Leroy , Alexey Gladkov , Oleg Nesterov , Eugene Syromyatnikov , Mike Frysinger , Renzo Davoli , Davide Berardi , strace-devel@lists.strace.io, Madhavan Srinivasan , Nicholas Piggin , Naveen N Rao , 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() Message-ID: <20250125204815.GA12624@strace.io> References: <20250113171054.GA589@strace.io> <6558110c-c2cb-4aa3-9472-b3496f71ebb8@csgroup.eu> <20250114170400.GB11820@strace.io> <20250123182815.GA20994@strace.io> <20250123234321.GA23582@strace.io> <87jzajjde1.fsf@mpe.ellerman.id.au> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87jzajjde1.fsf@mpe.ellerman.id.au> On Sat, Jan 25, 2025 at 11:17:58PM +1100, Michael Ellerman wrote: > "Dmitry V. Levin" 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. I agree, but shouldn't CCR.SO be cleared somehow after it was set earlier by syscall_set_return_value(current, regs, -ENOSYS, 0); ? -- ldv