From nobody Sat Feb 7 20:47:03 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 49E021E4A9 for ; Mon, 20 Jan 2025 13:45:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737380725; cv=none; b=UhL7qmwn2qgqaSgrlqLZfq76s9FPVMlOTxsi6qA5avkieEoOO7i9ckPXazj09qL2zASySjsc+cmbol1Iy3kYLVDRJrQoXk1mDvaqu5rIyfk4HFnHBw+LEmap2ncKJXh3CKgmBMhohcrgHkUvERaPi/G2ToFrG+X7+xKAqZtrGS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737380725; c=relaxed/simple; bh=WHif1f2CmE3SxIwCOjxfKNhPKp5wycfBkkl6qyNpyoc=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=IQz/CrrclWTmb+ainW3Y11nkciF+sg4q1Tnhe+KfkucqPQp7MoqDrBuRq2E2I6z6R52/9y304fdpxwkoTpHq9Qk4I4gGTiZXgromb/CTVerXhIQ85c621s+5bFdibtERS+xFqK4wvb7kSnjRmQgmUOnpdrfPVnBW10yeZRswOQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=OkhCmq9I; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="OkhCmq9I" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737380723; 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=Ga7QCRtOcrnYtWlk07C9MgkwegAMWWghsqDjUI+PWno=; b=OkhCmq9Iy4PWGdWG4fMQ/3p//+EGrX8+SbGvt5oYCwKxD3JyV6AdWth8C9vUy23ravnAMk MVztnc7gZ3p50Xl6iHypgnjCTDp/ThBUyHTJBsTPwWNUf5T+ddJxcwp2s3ndd6jepcl4bU FLFLE8xh2n4R3ITYyo3IzqCyhdSsVFs= Received: from mx-prod-mc-01.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-158-DhGEK2dkPqquqBt9d-3q1Q-1; Mon, 20 Jan 2025 08:45:19 -0500 X-MC-Unique: DhGEK2dkPqquqBt9d-3q1Q-1 X-Mimecast-MFC-AGG-ID: DhGEK2dkPqquqBt9d-3q1Q 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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 20C0B1955DDB; Mon, 20 Jan 2025 13:45:17 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.225.104]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id AF8B619560A3; Mon, 20 Jan 2025 13:45:11 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 20 Jan 2025 14:44:52 +0100 (CET) Date: Mon, 20 Jan 2025 14:44:45 +0100 From: Oleg Nesterov To: Kees Cook , Andy Lutomirski , Will Drewry , Thomas Bogendoerfer Cc: Madhavan Srinivasan , Michael Ellerman , Thomas Gleixner , Peter Zijlstra , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH 1/4] seccomp/mips: change syscall_trace_enter() to use secure_computing() Message-ID: <20250120134445.GA21268@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250120134409.GA21241@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" arch/mips/Kconfig selects HAVE_ARCH_SECCOMP_FILTER so syscall_trace_enter() can just use __secure_computing(NULL) and rely on populate_seccomp_data(sd) and "sd =3D=3D NULL" checks in __secure_computing(sd) paths. With the change above syscall_trace_enter() can just use secure_computing() and avoid #ifdef + test_thread_flag(TIF_SECCOMP). CONFIG_GENERIC_ENTRY is not defined, so test_syscall_work(SECCOMP) will check TIF_SECCOMP. Signed-off-by: Oleg Nesterov Acked-by: Thomas Bogendoerfer Reviewed-by: Kees Cook --- arch/mips/kernel/ptrace.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index 61503a36067e..f7107479c7fa 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c @@ -1326,24 +1326,8 @@ asmlinkage long syscall_trace_enter(struct pt_regs *= regs) return -1; } =20 -#ifdef CONFIG_SECCOMP - if (unlikely(test_thread_flag(TIF_SECCOMP))) { - int ret, i; - struct seccomp_data sd; - unsigned long args[6]; - - sd.nr =3D current_thread_info()->syscall; - sd.arch =3D syscall_get_arch(current); - syscall_get_arguments(current, regs, args); - for (i =3D 0; i < 6; i++) - sd.args[i] =3D args[i]; - sd.instruction_pointer =3D KSTK_EIP(current); - - ret =3D __secure_computing(&sd); - if (ret =3D=3D -1) - return ret; - } -#endif + if (secure_computing()) + return -1; =20 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) trace_sys_enter(regs, regs->regs[2]); --=20 2.25.1.362.g51ebf55 From nobody Sat Feb 7 20:47:03 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 4215D1E0E07 for ; Mon, 20 Jan 2025 13:45:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737380730; cv=none; b=Ch7pbktiFCJw7BUtXJ8qX5a3hDhgqvkaTu1F8AQxJuBoVjS77Sq1xkwgS6y2lWntPICC8oqDzHmlO1qKfpgGPj0lU+wTiAzD5j0MDMGvt/bTSvOb/tnrZGizWaDGZTemkgG4txlZbhmPmg16h8hv3GOeoI7A8biTWGu5fDtBxlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737380730; c=relaxed/simple; bh=XjFHIjesQ/Y9YCfSXrcZR/HEGaOC+Ql0rDoc48ACBmw=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=ekV/PC2W0gaZYHsY0uCX8rjKWYTeJtTaVbN7SirrqIRpk9l7HcKQPk/3z4fLMyI4LI+p4prwLZk2PTT8JLJTe6c8RsKLpPyI2aFHXQg6zoUw4OLwhSfgfqSKD6RQOMa5zyn+06lNXUkmbTW/d5VG9PIv0Oy9l/tlaUajaX6J7vA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=T2difETJ; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="T2difETJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737380727; 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=NuY4lntt+wpPMOwlY29nGQdQknJ504nvEIdtakSNjH8=; b=T2difETJyViEO7GM0Uc9vKWn5HRo20He8wcWEmrf9I00inPwopUN46iNl8fTge11wNVcHn FMX5HDQvUHgnMz+Y1Mq955Bfz18WcyfbMbTEkY1+6S1Blq0N5ioFvoBYS4kleeYmyr2nsc DdlPn1GrEXm6qLC6dABzs4lZOY4aw2M= 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-94-2ZKrlAgyONWB5VKEmnE0Sw-1; Mon, 20 Jan 2025 08:45:26 -0500 X-MC-Unique: 2ZKrlAgyONWB5VKEmnE0Sw-1 X-Mimecast-MFC-AGG-ID: 2ZKrlAgyONWB5VKEmnE0Sw 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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DA6541956062; Mon, 20 Jan 2025 13:45:23 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.225.104]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 4222619560A3; Mon, 20 Jan 2025 13:45:18 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 20 Jan 2025 14:44:58 +0100 (CET) Date: Mon, 20 Jan 2025 14:44:52 +0100 From: Oleg Nesterov To: Kees Cook , Andy Lutomirski , Will Drewry , Thomas Bogendoerfer Cc: Madhavan Srinivasan , Michael Ellerman , Thomas Gleixner , Peter Zijlstra , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH 2/4] seccomp: kill the dead code in the !CONFIG_HAVE_ARCH_SECCOMP_FILTER version of __secure_computing() Message-ID: <20250120134452.GA21275@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250120134409.GA21241@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Depending on CONFIG_HAVE_ARCH_SECCOMP_FILTER, __secure_computing(NULL) will crash or not, this is not consistent/safe. Fortunately, if CONFIG_HAVE_ARCH_SECCOMP_FILTER=3Dn, __secure_computing() has no callers, these architectures use secure_computing_strict(). Also, after the previous change __secure_computing(sd) is always called with sd =3D=3D NULL, so it is clear that we can remove the code which makes no sense. Signed-off-by: Oleg Nesterov --- include/linux/seccomp.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/include/linux/seccomp.h b/include/linux/seccomp.h index e45531455d3b..e01dfe57a884 100644 --- a/include/linux/seccomp.h +++ b/include/linux/seccomp.h @@ -32,11 +32,7 @@ static inline int secure_computing(void) } #else extern void secure_computing_strict(int this_syscall); -static inline int __secure_computing(const struct seccomp_data *sd) -{ - secure_computing_strict(sd->nr); - return 0; -} +static inline int __secure_computing(const struct seccomp_data *sd) { retu= rn 0; } #endif =20 extern long prctl_get_seccomp(void); --=20 2.25.1.362.g51ebf55 From nobody Sat Feb 7 20:47:03 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 57738BA20 for ; Mon, 20 Jan 2025 13:45:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737380741; cv=none; b=UD/L1H5oGgPGD+RnfeaiO/0yWpHIG2QlHGC82jo9N3LNYzIouoo9kGeaZpvJJZ1gxF53ht7w5WUYY0AJoTLEOn7qiM7gVoJqx7ri4XgshwPE7y4fv2NCaTgfSUV4ObO0FA3SrEEohQfZjck68SOSF6/kvkmaujbgzD07YTY7sgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737380741; c=relaxed/simple; bh=luvik0qgNsfhrH2+GLmny5dwNOsCSLTbf9dyK0pm8cA=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=sETzjBohDN1UC6OzIKu2MJHjlciESkzD6MmAExaiPNnxVR7c3JBbQGvKwMkebq7mb5IEo08bg8zmqiRFs7G7Se/ZyhBCOYQpm7zMvYeCStByj3muJwPaUQSzvgJnqIdsxcM0vaF73NeUWfafoHR7Q0fVl+rR+FswGop3Ccnnia0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=JxwYKYrV; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="JxwYKYrV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737380737; 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=4C//X0F2/vhqGqdyq38DMAz6+5GP64mgpWSnuLbKggM=; b=JxwYKYrVXNWvO0Sm2KRJSS7NfDU/FHsUlDVp+p3+bpfRgwAwWu6iksJ4yFTzMUZZJUPp7D 1ja8J1sylLiperSmD4JUcNbsaEz1O2o1XhFZ6WFBPnACKqsmYwn+SfiY1vZOPNfnai0L8M biKtVKvEOgGTChG3CiISs/zCdCzt444= Received: from mx-prod-mc-01.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-220-AFSzlNzjNsio8oNRgiUEaA-1; Mon, 20 Jan 2025 08:45:32 -0500 X-MC-Unique: AFSzlNzjNsio8oNRgiUEaA-1 X-Mimecast-MFC-AGG-ID: AFSzlNzjNsio8oNRgiUEaA 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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E571419560B8; Mon, 20 Jan 2025 13:45:29 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.225.104]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id AD5A23003E7F; Mon, 20 Jan 2025 13:45:25 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 20 Jan 2025 14:45:04 +0100 (CET) Date: Mon, 20 Jan 2025 14:44:59 +0100 From: Oleg Nesterov To: Kees Cook , Andy Lutomirski , Will Drewry , Thomas Bogendoerfer Cc: Madhavan Srinivasan , Michael Ellerman , Thomas Gleixner , Peter Zijlstra , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH 3/4] seccomp: remove the 'sd' argument from __secure_computing() Message-ID: <20250120134459.GA21284@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250120134409.GA21241@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" After the previous changes 'sd' is always NULL. Signed-off-by: Oleg Nesterov Reviewed-by: Kees Cook --- arch/powerpc/kernel/ptrace/ptrace.c | 2 +- include/linux/seccomp.h | 8 ++++---- kernel/entry/common.c | 2 +- kernel/seccomp.c | 7 +++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/kernel/ptrace/ptrace.c b/arch/powerpc/kernel/ptra= ce/ptrace.c index 727ed4a14545..c6997df63287 100644 --- a/arch/powerpc/kernel/ptrace/ptrace.c +++ b/arch/powerpc/kernel/ptrace/ptrace.c @@ -215,7 +215,7 @@ static int do_seccomp(struct pt_regs *regs) * have already loaded -ENOSYS into r3, or seccomp has put * something else in r3 (via SECCOMP_RET_ERRNO/TRACE). */ - if (__secure_computing(NULL)) + if (__secure_computing()) return -1; =20 /* diff --git a/include/linux/seccomp.h b/include/linux/seccomp.h index e01dfe57a884..6125baa96b76 100644 --- a/include/linux/seccomp.h +++ b/include/linux/seccomp.h @@ -23,16 +23,16 @@ #include =20 #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER -extern int __secure_computing(const struct seccomp_data *sd); +extern int __secure_computing(void); static inline int secure_computing(void) { if (unlikely(test_syscall_work(SECCOMP))) - return __secure_computing(NULL); + return __secure_computing(); return 0; } #else extern void secure_computing_strict(int this_syscall); -static inline int __secure_computing(const struct seccomp_data *sd) { retu= rn 0; } +static inline int __secure_computing(void) { return 0; } #endif =20 extern long prctl_get_seccomp(void); @@ -54,7 +54,7 @@ static inline int secure_computing(void) { return 0; } #else static inline void secure_computing_strict(int this_syscall) { return; } #endif -static inline int __secure_computing(const struct seccomp_data *sd) { retu= rn 0; } +static inline int __secure_computing(void) { return 0; } =20 static inline long prctl_get_seccomp(void) { diff --git a/kernel/entry/common.c b/kernel/entry/common.c index e33691d5adf7..20154572ede9 100644 --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -49,7 +49,7 @@ long syscall_trace_enter(struct pt_regs *regs, long sysca= ll, =20 /* Do seccomp after ptrace, to catch any tracer changes. */ if (work & SYSCALL_WORK_SECCOMP) { - ret =3D __secure_computing(NULL); + ret =3D __secure_computing(); if (ret =3D=3D -1L) return ret; } diff --git a/kernel/seccomp.c b/kernel/seccomp.c index 385d48293a5f..c29dfe82139e 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c @@ -1347,7 +1347,7 @@ static int __seccomp_filter(int this_syscall, const s= truct seccomp_data *sd, } #endif =20 -int __secure_computing(const struct seccomp_data *sd) +int __secure_computing(void) { int mode =3D current->seccomp.mode; int this_syscall; @@ -1356,15 +1356,14 @@ int __secure_computing(const struct seccomp_data *s= d) unlikely(current->ptrace & PT_SUSPEND_SECCOMP)) return 0; =20 - this_syscall =3D sd ? sd->nr : - syscall_get_nr(current, current_pt_regs()); + this_syscall =3D syscall_get_nr(current, current_pt_regs()); =20 switch (mode) { case SECCOMP_MODE_STRICT: __secure_computing_strict(this_syscall); /* may call do_exit */ return 0; case SECCOMP_MODE_FILTER: - return __seccomp_filter(this_syscall, sd, false); + return __seccomp_filter(this_syscall, NULL, false); /* Surviving SECCOMP_RET_KILL_* must be proactively impossible. */ case SECCOMP_MODE_DEAD: WARN_ON_ONCE(1); --=20 2.25.1.362.g51ebf55 From nobody Sat Feb 7 20:47:03 2026 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 24F091E22FB for ; Mon, 20 Jan 2025 13:45:43 +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=1737380747; cv=none; b=fnIAgvZGa0f0fceHQpkMS03z5BaU5IwuR7Ha2/sxnfnXwKDQJK8evAK+pN452YBAdCpNxxIZ/8qiXobuKVaVLMgYO6BPf7sVSM8v2M2GyNmhRC1j9jPcU2YEUx86GKYNgXg+c4XG8fcxPqe3rIEFi54cKV73l/VeZd8OOQ5a3b8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737380747; c=relaxed/simple; bh=m6lBuiJiZTJ5oH6fmhz8BBqdF09sFJ9n+qTcFvOk+mQ=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:In-Reply-To; b=hkDLJ3SqHynPo/PwYZ10X835A23yd2wjlpr9shQJD/2MNJNXGFYGge6Hdljd55jOY/RuVoLDvarNsaakIi7EL9TLh1jNKrYyUxeaqSIoHQqSj/eCLNa73vmSEqzM8xzVUO7bWcQ9PMiEUwHHnL5nFbiBCrzPeZ2w0MhoyCc+yuM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=Ah/ESxlb; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="Ah/ESxlb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737380743; 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=vfOTmMY2VnDeaFEXs43JEC9lE4+T6jIeb61gvtSteOc=; b=Ah/ESxlblZqzGEwwRPOifmrnD59Gmwt3bDstaG2vtiRoYVFQPiBwWl3PR9uX8X1Y+8n0An kZsyAF7s/O6k8onIJfvI5ipmwa8dOzXqGGqP+ux0AYglATnLtycrStDU9vmU/1lAoAMg6p HEPyP7v21F+rqk0uYtK3fzbx9kunyqE= 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-661-fqR8ZUFLPRugcQokSWegpg-1; Mon, 20 Jan 2025 08:45:38 -0500 X-MC-Unique: fqR8ZUFLPRugcQokSWegpg-1 X-Mimecast-MFC-AGG-ID: fqR8ZUFLPRugcQokSWegpg 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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 773751954196; Mon, 20 Jan 2025 13:45:36 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.225.104]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id EA41619560A3; Mon, 20 Jan 2025 13:45:31 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Mon, 20 Jan 2025 14:45:11 +0100 (CET) Date: Mon, 20 Jan 2025 14:45:05 +0100 From: Oleg Nesterov To: Kees Cook , Andy Lutomirski , Will Drewry , Thomas Bogendoerfer Cc: Madhavan Srinivasan , Michael Ellerman , Thomas Gleixner , Peter Zijlstra , linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH 4/4] seccomp: remove the 'sd' argument from __seccomp_filter() Message-ID: <20250120134505.GA21290@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250120134409.GA21241@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" After the previous change 'sd' is always NULL. Signed-off-by: Oleg Nesterov Reviewed-by: Kees Cook --- kernel/seccomp.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/kernel/seccomp.c b/kernel/seccomp.c index c29dfe82139e..75e293d3c1a1 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c @@ -1213,13 +1213,12 @@ static int seccomp_do_user_notification(int this_sy= scall, return -1; } =20 -static int __seccomp_filter(int this_syscall, const struct seccomp_data *s= d, - const bool recheck_after_trace) +static int __seccomp_filter(int this_syscall, const bool recheck_after_tra= ce) { u32 filter_ret, action; + struct seccomp_data sd; struct seccomp_filter *match =3D NULL; int data; - struct seccomp_data sd_local; =20 /* * Make sure that any changes to mode from another thread have @@ -1227,12 +1226,9 @@ static int __seccomp_filter(int this_syscall, const = struct seccomp_data *sd, */ smp_rmb(); =20 - if (!sd) { - populate_seccomp_data(&sd_local); - sd =3D &sd_local; - } + populate_seccomp_data(&sd); =20 - filter_ret =3D seccomp_run_filters(sd, &match); + filter_ret =3D seccomp_run_filters(&sd, &match); data =3D filter_ret & SECCOMP_RET_DATA; action =3D filter_ret & SECCOMP_RET_ACTION_FULL; =20 @@ -1290,13 +1286,13 @@ static int __seccomp_filter(int this_syscall, const= struct seccomp_data *sd, * a reload of all registers. This does not goto skip since * a skip would have already been reported. */ - if (__seccomp_filter(this_syscall, NULL, true)) + if (__seccomp_filter(this_syscall, true)) return -1; =20 return 0; =20 case SECCOMP_RET_USER_NOTIF: - if (seccomp_do_user_notification(this_syscall, match, sd)) + if (seccomp_do_user_notification(this_syscall, match, &sd)) goto skip; =20 return 0; @@ -1338,8 +1334,7 @@ static int __seccomp_filter(int this_syscall, const s= truct seccomp_data *sd, return -1; } #else -static int __seccomp_filter(int this_syscall, const struct seccomp_data *s= d, - const bool recheck_after_trace) +static int __seccomp_filter(int this_syscall, const bool recheck_after_tra= ce) { BUG(); =20 @@ -1363,7 +1358,7 @@ int __secure_computing(void) __secure_computing_strict(this_syscall); /* may call do_exit */ return 0; case SECCOMP_MODE_FILTER: - return __seccomp_filter(this_syscall, NULL, false); + return __seccomp_filter(this_syscall, false); /* Surviving SECCOMP_RET_KILL_* must be proactively impossible. */ case SECCOMP_MODE_DEAD: WARN_ON_ONCE(1); --=20 2.25.1.362.g51ebf55