linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Kaixiong Yu <yukaixiong@huawei.com>
To: <akpm@linux-foundation.org>, <mcgrof@kernel.org>,
	<joel.granados@kernel.org>
Cc: <ysato@users.sourceforge.jp>, <dalias@libc.org>,
	<glaubitz@physik.fu-berlin.de>, <luto@kernel.org>,
	<tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
	<dave.hansen@linux.intel.com>, <hpa@zytor.com>,
	<viro@zeniv.linux.org.uk>, <brauner@kernel.org>, <jack@suse.cz>,
	<kees@kernel.org>, <j.granados@samsung.com>,
	<willy@infradead.org>, <Liam.Howlett@oracle.com>,
	<vbabka@suse.cz>, <lorenzo.stoakes@oracle.com>,
	<trondmy@kernel.org>, <anna@kernel.org>, <chuck.lever@oracle.com>,
	<jlayton@kernel.org>, <neilb@suse.de>, <okorniev@redhat.com>,
	<Dai.Ngo@oracle.com>, <tom@talpey.com>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>,
	<paul@paul-moore.com>, <jmorris@namei.org>,
	<linux-sh@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-fsdevel@vger.kernel.org>, <linux-mm@kvack.org>,
	<linux-nfs@vger.kernel.org>, <netdev@vger.kernel.org>,
	<linux-security-module@vger.kernel.org>, <dhowells@redhat.com>,
	<haifeng.xu@shopee.com>, <baolin.wang@linux.alibaba.com>,
	<shikemeng@huaweicloud.com>, <dchinner@redhat.com>,
	<bfoster@redhat.com>, <souravpanda@google.com>,
	<hannes@cmpxchg.org>, <rientjes@google.com>,
	<pasha.tatashin@soleen.com>, <david@redhat.com>,
	<ryan.roberts@arm.com>, <ying.huang@intel.com>,
	<yang@os.amperecomputing.com>, <zev@bewilderbeest.net>,
	<serge@hallyn.com>, <vegard.nossum@oracle.com>,
	<wangkefeng.wang@huawei.com>
Subject: [PATCH v5 -next 13/16] x86: vdso: move the sysctl to arch/x86/entry/vdso/vdso32-setup.c
Date: Sat, 11 Jan 2025 15:07:48 +0800	[thread overview]
Message-ID: <20250111070751.2588654-14-yukaixiong@huawei.com> (raw)
In-Reply-To: <20250111070751.2588654-1-yukaixiong@huawei.com>

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 <yukaixiong@huawei.com>
Reviewed-by: Kees Cook <kees@kernel.org>
---
v5:
 - Accept Brian Gerst's suggestion to reduce the preprocessor
   condition "#elif (defined(CONFIG_X86_32) && !defined(CONFIG_UML))"
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..8894013eea1d 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 <linux/sysctl.h>
 
-static struct ctl_table abi_table2[] = {
+static const struct ctl_table vdso_table[] = {
 	{
+#ifdef CONFIG_X86_64
 		.procname	= "vsyscall32",
+#else
+		.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);
+#else
+	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,
-- 
2.34.1



  parent reply	other threads:[~2025-01-11  7:13 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-11  7:07 [PATCH v5 -next 00/16] sysctl: move sysctls from vm_table into its own files Kaixiong Yu
2025-01-11  7:07 ` [PATCH v5 -next 01/16] mm: vmstat: move sysctls to mm/vmstat.c Kaixiong Yu
2025-01-11  7:07 ` [PATCH v5 -next 02/16] mm: filemap: move sysctl to mm/filemap.c Kaixiong Yu
2025-01-11  7:07 ` [PATCH v5 -next 03/16] mm: swap: move sysctl to mm/swap.c Kaixiong Yu
2025-01-11  7:07 ` [PATCH v5 -next 04/16] mm: vmscan: move vmscan sysctls to mm/vmscan.c Kaixiong Yu
2025-01-11  7:07 ` [PATCH v5 -next 05/16] mm: util: move sysctls to mm/util.c Kaixiong Yu
2025-01-11  7:07 ` [PATCH v5 -next 06/16] mm: mmap: move sysctl to mm/mmap.c Kaixiong Yu
2025-01-11  7:07 ` [PATCH v5 -next 07/16] security: min_addr: move sysctl to security/min_addr.c Kaixiong Yu
2025-01-11  7:07 ` [PATCH v5 -next 08/16] mm: nommu: move sysctl to mm/nommu.c Kaixiong Yu
2025-01-11  7:07 ` [PATCH v5 -next 09/16] fs: fs-writeback: move sysctl to fs/fs-writeback.c Kaixiong Yu
2025-01-11  7:07 ` [PATCH v5 -next 10/16] fs: drop_caches: move sysctl to fs/drop_caches.c Kaixiong Yu
2025-01-11  7:07 ` [PATCH v5 -next 11/16] sunrpc: simplify rpcauth_cache_shrink_count() Kaixiong Yu
2025-01-17  9:55   ` Joel Granados
2025-01-11  7:07 ` [PATCH v5 -next 12/16] fs: dcache: move the sysctl to fs/dcache.c Kaixiong Yu
2025-01-11  7:07 ` Kaixiong Yu [this message]
2025-01-11  7:07 ` [PATCH v5 -next 14/16] sh: vdso: move the sysctl to arch/sh/kernel/vsyscall/vsyscall.c Kaixiong Yu
2025-01-11  7:07 ` [PATCH v5 -next 15/16] sysctl: remove the vm_table Kaixiong Yu
2025-01-11  7:07 ` [PATCH v5 -next 16/16] sysctl: remove unneeded include Kaixiong Yu
2025-01-13  5:10   ` Kalesh Anakkur Purayil
2025-01-13  6:59     ` yukaixiong
2025-01-14 13:50 ` [PATCH v5 -next 00/16] sysctl: move sysctls from vm_table into its own files Joel Granados
2025-01-15  1:53   ` yukaixiong
2025-01-16 10:03     ` Joel Granados
2025-02-05 12:39   ` Joel Granados

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250111070751.2588654-14-yukaixiong@huawei.com \
    --to=yukaixiong@huawei.com \
    --cc=Dai.Ngo@oracle.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=anna@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=bfoster@redhat.com \
    --cc=bp@alien8.de \
    --cc=brauner@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=dalias@libc.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=david@redhat.com \
    --cc=dchinner@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=edumazet@google.com \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=haifeng.xu@shopee.com \
    --cc=hannes@cmpxchg.org \
    --cc=hpa@zytor.com \
    --cc=j.granados@samsung.com \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=jmorris@namei.org \
    --cc=joel.granados@kernel.org \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=luto@kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=mingo@redhat.com \
    --cc=neilb@suse.de \
    --cc=netdev@vger.kernel.org \
    --cc=okorniev@redhat.com \
    --cc=pabeni@redhat.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=paul@paul-moore.com \
    --cc=rientjes@google.com \
    --cc=ryan.roberts@arm.com \
    --cc=serge@hallyn.com \
    --cc=shikemeng@huaweicloud.com \
    --cc=souravpanda@google.com \
    --cc=tglx@linutronix.de \
    --cc=tom@talpey.com \
    --cc=trondmy@kernel.org \
    --cc=vbabka@suse.cz \
    --cc=vegard.nossum@oracle.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=wangkefeng.wang@huawei.com \
    --cc=willy@infradead.org \
    --cc=yang@os.amperecomputing.com \
    --cc=ying.huang@intel.com \
    --cc=ysato@users.sourceforge.jp \
    --cc=zev@bewilderbeest.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox