From patchwork Thu Oct 10 15:22:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13830204 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 14AD0CF11F5 for ; Thu, 10 Oct 2024 14:12:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F1546B00A7; Thu, 10 Oct 2024 10:12:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 69FCF6B00A8; Thu, 10 Oct 2024 10:12:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51A566B00A9; Thu, 10 Oct 2024 10:12:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 32FE96B00A7 for ; Thu, 10 Oct 2024 10:12:18 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 784B440446 for ; Thu, 10 Oct 2024 14:12:15 +0000 (UTC) X-FDA: 82657882314.20.C166A19 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf18.hostedemail.com (Postfix) with ESMTP id 267CB1C0023 for ; Thu, 10 Oct 2024 14:12:14 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728569492; a=rsa-sha256; cv=none; b=e8+myxhcF25RLOHnKwHSnSNMWsMyB3a8UYt2pX3utA1uds/RjPnyo83491qiZVAA+4+xPM YEbPx45/KbT0NYUmGZGLGrMAQZyGMX8O++XO7VKozA+FCwiNeHdpNERBEsVwzW5fAPdRmC LxMNaUdfKz0MDoZ4FAXeiZpHPDojh58= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf18.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.191 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728569492; 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=u8JaX8yZxafhl1NuaoUCGwH4mMy31GRUFlzJBy/6WaI=; b=6GexzKydfgxPDnmfbpp+OM5atFu43Ll2B/entuUg18Zr8XvgRpl7aHSEDNmUIVQolpMZFA nzgsx+8ANvRKlDoPjifJExLvkqp6x4KOjbq342IqMSc6g9ZtI4HED0BveoZvn9aiazP3lJ 0rDlipuQjPhKQWXnTdi1JJc8XGBSLsQ= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4XPWn13NLdz1HKky; Thu, 10 Oct 2024 22:08:05 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 688EA18001B; Thu, 10 Oct 2024 22:12:12 +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; Thu, 10 Oct 2024 22:12:09 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 -next 13/15] x86: vdso: move the sysctl to arch/x86/entry/vdso/vdso32-setup.c Date: Thu, 10 Oct 2024 23:22:13 +0800 Message-ID: <20241010152215.3025842-14-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241010152215.3025842-1-yukaixiong@huawei.com> References: <20241010152215.3025842-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-Rspam-User: X-Rspamd-Queue-Id: 267CB1C0023 X-Rspamd-Server: rspam01 X-Stat-Signature: sr1pucfx5ze8k5j8b1xapdu4knhso3au X-HE-Tag: 1728569534-61823 X-HE-Meta: U2FsdGVkX1/Ecx1OAeGtdOvPBl2nagzBiDFqR7I8zUwb1UQCDBDS8pGqkQsGeGSp0q0Jt7iO5q7cp4nXesC7OTtss4KLK+YfAtEGMf5M+XTCbKs01VgPfuTclUYkZmnR9PBnmbgkVDYFb2wr7q62LAOuwjHCX5Mi4LWsoppsi9ybdfs2u9TWCaivk1axrsGa9xpS+UygX+VLAr/t/Spb7JEkaqeE7tlHLMpe/gkYi9CR/qoNt7IfVQIljRikaFI+/E/rqEbZ/wHrhjTRW6GPJsxhWLZWsraw98Nb9tHVlaBsdpqCNGRSjTADqxCMtxVO95NxSMxBVv5cEI7PpJdkX6WAxXmxUgN6tCYOqAWKX4jmOkQWCqLCBQ0r7p7xs2V16CmitvAzzULHUBy/+xEvpwuVpmQ+yq7g0DbQYm+ockN+dh7w07xvPU2t9aJ0O1mQJKMrWySv6IHAj+Cz4TuaRfWjGz1I8AGl5cBYvWP2chuPRcko/Q90sWcMWDCRGWRKAAqSePWoYJYfnw4DJIn2Qy3Rv4VOVfbbEGNgiCOQMiT0J8DZHCQ58gQt78JPCNh+MIMkTgrRYOm9URtmHsOaIlb/UYGNLwCV5kmzJZILescG8zGAYyRcbwOAHey50F5bZo6oFHnTzkpN7i3GKNAeRcybdOBFGDEKHle3WkZSYBto6weyyfp1+rCTaiHWZPLoWRmsU5dmF3AsXEvsPsrfYigqMKguLd0cQ0H7H/oX6cSKxkO4pE2WOY7R2QaeKRIfmTYbV+cOnNuRSn4U+Fgl4nH3LML/fh07dVRCtnOYJErBJALQ/N2bzDIPfYMgOyxnfKgDUyF2VvI5+ku3LGog4a1nBo3gk9xTlc7t7tSlo0P2w7qQTa6OrVveIWJAI4TEcB50bvSLHQ2DPDTAHGm3zx3hGzn5R3i0ZfAT3WrsrPXOmTkv0DO+Fn58jTgteppQBKDq7vMpTB8/FQQiVFc k8yKIinD I68Pn4zZ4y/i0tCEvdJ2HTmAVEslWrpUczz/3ePg32YtkWyVtNt+7GX7Z62Wd1IBg8+9mOXhE/U+UTGdcJl0GfkwohxowAq6rvbV4UFiAxhHddTn8pR3Fl2JESthFOvHBwxhaHfcR8aRgN/RN2w5fdtaohJRbHIRkitqi 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 --- 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..5a6886a006ab 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 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 6f03fc749794..24617be93119 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -2023,17 +2023,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,