From patchwork Sat Jan 11 07:07:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13935844 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1114E7719A for ; Sat, 11 Jan 2025 07:13:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FD9D6B00B5; Sat, 11 Jan 2025 02:13:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6927F6B00B6; Sat, 11 Jan 2025 02:13:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B2A16B00B7; Sat, 11 Jan 2025 02:13:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 24EFF6B00B5 for ; Sat, 11 Jan 2025 02:13:10 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D13E6810B7 for ; Sat, 11 Jan 2025 07:13:09 +0000 (UTC) X-FDA: 82994304498.04.5501535 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf08.hostedemail.com (Postfix) with ESMTP id 76D7016001C for ; Sat, 11 Jan 2025 07:13:07 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736579588; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w5gugbKQv5qJMbtMVTyjmHdyAVsCPAIp1jW4YKwC0Po=; b=LZXfX3J+PvPTRPjk2685kNM2/f92J+/JzEht1n3XF2H/v5jJnY73v9kq9LjfRHmPXqC9v8 dv+ka9MAVocUSEFxEPE3mHg3RElRqadPTMEqcxO8LaJ22usU6zZe81TqSvCBiGp4xmrw4b nyppl0TO/fmFvCfp53HxvhobJCyNOr8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736579588; a=rsa-sha256; cv=none; b=dXG2xmT2iMjj+Dwtbot/sxSR1jqq+Iex1smXZ5a5dVXK/HxOrPPH9Ds8ld4EwdcxnZVHgD NRD5c7dx4mz/CEd1Y38nlolgFfsNGJert2edSHIPn+JYeoeIqq9pylIJUOq3rGTSJ1dngS 02PcTKngZ3X9vFpiJZolB3XR4Z2H+9g= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; spf=pass (imf08.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4YVV5g1tqpz1kyCf; Sat, 11 Jan 2025 15:09:59 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 19FA71402DE; Sat, 11 Jan 2025 15:13:04 +0800 (CST) Received: from huawei.com (10.175.113.32) by kwepemh100016.china.huawei.com (7.202.181.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sat, 11 Jan 2025 15:13:00 +0800 From: Kaixiong Yu To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 -next 13/16] x86: vdso: move the sysctl to arch/x86/entry/vdso/vdso32-setup.c Date: Sat, 11 Jan 2025 15:07:48 +0800 Message-ID: <20250111070751.2588654-14-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250111070751.2588654-1-yukaixiong@huawei.com> References: <20250111070751.2588654-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 76D7016001C X-Stat-Signature: 1naapggr5xkxgfrzgajczrqy3b7uhw8k X-Rspam-User: X-HE-Tag: 1736579587-475347 X-HE-Meta: U2FsdGVkX18I96btyrwnxTnH5ZWHC0LoZWQxC+TOoUVSoO9TkulCvhbSOGJ4k5EoZHrJ9vFfCmaX0rn+QSn6nIZ8Cb69jPVebKrDMRhQ9yGrULaOTcvr75MWOrRpZMZx4mDL3ljHyjN0OPuvQujomBqz35rqcJYs9DppbMRuaWdzuC9qBxiTT89xlTybAA+cQQYfWMk/SfjHr9e3PSGHgTOD1ZK2rGfsfpYZ2i5HqSXgLs64IHGOH9HwCIsPyBGCWb6T+DYhIOU2IRoecfVUgqS4KA1U4HQQ63eP86nLPptfWvKFkNvVLwHKAC2uh84cRefEBhL/aif6a1kOkj1UIyeRyPRqL9qTAg7JOYUeRsV+Dlj41w0kqaRg3DghlSKFoezikHV2PRlmWlUh0L3Ag7L2Fk/rvqsJq1rB+RBwvacYjbQlNNaV3cax5UKqEFJOaM08ITnwKDJ7065CkJPA70V7xAkqDso7hqzkgI8n4aeHjFZCAM1QZDjJxnAkJJ9mOP3GC3IM1tTLCy54pEK6HS4b69Ja9iuAEXrW70occRKNORLgx4rFYCGh4KbK6FPI25N+/cR5kyYZiWFTa8uiNfHyor2Nx2cwJJADY3pTdHm1RvbkMOIKgR98p2CeYhgdfgA53XwqeZ2Tkr4k+CxYNGk57O65EojaSTb4uC3gLGAYOM+vAJP8pphsP0iVzI4zM/14ZwcDBakkSsyFh1OhHNAO4Tcj9sLFvd4Eok2CnYIBLaR9YJt6O052s/v7IaD1b23CFTzNDnzQUt3LBDW0B3S0dKcd8JlRwZJgce9AEiNrHsWE+fdGBMFeByXKZ9eYxGoOdYFOQ9XMNtpHP+b3gANtFi+/sJRSodz3F4gHeMGRhq3g03NbDMVWC579vtw8z0VzreZEL9qOxDH8sQPoAPR56Nk4uaLv2lNnhkeXXnaPSSoOZmNCyLz7kHGxKz0NiIHVmtueWZlELEpoLp1 77iTwm6Y X5vSdws7thaUx5yfHLzaqz8F9UcmyfdZ/LYMGCAnr1gcVgQzSg8aMUIylmh0p7vMpAxKx48wwnQUirYBLmD5mBo5RR4K7BsBCx0Dm+VMbUzVd9B3eH42bhE4CRjYtMjv0cOuemKbYqYXZ9QoTuHZrZV8f99eAizSkK5zN X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When CONFIG_X86_32 is defined and CONFIG_UML is not defined, vdso_enabled belongs to arch/x86/entry/vdso/vdso32-setup.c. So, move it into its own file. Before this patch, vdso_enabled was allowed to be set to a value exceeding 1 on x86_32 architecture. After this patch is applied, vdso_enabled is not permitted to set the value more than 1. It does not matter, because according to the function load_vdso32(), only vdso_enabled is set to 1, VDSO would be enabled. Other values all mean "disabled". The same limitation could be seen in the function vdso32_setup(). Signed-off-by: Kaixiong Yu Reviewed-by: Kees Cook --- v5: - Accept Brian Gerst's suggestion to reduce the preprocessor condition "#elif (defined(CONFIG_X86_32) && !defined(CONFIG_UML))" v4: - const qualify struct ctl_table vdso_table --- --- arch/x86/entry/vdso/vdso32-setup.c | 16 +++++++++++----- kernel/sysctl.c | 8 +------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/x86/entry/vdso/vdso32-setup.c b/arch/x86/entry/vdso/vdso32-setup.c index 76e4e74f35b5..8894013eea1d 100644 --- a/arch/x86/entry/vdso/vdso32-setup.c +++ b/arch/x86/entry/vdso/vdso32-setup.c @@ -51,15 +51,17 @@ __setup("vdso32=", vdso32_setup); __setup_param("vdso=", vdso_setup, vdso32_setup, 0); #endif -#ifdef CONFIG_X86_64 #ifdef CONFIG_SYSCTL -/* Register vsyscall32 into the ABI table */ #include -static struct ctl_table abi_table2[] = { +static const struct ctl_table vdso_table[] = { { +#ifdef CONFIG_X86_64 .procname = "vsyscall32", +#else + .procname = "vdso_enabled", +#endif .data = &vdso32_enabled, .maxlen = sizeof(int), .mode = 0644, @@ -71,10 +73,14 @@ static struct ctl_table abi_table2[] = { static __init int ia32_binfmt_init(void) { - register_sysctl("abi", abi_table2); +#ifdef CONFIG_X86_64 + /* Register vsyscall32 into the ABI table */ + register_sysctl("abi", vdso_table); +#else + register_sysctl_init("vm", vdso_table); +#endif return 0; } __initcall(ia32_binfmt_init); #endif /* CONFIG_SYSCTL */ -#endif /* CONFIG_X86_64 */ diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 860dea8f1587..7ff07b7560b4 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2013,17 +2013,11 @@ static struct ctl_table kern_table[] = { }; static struct ctl_table vm_table[] = { -#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \ - (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL)) +#if defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL) { .procname = "vdso_enabled", -#ifdef CONFIG_X86_32 - .data = &vdso32_enabled, - .maxlen = sizeof(vdso32_enabled), -#else .data = &vdso_enabled, .maxlen = sizeof(vdso_enabled), -#endif .mode = 0644, .proc_handler = proc_dointvec, .extra1 = SYSCTL_ZERO,