Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A44873C555C for ; Fri, 10 Jul 2026 15:38:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783697917; cv=none; b=lO8xKIEeRQWtnA/XLiyUt62861qs1h8dhv66dTbaIt7d1eqXx9FlrZkMULAIL8I/qCcMXJmicCG+cNFIy/ho0AnBW0Ual6srXAQwngL2cG2cjjZVATvK0uNHEJZFbUoJr4YgqngDoFH2AR/MSPALyuMDgRwYAH+uhfuTMlvYdAg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783697917; c=relaxed/simple; bh=WI/SJt1rp32lP7uzoQc1SGLKpFmr20PJGgMzeuOekPA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mf2ZEPKis+9tYUJNh96kMPnC+Lav4OZ1FYNToqLcA2g/XBXkcr/RmGsy6F+quKAXwdxSmTIOLicUR09dmh/KmgrrzV1x5+x/19DPajToaE/oKo2/5LkDvxz+IFjBp+Pi5KwzMTbBZtnkel5ZNWADijTD7Y9p3XN5nEXsGvH40gc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=JdGY0ApM; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=8S2jlTpc; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=JdGY0ApM; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=8S2jlTpc; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="JdGY0ApM"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="8S2jlTpc"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="JdGY0ApM"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="8S2jlTpc" Received: from kunlun.suse.cz (unknown [IPv6:2a07:de40:b306:2000::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 368C17680B; Fri, 10 Jul 2026 15:38:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1783697913; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pGG1gZ/hFugLP31pJo3lj0lh/RoHCYllxQkpzT/su6Q=; b=JdGY0ApMwMiQ5je0a17g62QspIPQ98dNzLG4nTC4WNRRcPPY6y/gU1ITkUGmH9qB6cXOoZ shBKiilCKemRCRZFZ4yL921HMpr1AJSmMoS8f4q+UhR0vvkedzeAnIafVlyAWsV8B7+qOH qDmMsGN6vffwzCXFER3Sxk2c4ckVNoE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1783697913; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pGG1gZ/hFugLP31pJo3lj0lh/RoHCYllxQkpzT/su6Q=; b=8S2jlTpcCsw4M/+MNKDsTA+eLurQWQcVpAHaA40A+HSklAKhyn85XlXfnHiaSlg/LIuIE7 mgV889nhnAVptxCw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=JdGY0ApM; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=8S2jlTpc DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1783697913; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pGG1gZ/hFugLP31pJo3lj0lh/RoHCYllxQkpzT/su6Q=; b=JdGY0ApMwMiQ5je0a17g62QspIPQ98dNzLG4nTC4WNRRcPPY6y/gU1ITkUGmH9qB6cXOoZ shBKiilCKemRCRZFZ4yL921HMpr1AJSmMoS8f4q+UhR0vvkedzeAnIafVlyAWsV8B7+qOH qDmMsGN6vffwzCXFER3Sxk2c4ckVNoE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1783697913; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pGG1gZ/hFugLP31pJo3lj0lh/RoHCYllxQkpzT/su6Q=; b=8S2jlTpcCsw4M/+MNKDsTA+eLurQWQcVpAHaA40A+HSklAKhyn85XlXfnHiaSlg/LIuIE7 mgV889nhnAVptxCw== Date: Fri, 10 Jul 2026 17:38:32 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= 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, "Dmitry V . Levin" Subject: Re: [PATCH v5 0/2] PTRACE_SET_SYSCALL_INFO: add support for seccomp syscall skipping Message-ID: References: <20260709100949.94345-1-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: <20260709100949.94345-1-renzo@cs.unibo.it> X-Spam-Flag: YES X-Rspamd-Action: add header X-Spam-Level: ************* X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [13.68 / 50.00]; SPAM_FLAG(5.00)[]; NEURAL_SPAM_LONG(3.50)[1.000]; BAYES_HAM(-3.00)[100.00%]; HFILTER_HOSTNAME_UNKNOWN(2.50)[]; RDNS_NONE(2.00)[]; SUSPICIOUS_RECIPS(1.50)[]; ONCE_RECEIVED(1.20)[]; HFILTER_HELO_IP_A(1.00)[kunlun.suse.cz]; HFILTER_HELO_NORES_A_OR_MX(0.30)[kunlun.suse.cz]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_SHORT(-0.01)[-0.070]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b306:2000::2:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; FREEMAIL_CC(0.00)[vger.kernel.org,linux-foundation.org,redhat.com,kernel.org,gmail.com,lists.strace.io,strace.io]; RCPT_COUNT_SEVEN(0.00)[10]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; MISSING_XM_UA(0.00)[]; TAGGED_RCPT(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[kunlun.suse.cz:helo,kunlun.suse.cz:mid,sashiko.dev:url,suse.de:dkim] X-Spamd-Bar: +++++++++++++ X-Rspamd-Queue-Id: 368C17680B X-Spam-Score: 13.68 X-Spam: Yes On Thu, Jul 09, 2026 at 12:09:47PM +0200, Renzo Davoli wrote: > PTRACE_SET_SYSCALL_INFO is a generic ptrace API that complements > PTRACE_GET_SYSCALL_INFO by allowing a tracer to modify details of a > system call in which the tracee is currently blocked. > > The API is designed to let tracers inspect and modify system call > information in a simple, architecture-agnostic manner. > > The current implementation only supports modifying the subset of > system call information needed by strace: the system call number, > arguments, and return value. > > This patch set extends PTRACE_SET_SYSCALL_INFO with support for > skipping a system call. > > When a seccomp filter returns SECCOMP_RET_TRACE, the tracer receives, > via PTRACE_GET_SYSCALL_INFO, a struct ptrace_syscall_info with > op == PTRACE_SYSCALL_INFO_SECCOMP. > > The tracer can skip the system call by setting the system call number > to -1. However, the current PTRACE_SET_SYSCALL_INFO interface does not > provide a way to specify the return value or error code that should be > reported to the tracee after skipping the call. Hello, this will not work at least on powerpc, and possibly s390x. On these architectures the syscall number and the syscall return value share the same register. seccomp can skip a syscall by returning -1 from __secure_computing() which is then interpreted by the caller as a reason to skip further syscall processing, in particular interpretinfg the return value set in the registers as the syscall number. However, the tracing hook in seccomp does not return anything, in particular it does not change the return value of __secure_computing(). /* Allow the BPF to provide the event message */ ptrace_event(PTRACE_EVENT_SECCOMP, data); If the skip was propagated all the way to here so that the __secure_computing() could indicate to skip the signal it would work. Other ways to rework the setting of the return value are possible. eg. it was suggested to add a special field to pt_regs to hold the syscall return value, and only copy it to the register at syscall exit. Thanks Michal > > This patchset extends PTRACE_SET_SYSCALL_INFO to support skipping a system call > triggered via seccomp. > > When a tracer retrieves a ptrace_syscall_info structure with 'op' set to > PTRACE_SYSCALL_INFO_SECCOMP, it can now choose to skip the system call. To do > this, the tracer changes 'op' to PTRACE_SYSCALL_INFO_EXIT and populates the > exit union fields (rval and is_error) to define the return value and error > status for the tracee. > > System call suppression via PTRACE_SYSCALL_INFO_ENTRY is currently not > implemented. On some architectures (e.g. MIPS), when a system call is > skipped by setting the syscall number to -1 at the entry stop, the > architecture entry path unconditionally overwrites the return value > register with -ENOSYS, clobbering any custom return value set by the > tracer at the entry stop. > > This patchset is a new version of the proposed patchset entitled: > ptrace_set_syscall_info: add support for seccomp syscall skipping and > instruction pointer modification > The patchset has been split in two: > syscall skipping(this) > instruction pointer modification (it will be updated soon) > > Changes in v5: > * reworded the explanation for not supporting PTRACE_SYSCALL_INFO_ENTRY yet. > * selftests/ptrace: removed a redundant check. > > Changes in v4: > * Reworded the commit messages for clarity. > * Renamed the local variable child_op to op in ptrace_set_syscall_info() > * Clean up and improve the coding style of selftests/ptrace/set_syscall_info.c > (suggested by Dmitry V. Levin) > > Changes in v3: > * restrict the syscall skipping feature to PTRACE_SYSCALL_INFO_SECCOMP > > Changes in v2: > bugfix: _NONE -> _EXIT transition was erroneously permitted > > Changes since the previous patchset v2: > * bugfix: skip_syscall init value > * fix comments > > Changes in (previous patchset) v2: > * use PTRACE_SYSCALL_INFO_EXIT instead of a new tag > * fixed most of the comments from sashiko.dev > > Renzo Davoli (2): > ptrace: add PTRACE_SET_SYSCALL_INFO syscall skipping support > selftests/ptrace: add a test case for PTRACE_SET_SYSCALL_INFO syscall > skipping > > kernel/ptrace.c | 27 ++- > .../selftests/ptrace/set_syscall_info.c | 172 +++++++++++++++++- > 2 files changed, 193 insertions(+), 6 deletions(-) > > -- > 2.53.0 >