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 8D6DF313E30 for ; Tue, 14 Apr 2026 16:48:30 +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=1776185311; cv=none; b=atyASS7WTUX9GZf/xT5jvbXb2stLaOhe1MZ3PCCDp9XAC/wAllB/h7N5WJR24xHB+R6YtJ/niVb/YDYHTIJXbOER/3lz2NOf9ZcaOl0lkB+UvgqbJ8daCYan/R/cyE2PWYdy8AiM27SmIJ0AZSHR8VAPD5a6uNHkfLNN2FDvW5A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776185311; c=relaxed/simple; bh=p8tf9brEw6sXzyN8rPTtq7oW1mfos8yma8dbTbRUqsA=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=RGcsO+fN+C0+1snDCVMC4o1JFYZgFCG2TkgRLNHS4q3ifgVYstwAwV7KjsiBzvMTwViSQE67IDiF8olhBKyg07V2mAAakd88HZPxwc0m+0KgjizTN3sK1OdOOeenEp3zKRWanoHiTLOr0B97CSQ7wVAMnfdQILxwuAY63GjFdrg= 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=fyIqprLt; 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="fyIqprLt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776185309; 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; bh=R9Oid93PnVrQy+LikjbR5Hy3F0zFMiTTmcgd9FAZbfo=; b=fyIqprLtAtH6N3Z3Dhvx7tUJ6g1LRQYRz9KzmnhGRqg8sdRavHgGEpC90ziEtR9ArJr3aw hQggzp+FBcc9D8OmuJ2/OogsJAT3uxYh1ncEfbWRjIbOgYmzfqSv6N5KUOSpO8kHgNginZ D6nalAJkYu7fX5RLACdGPeV0tvnKBJk= 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-25-4QmOzkR-MmKr82rzVltBwQ-1; Tue, 14 Apr 2026 12:48:23 -0400 X-MC-Unique: 4QmOzkR-MmKr82rzVltBwQ-1 X-Mimecast-MFC-AGG-ID: 4QmOzkR-MmKr82rzVltBwQ_1776185300 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 8F8481956095; Tue, 14 Apr 2026 16:48:19 +0000 (UTC) Received: from fedora (unknown [10.44.48.62]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 5D88B3000C1F; Tue, 14 Apr 2026 16:48:16 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 14 Apr 2026 18:48:19 +0200 (CEST) Date: Tue, 14 Apr 2026 18:48:14 +0200 From: Oleg Nesterov To: Andy Lutomirski , Kees Cook , Peter Zijlstra , Thomas Gleixner , Will Drewry Cc: Kusaram Devineni , Max Ver , linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/2] seccomp: introduce seccomp_nack_syscall() helper Message-ID: 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: X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 To factor out the code and simplify the next change Signed-off-by: Oleg Nesterov --- kernel/seccomp.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/kernel/seccomp.c b/kernel/seccomp.c index 066909393c38..cb8dd78791cd 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c @@ -1256,6 +1256,14 @@ static int seccomp_do_user_notification(int this_syscall, return -1; } +static void seccomp_nack_syscall(int this_syscall, int data, bool force_coredump) +{ + /* Show the handler or coredump the original registers. */ + syscall_rollback(current, current_pt_regs()); + /* Let the filter pass back 16 bits of data. */ + force_sig_seccomp(this_syscall, data, force_coredump); +} + static int __seccomp_filter(int this_syscall, const bool recheck_after_trace) { u32 filter_ret, action; @@ -1285,10 +1293,7 @@ static int __seccomp_filter(int this_syscall, const bool recheck_after_trace) goto skip; case SECCOMP_RET_TRAP: - /* Show the handler the original registers. */ - syscall_rollback(current, current_pt_regs()); - /* Let the filter pass back 16 bits of data. */ - force_sig_seccomp(this_syscall, data, false); + seccomp_nack_syscall(this_syscall, data, false); goto skip; case SECCOMP_RET_TRACE: @@ -1360,10 +1365,7 @@ static int __seccomp_filter(int this_syscall, const bool recheck_after_trace) /* Dump core only if this is the last remaining thread. */ if (action != SECCOMP_RET_KILL_THREAD || (atomic_read(¤t->signal->live) == 1)) { - /* 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); + seccomp_nack_syscall(this_syscall, data, true); } else { do_exit(SIGSYS); } -- 2.52.0