From patchwork Mon Dec 23 14:15:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixiong Yu X-Patchwork-Id: 13918966 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 B9FBDE7718D for ; Mon, 23 Dec 2024 14:20:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC4676B00CA; Mon, 23 Dec 2024 09:20:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A72596B00CB; Mon, 23 Dec 2024 09:20:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 913DA6B00CC; Mon, 23 Dec 2024 09:20:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 677106B00CA for ; Mon, 23 Dec 2024 09:20:22 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 154BF80EC3 for ; Mon, 23 Dec 2024 14:20:22 +0000 (UTC) X-FDA: 82926433128.04.FB2EB0F Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf11.hostedemail.com (Postfix) with ESMTP id AB1EC40008 for ; Mon, 23 Dec 2024 14:19:44 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.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=1734963591; 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=vtUe5KA/U6IHy7euIfBwZsj4iA+Wv18B5W9JRsTRBLQYlZhhbtVVFEprDXHZB0fUAkxC8q I3EA40UdeGUkBr1Go4pxuc9oWPJ5WHmtXtQwtAG388r0TT74s2YD97UIqOYitipoVHmjZU R1PjZEAtwRH4ERbci27QrN4etI4z0U0= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf11.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=1734963591; a=rsa-sha256; cv=none; b=KXggV5Gq0e7v5JChB5G25k6988x3Ni3FZbCwoCfe6OyEgILzAvdSa492JA70/M3mCFQMOM 5Izcu/uhMk3rs5TtxK6WFHVwJfQOYVKgC7HlilC76wNWIe2Gp0C7LX9shixTRbFh/GtkTw kQkhIuG8FOmFDa+knp5NkxQ9l1WVvAc= Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4YH0Tq2xVNz1kwqP; Mon, 23 Dec 2024 22:17:35 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id 6ED25180043; Mon, 23 Dec 2024 22:20:16 +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:20:13 +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:32 +0800 Message-ID: <20241223141550.638616-14-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-Queue-Id: AB1EC40008 X-Rspamd-Server: rspam12 X-Stat-Signature: dsb6uzoaomndgk8mqsgw9ri7gaf3z9wt X-Rspam-User: X-HE-Tag: 1734963584-872440 X-HE-Meta: U2FsdGVkX1+Ixmg/GAByhEOWz+cSx8aCJFe6vzLGx5aHZYforeb5gfiEe8/t4vVehLpxqZfX08W0rKiLZehufG0JCEUWP1P1LmQvf0sPpbqUU53N553gwq8GRtnDX162WbLt23TWN/jg5BaVa2Dgd1PAD/9RwQxKfnh9QfaYZkASaRLWfuLkKcD0YUo6S/dt7MhCAgmuNppAxiy9zgs6bIcaRqGz6a/xJIvyivmc17WAu3U2sfVOle1gsB1W6HGbkemHuh5FGlCAA+FBYxuYikDdtVi+nxYCWTIsXU0OHnHqK1oTHDMYLqw3Xqk37FujJBhWrtHNOASjowzrXL2KpG4wdckR5p15OtbmCydtegJ+dP0Lgxdi9qalo8nUBlFWAI3+5CanLGD/PIDpnvBcplsY8XUQD1V+1y7mof+WSwjH1s2njF2gFReMG8NUA7KCdJLYpPPYUe+xpZ/MyVTvqsVwWl7mZUwB/IMnGGdBwMHlO+aRmo8vY5RiX5Hfb6HUhE3ayQ9X0sTL5roonB7Xt1o2G7m+2L4oi7zs+QqSrDgCyM2YenJu5nLjZP3Y3epHuNRXtM7XfJstfRZHHWvgvuEm5hXa3ppmnlGGvqkXEjfeAL/8cktZeCCUbDXVksiRLFRFqLj40QDxITekR6ISBaxqpi66UVt55KKNKLvfNBBlvAJlCudM1CG8ra1MzBSEGiO6XgBaY2V3224DZtPfgNjV0ArXO5tYa+jBDcLxH4/LK0YBZbsImyuuzWOcpZQQ4t7Y8IyD8tqe4BDRXXh/AqDfqs8BhzJRpgZ2htaYaDGw6BoHiQ/VV3kExXiPAe8tC1MLIuZxZ3VjbP0Pv//MRJgCpgV8kvXP6moWODNyaEOr6nm6Z94JLMtK7gOsh5RusLFJV5ikDe8bd/vzNWjldLVEf7jEQP9taCUPVVPKkRL0IIhtsZHT3b6F7zigtwGbE++fC2UW25UvDDs90S4 Plb1otmY aGGE+1h3YAHatog+d38vLlRxfgERCIUvnNw479qXcrUXUXPOQAUxqNI07DgKWV6zJKwQ96xCOrvDeIxUR+9OLomiXJm4Z30cT+ocpwFG+t1iy4iJObb9k/RyjbHwe7pq1nfjwTQ+wOPqmvs6ZOglQgqVPFi+w4X0kOdgSIfKl10rRApk= 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,