From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8939D3CBE7A for ; Wed, 15 Jul 2026 21:20:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784150443; cv=none; b=QHZGQA7t5EOO4xWPjM8H8iNR1A17Ld2eekPyKRCNiD7GvukF5BY9FzrG5wHMwEOwUobFtxMsZWYYI/oiauh1LhHDbjHB5M37H5HKU90U/XDEXuTFKSjl2TAbkqZcCSzyR9Y1j9ChnJ1UHRetO8IFBu8PxLKKobf6QTH0vV+6Eds= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784150443; c=relaxed/simple; bh=l8LrloIzOK32CMuzElY05harW0usRO0LsWxE3MqYBd0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=flmeVUdYKGXLzIYHYYKu0n9KVHkOOW9/epK+Zxijn2vyf7Mb6YjJ6kc1DzpaQdsgrqIdDTzb75gO89H6CshTkL+boypsHbQ1GXHRvPQrCCDD8uGzqNBA/v3aeeFt45XEicCsAR3cfw4Qv6G6AMA6vcLz7PzoP+LTSX12/iVONbU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DPl27hTY; arc=none smtp.client-ip=209.85.215.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DPl27hTY" Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-c9d1fc053e0so2278858a12.1 for ; Wed, 15 Jul 2026 14:20:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784150441; x=1784755241; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=6q5nQLizQGV2XlL8vTWKU8w6FEVGfMIRL5kdTFKa2t4=; b=DPl27hTYmYtm24sGdsmyTrlUeGP9g2Xj6bDVkaQILbJsvjSVxz3kAsJZmtd8l7wqPw uMQBOnjH5gkqFIUVwuYB/VJTRjet/+E41eex86SVkH6v2a82L9/4KdPBw2XVgBQXVWkb x6HjZBCNtGe+vcfh+iG5UdjwincZeY6gLbc3l1nHBeRmencNZFp8yKPQRGeS7VNC4gAP JVbSxPvisQnRerOzpmZwpVst4OihkU0+xMCmeslDIXr1F3gxoRKd55z8R7ihuz/3Dqbq gfptQOr2zjp44L9xjojeH1wZbEq3ssn9aG5OFcXcwnzhpSpoFpywLttur0+zZe5LT1LA n7Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784150441; x=1784755241; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=6q5nQLizQGV2XlL8vTWKU8w6FEVGfMIRL5kdTFKa2t4=; b=LXlEkuZULU1M9ZDMLy3ijwJbneUVMBY3cwzqz6s9FauaCWxAoNvZykPqh2js9nJtbn xwSxSSA7QGhbNhTFaquIscmQpeUgCwSwzYAmXz1ecbXXUvrQQwqhpabiKAQZ15u9tACz HOJepyY0JlH/ISsP4o9guGJGTePLoEIoL6it1IUlko2bbU6YSLOAns2JYipEXnZA5+Sp w2KiM6Lg9z7QX+NCVp4tLcWU6ntfGGFsB9+dRT/Re1D7z1O5x94RkiB9s4TUIfm5+RjM NZ3WVU11xu7zVrLrxLl4hEa6CJrjUF9AZHExGJOuE1NhciCURL6IgQUaohYMjOa5VI3z uhKA== X-Forwarded-Encrypted: i=1; AHgh+RotQXrKYjChK5r4YIjv1aGGuC5ABPUTZVqQ9YcWWbTQW49pWT362PZK187jF86vDQvxrIC1yL/arKxRp8M=@vger.kernel.org X-Gm-Message-State: AOJu0YzVDR1NDmJGlkKL1njYAKmN7bn5CXbAPEwskr9RQeBczZKNs8ja wTQEYjGRvBBpCVsqAQVNyC4iLabCZtne3jv7IrSRsf0b08hwq+NqMLi/82BWMA== X-Gm-Gg: AfdE7clMxfk4BchwudqgOxiG5ROlum5bbt2ECIS1xqWXwCluv9WYEZBcwy3NIHoGlBT +R1NNoqhsavPJF3HrzByUaF1FcQDqURKfO/iVz2a+K8DEKoR4fOShGP9zpiPLJR1wlU5iRW0Ljh tHOUHU5O4mRGB1xPoj1H80vd+KT6UyuCWca2IWncBPh9dJf3AuCcqQ/M3OyTCVBITyNP4k9F+P5 ezAN2BRMPlR/6tqvOkz6GseSa0fa0Q4+uSC/DMrDRU3DmGV8blxvmucajek4qwH+fieBbluWVpp jiw4Taz02FaRVM0oKflh0Q4o2blA2FcLeD+WPo2bMJ7r4sK/rylkxpCpozWA6hybQtWOrtIT3or YAxDrlPcPwhLomH3V25gSDTyXmlFe7dm2lv2FzzNtjdYpxHYY7AanM14lr//2fk80QHsMh8WU2r HIUrqrTAE0FiUqgb+sBnnUGL3CfEYS7Lq188UHhQdy0XIZMKeWFiKDc9LEnA== X-Received: by 2002:a05:6a20:6a0d:b0:3b3:1c7b:ff0 with SMTP id adf61e73a8af0-3c1102af7a0mr21283514637.32.1784150440801; Wed, 15 Jul 2026 14:20:40 -0700 (PDT) Received: from pop-os.tail4adac7.ts.net ([129.210.115.107]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13cd403a7f7sm4126844c88.0.2026.07.15.14.20.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 14:20:39 -0700 (PDT) From: Cong Wang To: Andy Lutomirski Cc: Kees Cook , linux-kernel@vger.kernel.org, Will Drewry , Christian Brauner , Andrew Morton , linux-mm@kvack.org, Cong Wang Subject: [PATCH v6 4/8] seccomp: add __NR_seccomp_* aliases for rt_sigreturn and clone/fork Date: Wed, 15 Jul 2026 14:20:03 -0700 Message-ID: <20260715212007.2382846-5-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260715212007.2382846-1-xiyou.wangcong@gmail.com> References: <20260715212007.2382846-1-xiyou.wangcong@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Cong Wang The existing __NR_seccomp_* aliases name only the strict-mode syscalls (read/write/exit/sigreturn). SEND_REDIRECT must also recognise rt_sigreturn and the clone/fork task-creation family, native and compat, so it can refuse to redirect them. Gate these behind a new SECCOMP_ARCH_REDIRECT opt-in, mirroring how SECCOMP_ARCH_NATIVE gates the bitmap cache: an arch declares it only once it supplies a complete, verified set of these numbers, and where it is undefined the feature is compiled out. This avoids a generic fallback silently handing an arch a wrong number that would drop a syscall from the deny list. x86_64 opts in and supplies the ia32 compat numbers. Assisted-by: Claude:claude-opus-4.8 Signed-off-by: Cong Wang --- arch/x86/include/asm/seccomp.h | 15 ++++++++++++++- include/asm-generic/seccomp.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/seccomp.h b/arch/x86/include/asm/seccomp.h index 42bcd42d70d1..a911fce504ac 100644 --- a/arch/x86/include/asm/seccomp.h +++ b/arch/x86/include/asm/seccomp.h @@ -6,6 +6,7 @@ #ifdef CONFIG_X86_32 #define __NR_seccomp_sigreturn __NR_sigreturn +#define __NR_seccomp_rt_sigreturn __NR_rt_sigreturn #endif #ifdef CONFIG_COMPAT @@ -14,12 +15,18 @@ #define __NR_seccomp_write_32 __NR_ia32_write #define __NR_seccomp_exit_32 __NR_ia32_exit #define __NR_seccomp_sigreturn_32 __NR_ia32_sigreturn +#define __NR_seccomp_rt_sigreturn_32 __NR_ia32_rt_sigreturn +#define __NR_seccomp_clone_32 __NR_ia32_clone +#define __NR_seccomp_clone3_32 __NR_ia32_clone3 +#define __NR_seccomp_fork_32 __NR_ia32_fork +#define __NR_seccomp_vfork_32 __NR_ia32_vfork #endif #ifdef CONFIG_X86_64 # define SECCOMP_ARCH_NATIVE AUDIT_ARCH_X86_64 # define SECCOMP_ARCH_NATIVE_NR NR_syscalls # define SECCOMP_ARCH_NATIVE_NAME "x86_64" +# define SECCOMP_ARCH_REDIRECT 1 # ifdef CONFIG_COMPAT # define SECCOMP_ARCH_COMPAT AUDIT_ARCH_I386 # define SECCOMP_ARCH_COMPAT_NR IA32_NR_syscalls @@ -28,8 +35,14 @@ /* * x32 will have __X32_SYSCALL_BIT set in syscall number. We don't support * caching them and they are treated as out of range syscalls, which will - * always pass through the BPF filter. + * always pass through the BPF filter. It shares AUDIT_ARCH_X86_64 with the + * native ABI, so refuse to redirect it: the generic denylist keys off plain + * syscall numbers and cannot name x32's sigreturn/clone. */ +static inline bool arch_seccomp_redirect_deny(const struct seccomp_data *sd) +{ + return sd->nr & __X32_SYSCALL_BIT; +} #else /* !CONFIG_X86_64 */ # define SECCOMP_ARCH_NATIVE AUDIT_ARCH_I386 # define SECCOMP_ARCH_NATIVE_NR NR_syscalls diff --git a/include/asm-generic/seccomp.h b/include/asm-generic/seccomp.h index 6b6f42bc58f9..42b1b9b79ddf 100644 --- a/include/asm-generic/seccomp.h +++ b/include/asm-generic/seccomp.h @@ -26,6 +26,36 @@ #define __NR_seccomp_sigreturn __NR_rt_sigreturn #endif +#ifdef SECCOMP_ARCH_REDIRECT +#ifndef __NR_seccomp_rt_sigreturn +#define __NR_seccomp_rt_sigreturn __NR_seccomp_sigreturn +#endif +#ifndef __NR_seccomp_clone +#define __NR_seccomp_clone __NR_clone +#endif +#ifndef __NR_seccomp_clone3 +#ifdef __NR_clone3 +#define __NR_seccomp_clone3 __NR_clone3 +#else +#define __NR_seccomp_clone3 (-1) +#endif +#endif +#ifndef __NR_seccomp_fork +#ifdef __NR_fork +#define __NR_seccomp_fork __NR_fork +#else +#define __NR_seccomp_fork (-1) +#endif +#endif +#ifndef __NR_seccomp_vfork +#ifdef __NR_vfork +#define __NR_seccomp_vfork __NR_vfork +#else +#define __NR_seccomp_vfork (-1) +#endif +#endif +#endif /* SECCOMP_ARCH_REDIRECT */ + #ifdef CONFIG_COMPAT #ifndef get_compat_mode1_syscalls static inline const int *get_compat_mode1_syscalls(void) -- 2.43.0