summaryrefslogtreecommitdiff
path: root/kernel/entry/syscall_user_dispatch.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2026-10-07 08:01:02 -1000
committerTejun Heo <tj@kernel.org>2026-10-07 08:01:02 -1000
commit92b542db38bf7cb4de583b2ca37febc549db0ce4 (patch)
tree30dcfdb338f7fdba597e1ec9314c2006df86f525 /kernel/entry/syscall_user_dispatch.c
parentfee1265a725725dac0ff7459f912d69558798b36 (diff)
parentd1a4549a3645e55cc9ade09e360280590b3c9559 (diff)
downloadlinux-next-92b542db38bf7cb4de583b2ca37febc549db0ce4.tar.gz
linux-next-92b542db38bf7cb4de583b2ca37febc549db0ce4.zip
Merge branch 'for-7.3-fixes' into for-next
Diffstat (limited to 'kernel/entry/syscall_user_dispatch.c')
-rw-r--r--kernel/entry/syscall_user_dispatch.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/kernel/entry/syscall_user_dispatch.c b/kernel/entry/syscall_user_dispatch.c
index d89dffcc2d64..59c861866941 100644
--- a/kernel/entry/syscall_user_dispatch.c
+++ b/kernel/entry/syscall_user_dispatch.c
@@ -2,21 +2,22 @@
/*
* Copyright (C) 2020 Collabora Ltd.
*/
-
+#include <linux/elf.h>
#include <linux/entry-common.h>
-#include <linux/sched.h>
#include <linux/prctl.h>
#include <linux/ptrace.h>
-#include <linux/syscall_user_dispatch.h>
-#include <linux/uaccess.h>
-#include <linux/signal.h>
-#include <linux/elf.h>
-
+#include <linux/sched.h>
#include <linux/sched/signal.h>
#include <linux/sched/task_stack.h>
+#include <linux/signal.h>
+#include <linux/syscall_user_dispatch.h>
+#include <linux/sysctl.h>
+#include <linux/uaccess.h>
#include <asm/syscall.h>
+static bool syscall_user_dispatch_allowed __read_mostly = true;
+
static void trigger_sigsys(struct pt_regs *regs)
{
struct kernel_siginfo info;
@@ -102,6 +103,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 +177,22 @@ 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_dobool,
+ },
+};
+
+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 */