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 7493125228D for ; Sun, 19 Apr 2026 15:53:31 +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=1776614012; cv=none; b=Rbx0AECCouqVtHn2AaSoudbhb9a2iplJtKCINanKblmhwOPI5n1De3AsTkhQkb6Ifg67tuKoEkZQY/ArrssFcosAf2hEMGNC+86KduR6VnrA5jYJBK01Br5s6WkKkqNILB5XZ4Cvhw472+caFPob3ts0p3jGCL76mdIUr0SX56I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776614012; c=relaxed/simple; bh=p8tf9brEw6sXzyN8rPTtq7oW1mfos8yma8dbTbRUqsA=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=e/kwHRUmO+6/hTxfhiED0pW0LZilamKj7b938H82/AXp3hp5d5U4TRxh0FZYhcOx12iwbNtCYnhr+eiThrhp1Hk0ZDM5iJbtdUfl88pvmp6P9JtQ2ReGJev0bhHqU+7+P4UsFIsjAvZLvFUxuQ3ReqRXG172YAIQGrJD77ffcWY= 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=hfPioTPX; 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="hfPioTPX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1776614010; 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=hfPioTPXV+vtHoGGVDayy9cpVDWhEsJwNaL44/Wboze6jueeQZbkklkp+MBbdO8AWDf1Uv IueUSGcD5IyM+E/L4j0Dknj911AhQqoWTOrA4UUW7J05xtpYcIWWNpd+qSHbXecjtvC6bH EAiHPniOdr6eTeNn81mRW+sRt2/k7I0= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-517-_7uab2HjN2GHIN3c1sXo8w-1; Sun, 19 Apr 2026 11:53:27 -0400 X-MC-Unique: _7uab2HjN2GHIN3c1sXo8w-1 X-Mimecast-MFC-AGG-ID: _7uab2HjN2GHIN3c1sXo8w_1776614005 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0A13F180036E; Sun, 19 Apr 2026 15:53:25 +0000 (UTC) Received: from fedora (unknown [10.44.32.56]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 06BB319560AB; Sun, 19 Apr 2026 15:53:20 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sun, 19 Apr 2026 17:53:24 +0200 (CEST) Date: Sun, 19 Apr 2026 17:53:19 +0200 From: Oleg Nesterov To: Andy Lutomirski , Kees Cook , Peter Zijlstra , Thomas Gleixner , Will Drewry Cc: Eric Paris , Kusaram Devineni , Max Ver , Paul Moore , audit@vger.kernel.org, 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.0 on 10.30.177.12 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