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 2055725B0A2 for ; Mon, 6 Jul 2026 16:03:28 +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=1783353811; cv=none; b=iVr3pMw8wC9bNrerqNgdqaQunQAiX/wg/UlNjYPI8BbMoRlKYXD6HZ9HT+ozQNjeTb5Q0Jp8xaEo2B02h2Shn7Wq/Fjsox6rzjNMh3eQ9vNlENuZAUvY5ZAOTynIeEo1J2hVzR+x+QV5v3lZl/cYddKT2O+qXLooBftbLqb01LI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783353811; c=relaxed/simple; bh=+LxdgCWJ2TuqX665PIx4Mk0tyz4XTIjHi2C7V/Fm28E=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CMh7+7A0rBg8vHmLJSDmxPIV8DUP+3jUH0/L6FfwKGQ4/JX8Ga5a4AuhfSaWlEBAGdPiwyj+XDkFuTupU5Q6a1pHRhJ8euKSaIT+y9is07gDGNJwqMBVv117gEiILJpjm0NgZbj7kMhKA61IfUGXSFGA2tzLqYO0etaihSnKhZo= 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 E8F6E72C8CC; Mon, 6 Jul 2026 19:03:27 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id DB60B7CCB3A; Mon, 6 Jul 2026 19:03:27 +0300 (IDT) Date: Mon, 6 Jul 2026 19:03:27 +0300 From: "Dmitry V. Levin" To: Renzo Davoli Cc: linux-kernel@vger.kernel.org, Andrew Morton , Oleg Nesterov , Shuah Khan , Alexey Gladkov , Eugene Syromyatnikov , Davide Berardi , strace-devel@lists.strace.io Subject: Re: [PATCH v2 1/2] ptrace: PTRACE_SET_SYSCALL_INFO syscall skipping support Message-ID: <20260706160327.GB5029@strace.io> References: <20260704142643.692754-1-renzo@cs.unibo.it> <20260704142643.692754-2-renzo@cs.unibo.it> 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: On Sun, Jul 05, 2026 at 08:41:07AM +0200, Renzo Davoli wrote: [...] > Moreover, kernel/ptrace.c contains the following comment: > /* > * 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. > */ I wrote this comment to warn explicitly against invoking syscall_set_arguments() after syscall_set_nr(-1). Doing so is unsafe on several architectures, as setting the first syscall argument will clobber the syscall return value on those platforms. [...] > By contrast, for PTRACE_SYSCALL syscall-entry stops, the man page only states > that the tracer may modify the system call number. It does not specify that > assigning a negative value must suppress the system call and preserve the > return value across all architectures, even though many architectures implement > exactly this behavior. While setting the system call number to an invalid value during a syscall-entry stop indeed suppresses the system call on all architectures, the return value semantics are complicated. The return value is normally set to -ENOSYS, but there are architectures (parisc between commits v4.6-rc2~20^2 and v5.0-rc8~9^2~1, and riscv since commit v6.5-rc7~13^2~5) where -ENOSYS isn't set. Furthermore, setting the return value along with the system call number during a syscall-entry stop is not guaranteed to be honored on all architectures, with MIPS being a notable example. The man page could definitely be improved in this respect. -- ldv