From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (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 310CB37206E for ; Sat, 4 Jul 2026 01:59:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783130356; cv=none; b=sk0xLwkvGTma0jkLwkv+0JN4QYXqmjlVXYRQasM1Ripl0kfnZMqKqjlaLenmxIWZnVKhN3jJtwQyiacznGtM88eCr/7kJleFFVRwe0gV9qPV+m0yP2DZGvFB9FHULv3BqgpAbrl6fDHZYgI3r02N9HwGyxNCOhedL5ge+BFgRrU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783130356; c=relaxed/simple; bh=T0t5M/tb11Dl8w32HFMPoNKEsjuCn498IkXKnjv337I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uNT7gILpSz9Fa1QxrilslcbNqnZR8PpYdsvW/FvI8LbQ8/xOwduWa0XELBWHzFR2RfdQXH5iG7J8hex+ym9+wZpD8jxsRFuzMkjNU13RE7TnSWNE4Bvd2ycGBxzoo36mUxdeN1KKojEgbNvMm3zkpCPZnD2Dn/BXxHpy4w5emW8= 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=lfc57C4E; arc=none smtp.client-ip=209.85.160.172 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="lfc57C4E" Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-51bf2479349so7355001cf.2 for ; Fri, 03 Jul 2026 18:59:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1783130354; x=1783735154; 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=1o1MWgoY6UQRPPZVOsNGZDHuSijtCgGTMT4PN0DmAqg=; b=lfc57C4ERGadzVOUYHgpkNqMYBCuzvtiN4pPIsyVl1pJjrhWNg0eUaRBS4TjanCgmj quEmaOj1gumKg9aBBKwieyT555aezSB+WgBP6ikQlHLg3YjGxLMa8DxKyyvbySUON6xj DwWj5fiTjd7hTfTjwiDCDrYRgzfKauNzWt1K1IOvd8e+b4WzmtpTJAUut3XlEO976q+E NNPm8kX+txjl96T6juH7sOK44mWZ6N2GCdStwMDFKnnXKZkejP0B3clKlz9jQmgSYXjp gviCMDMtCrjtf8K5xisX8RFwMkEg5KGHCsB5J/ULZo4n+0f1hWX6WjlBDT+I9SxnBThU RRmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783130354; x=1783735154; 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=1o1MWgoY6UQRPPZVOsNGZDHuSijtCgGTMT4PN0DmAqg=; b=aZHJpNdj+s2Cjp8LTo1qgbb7wBLoYjmwic85MzLk8OaPuaD5ovGcqiAGaCkRXXiNhy mPo+zlH+7PkWY5J4XiPTqJQc4CiDA2W5glv34My7hPKQcRGdZC9vnS80DQDoLaa2TohN DxCUx1lzoJFxhZUeDR55X8ngdjge90iF5mptJAlcOq/amfNBPa1+IfE0dU8aaCFk0f6O 3kuyHLZjhOS9uym4GBlOZOyA258IodRSKwwyg1y6BDWjnYqUGcD9qTCtjmq2HRvI2ta1 U/H8KH2XeMspSg5MuN29EMUqqe9Jn45Kvu0XihORr5qHVY0/62TqskUVQsoGc3G3hnPy ec/A== X-Gm-Message-State: AOJu0YzrVaquRQ05e6XxFgQi0V7EyZKeh6iOknkyLhvEARmTnKHUjGXt aBWMMbMCAQ0ZA6kPX/TnqWo+ToyloPOYo/QdU97rFqEjxINbqORtbjzuarZDTYCqMzDApBV8vzE EwQsg X-Gm-Gg: AfdE7clUIKI6lJMaVo/D1+nTKumQDEThrAgv6nQjbZd1I8qlI8kV3am8tGcEgNbh1lu vJFV72H3hiBojuxsyyQKalw4B7GkkYFVTCJm4U5rcC2NpM0vsGGMEo77BY8PZfCr2wrZXCjXXbX BoNCj4mP3UZZFOxdORgqLM8N4Y1WpMVJVCa67s3YEBKMedYUwYsfr8AmuRR05ndC67R4UHwLr1P E/DtYR4kUkrSZxB6VyrKBY1Arx6bexBQQMGqOiYSOdEeQZgTilMiCObExDzuNLseUiny5v6Dhmp AHq923EmwdY1dG+yJznJKaPoS/FkNZ+gkUzVgEQIij711Wc2GNlrWMmH1xX1Y9U0GHvWUGXzuBJ 2meMTPxEhC9ynpESkM8RmX8XYL5qhsPRBgEPt+gvHlu6EEptgijNNsbrjD4TNqej8nouVxlZ5wW dy6G6firWdx/FSlEoYFut8Iwz4O/d8ykBokf4i1czoXYmrGVsfpssGSQ== X-Received: by 2002:a05:622a:5918:b0:51c:19d8:e30a with SMTP id d75a77b69052e-51c4c1e421fmr30575761cf.15.1783130354238; Fri, 03 Jul 2026 18:59:14 -0700 (PDT) Received: from fedora (50-32-2-77.vng01.dlls.pa.frontiernet.net. [50.32.2.77]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51c41e084e8sm28109311cf.28.2026.07.03.18.59.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2026 18:59:13 -0700 (PDT) From: Gregory Price To: linux-kernel@vger.kernel.org Cc: linux-doc@vger.kernel.org, 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, lance.yang@linux.dev, marc.herbert@linux.intel.com, kees@kernel.org, leitao@debian.org, gourry@gourry.net, joel.granados@kernel.org, lirongqing@baidu.com, nathan@kernel.org, xur@google.com, lukas.bulwahn@redhat.com, ryan.roberts@arm.com Subject: [PATCH v2 1/2] syscall_user_dispatch: Make it configurable in Kconfig Date: Fri, 3 Jul 2026 21:58:58 -0400 Message-ID: <20260704015859.536580-2-gourry@gourry.net> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260704015859.536580-1-gourry@gourry.net> References: <20260704015859.536580-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 Syscall User Dispatch is presently built under CONFIG_GENERIC_SYSCALL and cannot be disabled independently. Add CONFIG_SYSCALL_USER_DISPATCH to make it an optional feature. Signed-off-by: Gregory Price --- arch/Kconfig | 11 ++++++++ include/linux/entry-common.h | 6 ++--- include/linux/syscall_user_dispatch.h | 28 +++++++++++++++++++-- include/linux/syscall_user_dispatch_types.h | 2 +- kernel/entry/Makefile | 3 ++- 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index fa7507ac8e13..192b9d8abb5f 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -114,6 +114,17 @@ config GENERIC_ENTRY select GENERIC_IRQ_ENTRY select GENERIC_SYSCALL +config SYSCALL_USER_DISPATCH + bool "Syscall User Dispatch" + depends on GENERIC_ENTRY + default y + help + Syscall User Dispatch lets a thread have its own system calls outside + an allowed IP address range to be intercepted and redirected to a + userspace signal handler. + + If unsure, say Y. + config KPROBES bool "Kprobes" depends on HAVE_KPROBES diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h index 416a3352261f..9336516430a1 100644 --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -55,7 +56,6 @@ static __always_inline int arch_ptrace_report_syscall_entry(struct pt_regs *regs } #endif -bool syscall_user_dispatch(struct pt_regs *regs); long trace_syscall_enter(struct pt_regs *regs, long syscall); void trace_syscall_exit(struct pt_regs *regs, long ret); @@ -232,10 +232,8 @@ static __always_inline void syscall_exit_work(struct pt_regs *regs, unsigned lon * of these syscalls is unknown. */ if (work & SYSCALL_WORK_SYSCALL_USER_DISPATCH) { - if (unlikely(current->syscall_dispatch.on_dispatch)) { - current->syscall_dispatch.on_dispatch = false; + if (syscall_user_dispatch_clear_on_dispatch()) return; - } } audit_syscall_exit(regs); diff --git a/include/linux/syscall_user_dispatch.h b/include/linux/syscall_user_dispatch.h index 3858a6ffdd5c..c466af02da36 100644 --- a/include/linux/syscall_user_dispatch.h +++ b/include/linux/syscall_user_dispatch.h @@ -7,8 +7,22 @@ #include #include +#include -#ifdef CONFIG_GENERIC_ENTRY +struct pt_regs; + +#ifdef CONFIG_SYSCALL_USER_DISPATCH + +bool syscall_user_dispatch(struct pt_regs *regs); + +static __always_inline bool syscall_user_dispatch_clear_on_dispatch(void) +{ + if (likely(!current->syscall_dispatch.on_dispatch)) + return false; + + current->syscall_dispatch.on_dispatch = false; + return true; +} int set_syscall_user_dispatch(unsigned long mode, unsigned long offset, unsigned long len, char __user *selector); @@ -24,6 +38,16 @@ int syscall_user_dispatch_set_config(struct task_struct *task, unsigned long siz #else +static inline bool syscall_user_dispatch(struct pt_regs *regs) +{ + return false; +} + +static inline bool syscall_user_dispatch_clear_on_dispatch(void) +{ + return false; +} + static inline int set_syscall_user_dispatch(unsigned long mode, unsigned long offset, unsigned long len, char __user *selector) { @@ -46,6 +70,6 @@ static inline int syscall_user_dispatch_set_config(struct task_struct *task, return -EINVAL; } -#endif /* CONFIG_GENERIC_ENTRY */ +#endif /* CONFIG_SYSCALL_USER_DISPATCH */ #endif /* _SYSCALL_USER_DISPATCH_H */ diff --git a/include/linux/syscall_user_dispatch_types.h b/include/linux/syscall_user_dispatch_types.h index 3be36b06c7d7..c0bdd4f760d3 100644 --- a/include/linux/syscall_user_dispatch_types.h +++ b/include/linux/syscall_user_dispatch_types.h @@ -4,7 +4,7 @@ #include -#ifdef CONFIG_GENERIC_ENTRY +#ifdef CONFIG_SYSCALL_USER_DISPATCH struct syscall_user_dispatch { char __user *selector; diff --git a/kernel/entry/Makefile b/kernel/entry/Makefile index 2333d70802e4..f220bae86b12 100644 --- a/kernel/entry/Makefile +++ b/kernel/entry/Makefile @@ -13,5 +13,6 @@ CFLAGS_REMOVE_common.o = -fstack-protector -fstack-protector-strong CFLAGS_common.o += -fno-stack-protector obj-$(CONFIG_GENERIC_IRQ_ENTRY) += common.o -obj-$(CONFIG_GENERIC_SYSCALL) += syscall-common.o syscall_user_dispatch.o +obj-$(CONFIG_GENERIC_SYSCALL) += syscall-common.o +obj-$(CONFIG_SYSCALL_USER_DISPATCH) += syscall_user_dispatch.o obj-$(CONFIG_VIRT_XFER_TO_GUEST_WORK) += virt.o -- 2.54.0