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 59052218AB9 for ; Sun, 8 Mar 2026 13:08:56 +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=1772975337; cv=none; b=jnNU4yqQ7IP0jW8rB2ndztTGkcr69JcvivmRY6zED5Zp5Ah+9UD61F3W4B5fwbaOH7zoKw+3wzCfmMmUMirIIsvBaeTE0f4zp7FQ7MhLsC+fUxvXAphgbcB1M9Y9JeArQAYSa6HjrQZhAq24LIFrySR9Xjs0pxqVeGS9wcMOJgY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772975337; c=relaxed/simple; bh=BgXzf9/DakieqP1vbKFJbeiTrM0BNzQVzd7gSPOSD0A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mnPjHvFws2FXE357MJrZcRg9S3oROKps1Ee8LeZUSiSu2kWcAV3aVfQFltTHzS1rvd5N+Qmu/u5qmDecg4UqpQ0hsBreXSsiphbOC8xzl1Kkii6yyGoCA/piecWp0Jf0UN57ILgYYCnFE3teJfr3o5NLfec7/4fP0rij58FjWD8= 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=IlAzAMcR; 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="IlAzAMcR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772975335; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i/Bsvt9jT0E4ZN9oplHUq+cX+ewJsum36FF0EKEPoDs=; b=IlAzAMcRHFZSeuyOprrjdladQvvBVjcoZ9Yqzo/r7sgmq5TtRlH7h7F3SJn7sdZyN8Hcr5 kWJN8VgmsOoFc55CbEJ0baRNa5hZn9H01BMprUBoLpfKVPGtNmCMQNz1hw8FeR85tqkx71 Spdtu5y1n6iJtWWO0ogHZInsdOIO1rg= Received: from mx-prod-mc-05.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-373-b78EP0AsPEm_FEBqcDVdBA-1; Sun, 08 Mar 2026 09:08:50 -0400 X-MC-Unique: b78EP0AsPEm_FEBqcDVdBA-1 X-Mimecast-MFC-AGG-ID: b78EP0AsPEm_FEBqcDVdBA_1772975329 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 62872195608E; Sun, 8 Mar 2026 13:08:49 +0000 (UTC) Received: from fedora (unknown [10.45.224.43]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 95AE330001BE; Sun, 8 Mar 2026 13:08:46 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sun, 8 Mar 2026 14:08:48 +0100 (CET) Date: Sun, 8 Mar 2026 14:08:45 +0100 From: Oleg Nesterov To: Max Ver , Andy Lutomirski , Kees Cook , Dmitry Levin Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Will Drewry Subject: Re: Process killed by seccomp looks live by tracer Message-ID: References: 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 On 03/06, Max Ver wrote: > > I suppose it's more reasonable for kernel to give a hint just after > the syscall killed by seccomp at the fourth loop. So that we can know > the syscall is rollbacked, or else we can only assume the syscall may > succeed. Perhaps you are right, but this is a question for seccomp experts... Kees, Andy, what do you think? Say, we can do something like --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -951,11 +951,20 @@ ptrace_get_syscall_info_seccomp(struct task_struct *child, struct pt_regs *regs, return offsetofend(struct ptrace_syscall_info, seccomp.ret_data); } +// currently not exposed +#define SECCOMP_MODE_DEAD (SECCOMP_MODE_FILTER + 1) + +static long xxx_get_error(struct task_struct *task, struct pt_regs *regs) +{ + return task->seccomp.mode == SECCOMP_MODE_DEAD + ? -EINTR : syscall_get_error(task, regs); +} + static unsigned long ptrace_get_syscall_info_exit(struct task_struct *child, struct pt_regs *regs, struct ptrace_syscall_info *info) { - info->exit.rval = syscall_get_error(child, regs); + info->exit.rval = xxx_get_error(child, regs); info->exit.is_error = !!info->exit.rval; if (!info->exit.is_error) info->exit.rval = syscall_get_return_value(child, regs); but probably this is not a good solution. Perhaps we can add a new "killed_by_seccomp" member into ptrace_syscall_info.exit ? Or even add a new ptrace_syscall_info.op = PTRACE_SYSCALL_INFO_KILLED_BY_SECCOMP ? Or change ptrace_report_syscall(PTRACE_EVENTMSG_SYSCALL_EXIT) to not report the event if the tracee was killed by force_sig_seccomp(force_coredump => true) ? Oleg. > > Oleg Nesterov 于2026年3月6日周五 01:46写道: > > > > That said... > > > > __seccomp_filter() does > > > > 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); > > > > This means that after syscall_rollback() regs->ax == orig_ax, so > > ptrace_get_syscall_info_exit() will always report .is_error == 0. > > > > And since force_sig_seccomp() uses force_coredump == true, SIGSYS > > won't be reported (see the SA_IMMUTABLE check in get_signal()). > > > > Again, it is not that I think this wrong. But perhaps Kees and Andy > > can take a look and confirm that this is what we actually want. > > > > Oleg.