From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (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 C3FE82F3C1F for ; Sat, 27 Jun 2026 20:56:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782593767; cv=none; b=CYy4fEmKEURDrxhiNuBPf2lRJDT3w4esKO6+lWHKyDYea5KfdYIUoKL5XjyaPanpDzk+31GdQVMmH+sawwTgnB8dl3Wg4fCJzp6uG2VQXLZPRKc2hkam1O7PJuQpocqF6rC8cd3wFiaIE5AjbEKHad9AK587K5qLHn7ksmqHjdk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782593767; c=relaxed/simple; bh=8G9FTDLCdDxMM5W0HpwbCdM6xzK8nY/RwixUATVbMl0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vr9m+d/w4A+ME87flAZPqWF4HrrUrXRHpNwTnY8aCwJLFTsmOUksZzM7Jnh36laHXvE3KqL/wDR7jW7g2iIB8tjEqBokNwvxXpf4Rxu/ag6m59J4eJ5AJKefeth3FQCLCZkp5UaUlV1EjerI+3SJUCuSY131rrlqRIM7EpE4iS0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=qKy7Kuyj; arc=none smtp.client-ip=209.85.219.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="qKy7Kuyj" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-8eefd0c5f59so1367776d6.3 for ; Sat, 27 Jun 2026 13:56:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1782593765; x=1783198565; 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; bh=LJmiPaWE1oBb3px3lgYj/2H7Qq4DS6Rodsmex8FgQuw=; b=qKy7KuyjZ3FOq8Uj6wGfDw45ar0YEkM5neZtUttNRvR09xCEMZ5ahSSC3JcMR4bd+K j9l35OMRC8tb1Cw5WwMQ8WrK3yMXM/0kwgXm3Tf3bnUEbkZ4sK2Ox0+QqWjb62MpQTgS lnVc64Nt9iE1vz4LfmxqlTogM19Ne+KG4cuVnvSCNEx0/bepBCeo2AGJ54fKs8DMF1Qq TvoPANBFSn7z8rAzy/3T1w+fy9cB6AalgxWGmbBNgYtrYKkpV1bop1rOTHJHgDo30vZI xjFNqvyberQVJ4fsHdcYhYQiE+tuDnbydO++XEkhioOv++yORx7zVm3NB5TptK3LBTlc YzFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782593765; x=1783198565; 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; bh=LJmiPaWE1oBb3px3lgYj/2H7Qq4DS6Rodsmex8FgQuw=; b=Hwq5zjc4QvfI73uw8EC6ALSmKZiDzg0a/NMZoI65P1kSNhjjst3khraB/R7z67yZG+ kfaBwANxQiob3Ye+jbw/OU7Lek0SQDwVbby/rRqo+8Fod7VAmfHRlNlBgEOjpLXLkXwR 2SQaO02X73dxP5jEo3EMacI9UuX5M17VMCw6Ud8QE/zvekW7w+Rlg4S8oNcSX0lLEmeV +CFe1ni+VJGS/mMMTDp7YadhaHdbYAI9ocTcYSoV/y6PtBc3JoiI9KeOyamKLNbv2yf9 U79Nck7RWtmv4Xpmezf0zvdfOpc0xhky3quaKMjAoH/cAlrYIPghyFQ9tw7oRvWTSgT9 rR7g== X-Gm-Message-State: AOJu0YzzJAaCWLCV2WZyilmJ6PsBCZ1ZWhZuGa27HyD4atPPccelkoYX UTOhosC1b07HwCxoQv49wLSvyl65dVxC9likP6JhsyL9fefBlKKj5T3xuVsCJXziXmPsDdLoge1 z1PeU X-Gm-Gg: AfdE7cmaVydGyHNyJdNI/7utG7pvjEvUGG3KQ1msMuy5fBkWMKpRbCbGldpnjME5VOQ tpZfMH40gPnjC2rZNXJfQDGPoyXLLggx+HDq5TFedtF1xgt2VbpTSjvPitcjQ4atbtzeytVek9p +3O9RH/QXNahw7IcW2sO7BxrChOGVbKZyTarKRJkV1NP71gaRNvM1crcAnVMzOAwWSO7qPNd57C hm294Ib2eee624uadlwipgOt99ik+x3CkXos3txwfpqaMrGr2aKMdveIF6X3qNyy/0sUbMxaqY1 CS40nrXC/FLDvB3BkhU2qeeEaNghZv3vb2TmmrPcAZB7LOOS687/6LeSVSCn/lB9Qe0j3Ifdcor ISminzadkYURSjgfA50Zr2Qpf69rQRTCXp+0EoKuS3JW5T3djcMr9D8Y66gn7t3jAcfisDS+rYV EzIDvrOdwC6cPPR0IHVf+U49dIRD1hgwjG+9ai68MTqE6CoEY+rYqGB4WRYPyNBqUcvsWAJmdpA E3Gugqf5IRj X-Received: by 2002:a05:6214:21eb:b0:8ce:a005:3ea6 with SMTP id 6a1803df08f44-8e6da33b970mr200983256d6.22.1782593764787; Sat, 27 Jun 2026 13:56:04 -0700 (PDT) Received: from gourry-fedora-PF4VCD3F.lan (pool-173-79-60-52.washdc.fios.verizon.net. [173.79.60.52]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8df81cdec56sm265460836d6.32.2026.06.27.13.56.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jun 2026 13:56:04 -0700 (PDT) From: Gregory Price To: linux-kernel@vger.kernel.org Cc: linux-doc@vger.kernel.org, kernel-team@meta.com, corbet@lwn.net, skhan@linuxfoundation.org, tglx@kernel.org, peterz@infradead.org, luto@kernel.org, akpm@linux-foundation.org, feng.tang@linux.alibaba.com, pmladek@suse.com, mhiramat@kernel.org, marc.herbert@linux.intel.com, joel.granados@kernel.org, gourry@gourry.net, lirongqing@baidu.com, kees@kernel.org, nathan@kernel.org, linusw@kernel.org, arnd@arndb.de, deller@gmx.de, jpoimboe@kernel.org, ruanjinjie@huawei.com, lukas.bulwahn@redhat.com, ryan.roberts@arm.com, ojeda@kernel.org Subject: [PATCH 2/2] kernel/entry: add kernel.syscall_user_dispatch sysctl Date: Sat, 27 Jun 2026 16:55:51 -0400 Message-ID: <20260627205551.769684-2-gourry@gourry.net> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260627205551.769684-1-gourry@gourry.net> References: <20260627205551.769684-1-gourry@gourry.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add a matching sysctl to go with CONFIG_SYSCALL_USER_DISPATCH. kernel.syscall_user_dispatch (default 1) controls whether userspace may arm SUD (both via prctl and ptrace). Disarming is always permitted - same semantics as comparable knobs Signed-off-by: Gregory Price --- Documentation/admin-guide/sysctl/kernel.rst | 17 +++++++++++++ kernel/entry/syscall_user_dispatch.c | 28 +++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst index c6994e55d141..4c90caaf1e21 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -1402,6 +1402,23 @@ Note that if you change this from 0 to 1, already created segments without users and with a dead originative process will be destroyed. +syscall_user_dispatch +===================== + +Controls whether userspace may arm Syscall User Dispatch (SUD) via +``prctl(PR_SET_SYSCALL_USER_DISPATCH, ...)`` or the +``PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG`` ptrace request: + + == =================================================================== + 0 Arming SUD is denied with ``-EPERM``. Tasks that already armed it + keep it, and disabling SUD (``PR_SYS_DISPATCH_OFF``) is always + permitted. + 1 (default) Arming SUD is permitted. + == =================================================================== + +Only present when the kernel is built with ``CONFIG_SYSCALL_USER_DISPATCH``. + + sysctl_writes_strict ==================== diff --git a/kernel/entry/syscall_user_dispatch.c b/kernel/entry/syscall_user_dispatch.c index d89dffcc2d64..1c39ccd733f5 100644 --- a/kernel/entry/syscall_user_dispatch.c +++ b/kernel/entry/syscall_user_dispatch.c @@ -11,12 +11,15 @@ #include #include #include +#include #include #include #include +static int syscall_user_dispatch_allowed __read_mostly = 1; + static void trigger_sigsys(struct pt_regs *regs) { struct kernel_siginfo info; @@ -102,6 +105,10 @@ static int task_set_syscall_user_dispatch(struct task_struct *task, unsigned lon return -EINVAL; } + /* Arming can be denied at runtime via sysctl, disarming is allowed */ + if (mode != PR_SYS_DISPATCH_OFF && !syscall_user_dispatch_allowed) + return -EPERM; + /* * access_ok() will clear memory tags for tagged addresses * if current has memory tagging enabled. @@ -172,3 +179,24 @@ int syscall_user_dispatch_set_config(struct task_struct *task, unsigned long siz return task_set_syscall_user_dispatch(task, cfg.mode, cfg.offset, cfg.len, (char __user *)(uintptr_t)cfg.selector); } + +#ifdef CONFIG_SYSCTL +static const struct ctl_table syscall_user_dispatch_sysctls[] = { + { + .procname = "syscall_user_dispatch", + .data = &syscall_user_dispatch_allowed, + .maxlen = sizeof(syscall_user_dispatch_allowed), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE, + }, +}; + +static int __init syscall_user_dispatch_sysctl_init(void) +{ + register_sysctl_init("kernel", syscall_user_dispatch_sysctls); + return 0; +} +late_initcall(syscall_user_dispatch_sysctl_init); +#endif /* CONFIG_SYSCTL */ -- 2.54.0