[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20220220060200.14205-1-tangmeng@uniontech.com>
Date: Sun, 20 Feb 2022 14:02:00 +0800
From: tangmeng <tangmeng@...ontech.com>
To: viro@...iv.linux.org.uk, mcgrof@...nel.org, keescook@...omium.org,
yzaikin@...gle.com
Cc: linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
nizhen@...ontech.com, zhanglianjie@...ontech.com,
nixiaoming@...wei.com, tangmeng <tangmeng@...ontech.com>
Subject: [PATCH 11/11] fs/userfaultfd: move userfaultfd sysctls to its own file
kernel/sysctl.c is a kitchen sink where everyone leaves their dirty
dishes, this makes it very difficult to maintain.
To help with this maintenance let's start by moving sysctls to places
where they actually belong. The proc sysctl maintainers do not want to
know what sysctl knobs you wish to add for your own piece of code, we
just care about the core logic.
All filesystem syctls now get reviewed by fs folks. This commit
follows the commit of fs, move the userfaultfd sysctls to its own file,
fs/userfdfault.c.
Signed-off-by: tangmeng <tangmeng@...ontech.com>
---
fs/userfaultfd.c | 23 ++++++++++++++++++++++-
include/linux/userfaultfd_k.h | 2 --
kernel/sysctl.c | 11 -----------
3 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index e26b10132d47..796d828dd2bb 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -30,7 +30,28 @@
#include <linux/security.h>
#include <linux/hugetlb.h>
-int sysctl_unprivileged_userfaultfd __read_mostly;
+static int sysctl_unprivileged_userfaultfd __read_mostly;
+#ifdef CONFIG_SYSCTL
+static struct ctl_table vm_userfaultfd_table[] = {
+ {
+ .procname = "unprivileged_userfaultfd",
+ .data = &sysctl_unprivileged_userfaultfd,
+ .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
+ .mode = 0644,
+ .proc_handler = proc_dointvec_minmax,
+ .extra1 = SYSCTL_ZERO,
+ .extra2 = SYSCTL_ONE,
+ },
+ { }
+};
+
+static __init int vm_userfaultfd_sysctls_init(void)
+{
+ register_sysctl_init("vm", vm_userfaultfd_table);
+ return 0;
+}
+late_initcall(vm_userfaultfd_sysctls_init);
+#endif /* CONFIG_SYSCTL */
static struct kmem_cache *userfaultfd_ctx_cachep __read_mostly;
diff --git a/include/linux/userfaultfd_k.h b/include/linux/userfaultfd_k.h
index 33cea484d1ad..0ece3026203f 100644
--- a/include/linux/userfaultfd_k.h
+++ b/include/linux/userfaultfd_k.h
@@ -33,8 +33,6 @@
#define UFFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK)
#define UFFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS)
-extern int sysctl_unprivileged_userfaultfd;
-
extern vm_fault_t handle_userfault(struct vm_fault *vmf, unsigned long reason);
/*
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 657b7bfe38f6..bc74f2bdaa52 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2407,17 +2407,6 @@ static struct ctl_table vm_table[] = {
.extra1 = (void *)&mmap_rnd_compat_bits_min,
.extra2 = (void *)&mmap_rnd_compat_bits_max,
},
-#endif
-#ifdef CONFIG_USERFAULTFD
- {
- .procname = "unprivileged_userfaultfd",
- .data = &sysctl_unprivileged_userfaultfd,
- .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
- .mode = 0644,
- .proc_handler = proc_dointvec_minmax,
- .extra1 = SYSCTL_ZERO,
- .extra2 = SYSCTL_ONE,
- },
#endif
{ }
};
--
2.20.1
Powered by blists - more mailing lists