From patchwork Mon Dec 23 14:15:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918981 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 D5AC3E7718B for ; Mon, 23 Dec 2024 14:21:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 653A36B0082; Mon, 23 Dec 2024 09:21:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B56B6B0088; Mon, 23 Dec 2024 09:21:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 480C46B00E9; Mon, 23 Dec 2024 09:21:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 267916B0082 for ; Mon, 23 Dec 2024 09:21:16 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id E0E311A18D7 for ; Mon, 23 Dec 2024 14:21:15 +0000 (UTC) X-FDA: 82926434682.13.3E27283 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf17.hostedemail.com (Postfix) with ESMTP id 7C7B24001C for ; Mon, 23 Dec 2024 14:20:44 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 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=1734963656; 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=XVAP2YL/LcT7j+M6fgTBY91P4QxjGaa6nQWMftrtHB8=; b=4rihUgoDVC4Bo/MEQ5NGdBzrFa5Z1JEaQsBc5n/sNhmha/IXdpNVMrnzCXECwBhx9yB6IG HKatW2yZVmAIN0GzqJONsbqocN918Iejj/NCDVKKwVkkuaC4goG9P5rn/D0SPkiRlQtlcV 4+lhgXcJDJocKOTrptonB7fjRDfHDZY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734963656; a=rsa-sha256; cv=none; b=LdaW8y3JtN1tjQCnfKPwq+THq7U4lESpHaf/o6qcaXM1T102GSbiV3058sXcB2r+lhFJxo e95SKnth1Hc67qQarMwXo+lcUREttbmDw6KEfcWJuMC2H9FCAmtUTA0Kj9CuXPaBfmxje/ xGr7X9GemVHa3fGICvnuhN/VtbQ5QjY= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4YH0Wx0YfbzrRqx; Mon, 23 Dec 2024 22:19:25 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id C89DE180087; Mon, 23 Dec 2024 22:21:09 +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; Mon, 23 Dec 2024 22:21:06 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v4 -next 13/15] x86: vdso: move the sysctl to arch/x86/entry/vdso/vdso32-setup.c Date: Mon, 23 Dec 2024 22:15:48 +0800 Message-ID: <20241223141550.638616-30-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241223141550.638616-1-yukaixiong@huawei.com> References: <20241223141550.638616-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemh100016.china.huawei.com (7.202.181.102) X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 7C7B24001C X-Stat-Signature: zn1j65co9j1tuswi87z6789m174te6ub X-Rspam-User: X-HE-Tag: 1734963644-618505 X-HE-Meta: U2FsdGVkX1+txevwLhigCB372tMRAK1ucIr6i/JlH1Lxd/X2VsDxRWpsY/YY1+onEH55OyGdkl2J5bsLGEalZcGb7oQ5JMdjXtWogn9EksPtLBvlYO4wDas932xoMChQgM16mwXw1IToJjNoi2Fg5M6RKuoCqsanIFhElfRjF/R38Bbc5PrsbAPoGM2QmwC4c6jULwRGqXEmQhege4sdfzz3poQ+16L/w05ksqX589w+9g9VgA1toRx8s3QxT/Op354ie7BhEpNKpgy0imj1ZqD7rtqcJ9oL4fFSqMyCDEPbuGfcxPLvdYrz7LZa2UPixcoxm4FhxkiGDWh1zq23tgMMLmO4uFU8DPdQfg+qCdOVPGIyT50oTFvDWOLXAdLYDCy1cbRADsfybnmdzaDnEWJOc7qpeWNjCq0qSRgfGktNej6CsEmfmYkWKe3qxCikgMGOxtxJJrgipGv1Qx6N8XWQcOiGwGM+q3px5aGaVyU194e+rYVz8yAbT9d9cU06CKafoFgXLvrwjsZQX+ZzJEQJQbLQmcE9oNB7bM7A15Ev7dOq0viNY2SXHytiNtD7vEU+sMzLf9+hX6DAaD9znwyHI8Y7Q07I6K3k9th4M/ufPyq6m3/Sv9wNlNo4mg5AQ7smWyJLoql2bqe182NSWTfzEvO44jCBjTMzI0JL8IMhorrqr46XnmwOJIfRam7XrkZ0zJMleZBsMMLQVsm60aoP3v5J3O7jQlv2UT6nIoMid+UIe0YzlGLARWC9e96FcrCf29XtBPCISpiRH1BdSxrvTdSar/h8X1WzhxEZJmcr9/6OXgCoBJbaJdP37CwgSt7vOsx9TqOY8ik4XigNZgyD6mOye5GkG0ZWYdNuXlv//ya7chiAUm49douIy7qU9u0+TprWTI3Q/tfKKVPXTf4kZEx2EP43AVZagFuNWZIadRYWlEFa1fRU684O6sqTvNqws1yCcVb/Fl/9SU9 Qppd3yD7 OIFGiEedGRfC3S9TeK/eGcyZVZRMTNPtz3Jp+RnD0fPcT5bwDt6ho10a31M0K1eypMIXHdQyjr/PQTs18nwZRbkemx/W9fTh58pjeVp70mAH0KpmlenoJ7NQ3csadEhdbc5mafTJh5Al0IHFLUDiDWQlAWgHttOsnyDKO+xwGC/ZcXog= 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 --- 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..f71625f99bf9 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", +#elif (defined(CONFIG_X86_32) && !defined(CONFIG_UML)) + .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); +#elif (defined(CONFIG_X86_32) && !defined(CONFIG_UML)) + 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,