From patchwork Sat Dec 28 14:57:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yukaixiong X-Patchwork-Id: 13922375 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 5E6ADE7718F for ; Sat, 28 Dec 2024 15:02:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DD5CE6B00A7; Sat, 28 Dec 2024 10:02:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D5E996B00A8; Sat, 28 Dec 2024 10:02:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BFEE56B00A9; Sat, 28 Dec 2024 10:02:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A0E026B00A7 for ; Sat, 28 Dec 2024 10:02:33 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 55FF8C0774 for ; Sat, 28 Dec 2024 15:02:33 +0000 (UTC) X-FDA: 82944682716.21.F5F31BF Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf13.hostedemail.com (Postfix) with ESMTP id 2FE8020018 for ; Sat, 28 Dec 2024 15:01:47 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 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=1735398131; 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=WpeHczk2yrTxfdlPyspI0BCkTA/LZAECmCJsyheLbqk3Ru3RXY8+hSrAgyzNJuly9wyfbr Sd8h89bi5Vl18D1FnRa8gPA4AYRru9gMtiAsSYPfvoIbdVMt+l9Woxlfl/03G9Hhwq5DYX ghDfIjJAe2E22z2tAg5pGaTv6/3axmk= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735398131; a=rsa-sha256; cv=none; b=2ctV67SALEzACMs2YHXPajhM8acoGmqSvMFWqybpRYoXyNVl/f/hqGBxV20/mvc8f+4e7s Gx1uRL1qojALJdoaNomjACRGPez0PZtHOpd94toXB/g+mgp8Mjp33858oUKW6+Fw8yuq3O vWA60T0Mc7XIr+h9ArqsGu26zflMgMc= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf13.hostedemail.com: domain of yukaixiong@huawei.com designates 45.249.212.190 as permitted sender) smtp.mailfrom=yukaixiong@huawei.com Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4YL5B30xN4z2Fby3; Sat, 28 Dec 2024 22:59:39 +0800 (CST) Received: from kwepemh100016.china.huawei.com (unknown [7.202.181.102]) by mail.maildlp.com (Postfix) with ESMTPS id B9F301401E0; Sat, 28 Dec 2024 23:02:26 +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, 28 Dec 2024 23:02:23 +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: Sat, 28 Dec 2024 22:57:44 +0800 Message-ID: <20241228145746.2783627-14-yukaixiong@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241228145746.2783627-1-yukaixiong@huawei.com> References: <20241228145746.2783627-1-yukaixiong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemh100016.china.huawei.com (7.202.181.102) X-Stat-Signature: ow9f7hdy98cb7pwhwyyrwf4mjajwm7f4 X-Rspamd-Queue-Id: 2FE8020018 X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1735398107-662514 X-HE-Meta: U2FsdGVkX1/jIN0LUUmXZs51D+mv1Afutf4aD3gBnAdL0cxYWl7xsabXP7F72g6y4DhAtXfktgd93Mvk5FgbDC1is2upbnQTLDwAJS1ct9TXUZVlyMdvjglUd5w6MmGcCuKV7NO6Oy/kwprXdlEbPQuoj+4ASRJh0dNYYmW3Pnc1mgSqW6kogmhEg9qV5KWRfdvn89zwxRIEGrzaG1nO9DUeR6dOwP13C/Qhfnv67PwM9fLIWbA1CoGyAOtgLrqQ9tlaOaunYMLnrEhuHhYdW8TivSL1DE+Z4PBaxdTYYGtGjiL//mitoaLMpbz8PoSMxx0tMaWCZoh/CqVyIcjOo+8+U5bg8+OebY1vj4xg4+oqUey1UvwUZnKhfOLoc+G2ItVGuLGNSGwGZ64LKFql6dGuoh0wqh2y2DbSa1vol2vB7XXB9fmRki/9cuuw2Bl7Ozxr7c+6WaQZlPKod4EKhpekxajfg8bpVKsgBPGjsK8ASKcWqVqIZNSYBfTWxkv45z1pHaAmeVmNAesK2ycbl5cRi8gULTHzcpGGiSWwAKrSV7OU1HZebH5ePJq8b/jbdQ2F50Cxfmlro0yPJDHhR5CyJRmY+YQ5GATy+ULcotNTNbenuBQNoB+caxQiOfqNAfaJ0uHAkWg7DRUgOhPhp7UbQwyGIe+ytk+HBh7fAeeUQOoorpNG/6uwl/Hb0HQUHhsqukSvyLq6wq6Hf2a2dnC6cgwCQTHpvVZFZr0PcQzCQNdbVB00isTXRTMU8CcUHAsghFxrKRDwx6TTvH8xQp47NOKDXn6IPfUKRvzIC4rBBSgD793aWZNoeNlkPSQLJpxfQMdxsqf3xQd4wUFfi29T4CffvFKLE4kZmalkIuWtUaMsJESSvHZaQBbfsfMK3TUiC+GPMFSPVVpMh+QS5prvQ/rn3BRoi9nk3ni8JFSo112VAUSC+vlnwZoIklLbAyyVnkc2KMfWYqB7hH6 nqg82eGb TrNYhi5s3H9WAHbR6ZYDdA8l5Kbhd/ooO6WKfMkn93q1Wd1nlLB8Dt95usF/jSLrdimKTWrq+Ro2oXsDnZqx0bDxqFf03W8C7zVySacoisJelucj+jKWnZ8tYDexx4LSf4/2GP8NKHwh9ur/EBGtz5LFO/bKHGEVs+mQuDNfvGOx+FP+M4rikK7MB4pufm6dggy1AUsc2kJ93alQf6pzr69jxC3Y4/TQTpDul57HiCc+LIsz/rwFAgjOR0mjotzOiGyMDOMa6SCVhWf1zNJaZQNiT/8fm4Rs/zADj5jZCSjXNzjdnVbeJuKuKaDO2Que1Jx/n 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,