From patchwork Mon Aug 26 12:04:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13777727 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91F4416F262; Mon, 26 Aug 2024 12:05:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724673955; cv=none; b=OjXmkNrMXVuS+ozO7RsxhxuyHHHdHFLonUrUpEyaS6UY3QhWqyb9euqbeh/ZlAWgmMPjRrNyF6uznKZrKCpLas950OSlHNvp4ZLeeBsggWKBEjYi6dcTXSQ3icvAJQotrWPqfet38MtMQyceS+gxZJ59p9RFm80efHPc0T4NrPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724673955; c=relaxed/simple; bh=CulbPYR/PtGE/cSv5ghlj2I1fT+sMeoUvCx6Es+4Rko=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hZpNI3/WVrnEVkH1C6Y4N1s9/x2JSk+fBAI4r/Wh8qXHwGaI5enhT1jY2Ne+gmuK4FdifS+MlELcDzLWcrLHx83lNyP9k+87uCoFERhxerzsQapA0pzx7gHSrJEZYw3aFKnLMKJekoxl2ly3Ak0t6xSKeZ3kWjpZwgmRdBWsjVE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Wsq5C2dFqzQqhb; Mon, 26 Aug 2024 20:01:03 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id F1B301800D0; Mon, 26 Aug 2024 20:05:50 +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, 26 Aug 2024 20:05:48 +0800 From: Kaixiong Yu To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH -next 13/15] x86: vdso: move the sysctl into its own file Date: Mon, 26 Aug 2024 20:04:47 +0800 Message-ID: <20240826120449.1666461-14-yukaixiong@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240826120449.1666461-1-yukaixiong@huawei.com> References: <20240826120449.1666461-1-yukaixiong@huawei.com> Precedence: bulk X-Mailing-List: linux-sh@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemh100016.china.huawei.com (7.202.181.102) 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 --- 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,