From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9DD7363C79 for ; Sun, 22 Mar 2026 15:14:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774192455; cv=none; b=aIg92RsxV/MVbvXucCibiFYdulGzGsHmPysiQ++v8p6lpDB0vcpeSweqeL4mOTNzLKduOeo0r38BJ+uE4ryIM5JtU/slIrehRE4QJwMaXVFlgth3V/f/8SmoBET5tNStheVJVUDFSQZJZzrS0ppqIL/LSyAc8fXQ39aYsmgDBk4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774192455; c=relaxed/simple; bh=K9arxzeFwM/5CA+MSNllI+OdVZHkkN29HuBDxs5FZz4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pj30X59QnTy6pyW/7p2MYAZM6/K5ckvZC3mo8p9tXsoIGW7HBCyQDX8Mmefx5XJLUb1WYzT5CnElDqJ6tdRwL100HCw4Jk9TXLJ2ma3p5MHj1m7RUJ9oU/hg+d0bXUPXqROj+ray3jjoxmf3GLsXdK50ARPHQlemqq9m29kvG+U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=MZHs6XAp; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MZHs6XAp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1774192451; h=from:from:reply-to:subject:subject: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=CooqHa2GlrcpPwRj8D24KKzCVByNVpBIPaIGEbwzR3Q=; b=MZHs6XApNIey5uM/M68Dn0ryo38CyDK8Dc27siKcVxG8YSGdVl3z4ih9Hh7HT7C9Hcuk/R FvPTysonNA3+tvCJq1Cua5gkRRboAD3Q0K7BMRsNa5Vv22KC/YOna9ftOCHrWTHPAjWezU +i0RqUU+Fd6XBf9k3UvcCvd8c3hbx1k= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-685-zozbFoDuMCK-BFM1VXRX0w-1; Sun, 22 Mar 2026 11:14:08 -0400 X-MC-Unique: zozbFoDuMCK-BFM1VXRX0w-1 X-Mimecast-MFC-AGG-ID: zozbFoDuMCK-BFM1VXRX0w_1774192447 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AF458195604F; Sun, 22 Mar 2026 15:14:06 +0000 (UTC) Received: from fedora (unknown [10.44.32.25]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 20E5F1955D71; Sun, 22 Mar 2026 15:14:02 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sun, 22 Mar 2026 16:14:06 +0100 (CET) Date: Sun, 22 Mar 2026 16:14:01 +0100 From: Oleg Nesterov To: Kees Cook Cc: Andrew Morton , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Will Drewry , Max Ver , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] ptrace: don't report syscall-exit if the tracee was killed by seccomp Message-ID: References: <6E69C3F0-0691-4115-AE36-F5E5743C942A@kernel.org> 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: <6E69C3F0-0691-4115-AE36-F5E5743C942A@kernel.org> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 On 03/22, Kees Cook wrote: > > On March 22, 2026 6:44:54 AM PDT, Oleg Nesterov wrote: > >__seccomp_filter() does > > > > case SECCOMP_RET_KILL_THREAD: > > case SECCOMP_RET_KILL_PROCESS: > > ... > > /* Show the original registers in the dump. */ > > syscall_rollback(current, current_pt_regs()); > > > > /* Trigger a coredump with SIGSYS */ > > force_sig_seccomp(this_syscall, data, true); > > > >syscall_rollback() does regs->ax == orig_ax. This means that > >ptrace_get_syscall_info_exit() will see .is_error == 0. To the tracer, > >it looks as if the aborted syscall actually succeeded and returned its > >own syscall number. > > > >And since force_sig_seccomp() uses force_coredump == true, SIGSYS won't > >be reported (see the SA_IMMUTABLE check in get_signal()), so the tracee > >will "silently" exit with error_code == SIGSYS after the bogus report. > > > >Change syscall_exit_work() to avoid the bogus single-step/syscall-exit > >reports if the tracee is SECCOMP_MODE_DEAD. > > > >TODO: With or without this change, get_signal() -> ptrace_signal() may > >report other !SA_IMMUTABLE pending signals before it dequeues SIGSYS. > >Perhaps it makes sense to change get_signal() to check SECCOMP_MODE_DEAD > >too and prioritize the fatal SIGSYS. > > > >Reported-by: Max Ver > >Closes: https://lore.kernel.org/all/CABjJbFJO+p3jA1r0gjUZrCepQb1Fab3kqxYhc_PSfoqo21ypeQ@mail.gmail.com/ > >Signed-off-by: Oleg Nesterov > >--- > > include/linux/entry-common.h | 3 +++ > > include/linux/seccomp.h | 8 ++++++++ > > kernel/seccomp.c | 3 --- > > 3 files changed, 11 insertions(+), 3 deletions(-) > > > >diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h > >index f83ca0abf2cd..5c62bda9dcf9 100644 > >--- a/include/linux/entry-common.h > >+++ b/include/linux/entry-common.h > >@@ -250,6 +250,9 @@ static __always_inline void syscall_exit_work(struct pt_regs *regs, unsigned lon > > if (work & SYSCALL_WORK_SYSCALL_TRACEPOINT) > > trace_syscall_exit(regs, syscall_get_return_value(current, regs)); > > > >+ if (killed_by_seccomp(current)) > >+ return; > > Hmm. I'm still not convinced this is right, Me too actually ;) That is why RFC. So: - Do you agree that the current behaviour is not really "sane" and can confuse ptracers? - If yes, what else do you think we can do? No, I no longer think it makes sense to change the ptrace_get_syscall_info_exit() paths... > but if we make this change, I'd want to see a behavioral test added > (likely to the seccomp self tests), and to make sure the rr test suite doesn't regress. OK. I'll try to take a look at these tests and possibly add another one. But (sorry) not the next week, I will be travelling. Oleg.