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 C337A204688 for ; Sat, 25 Jan 2025 21:25:15 +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=1737840319; cv=none; b=OB1MGSrpp734hUnztBYzsD9o6JcB5NoAqGMGzWjgggUniUYVaCaHykH2EEja0k+ZQ7sIczJwzaaHF1fVpZFfYvWZcYm6pyf7aRCq/c/5KnBaAFV5rHKDbMy653u7xDdNhVOXjcxWYWCI75EwHXbmh5pxw+D0S+tTZ62+Rwd+Dow= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737840319; c=relaxed/simple; bh=pIzaV1WRZzZFS7Gmb5JVNGgWw4Q7Jsld9rG4bVYYi4o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=E3zu3DQ0xJTuKiRl9lyw6CEueJBc4dr8atXyq1uoT8I6mdFz50YhPygpEo4N91NEHYWbDGois7wFVVl+TIKOPrjlyI1i49+72weOW3ZIIWLIP+Xmtohydm5Zm7wT7NLPfbKEPBCyxWh6ef/6vIghpgxALKBURtXe6F1NwD2wsh4= 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 DB0A772C8CC; Sun, 26 Jan 2025 00:25:13 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id CFE447CCB3A; Sat, 25 Jan 2025 23:25:13 +0200 (IST) Date: Sat, 25 Jan 2025 23:25:13 +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: <20250125212513.GB12624@strace.io> References: <20250113171054.GA589@strace.io> <6558110c-c2cb-4aa3-9472-b3496f71ebb8@csgroup.eu> <20250114170400.GB11820@strace.io> <20250123182815.GA20994@strace.io> <87lduzjdee.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: <87lduzjdee.fsf@mpe.ellerman.id.au> On Sat, Jan 25, 2025 at 11:17:45PM +1100, Michael Ellerman wrote: > "Dmitry V. Levin" writes: [...] > > The only case where I see some intersection is do_seccomp() where the > > tracer would be able to see -ENOSYS in gpr[3]. However, the seccomp stop > > is not the place where the tracer *reads* the system call exit status, > > so whatever was written in gpr[3] before __secure_computing() is not > > really relevant, consequently, selftests/seccomp/seccomp_bpf passes with > > this patch applied as well as without it. > > IIRC it is important for a tracer that blocks the syscall but doesn't > explicitly set the return value. But it's only important that the > default return value is syscall failure (ie. ENOSYS/-ENOSYS), the actual > sign of the r3 value should be irrelevant to the tracer. > > If the selftest still passes then that's probably sufficient. Yes, I failed to explain this properly, thanks for correcting me. With the current implementation, both -ENOSYS and ENOSYS/cr0.SO semantics of the error code at __secure_computing() stage lead to the same result, this is the reason why seccomp_bpf selftest passes regardless of the patch. At any point where the tracer is entitled to interpret gpr[3] as a syscall return value, the semantics of gpr[3] is well-defined (-ERRORCODE/cr0.SO in non-scv case) and is a part of the ABI. However, since we have to provide backwards compatibility with the current inconsistent implementation, in the non-scv case we have to continue supporting both -ENOSYS and ENOSYS/cr0.SO semantics of the syscall return value set by the tracer at __secure_computing() stage. -- ldv