aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis Chamberlain <mcgrof@kernel.org>2021-11-17 15:42:41 -0800
committerLuis Chamberlain <mcgrof@kernel.org>2021-11-17 15:50:59 -0800
commite727f07ea75eda3892a29abc81b503ebc2bbcaf1 (patch)
treef6654f3918735da4e9df6bad6b8e496dfc1011ba
parent1d8db35dee77c851dadb16011bb219e53ad5ce60 (diff)
downloadlinux-next-e727f07ea75eda3892a29abc81b503ebc2bbcaf1.tar.gz
sysctl: add helper to register a sysctl mount point
The way to create a subdirectory on top of sysctl_mount_point is a bit obscure, and *why* we do that even so more. Provide a helper which makes it clear why we do this. Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
-rw-r--r--fs/proc/proc_sysctl.c10
-rw-r--r--include/linux/sysctl.h7
2 files changed, 17 insertions, 0 deletions
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 69cbd70bac1c6..ab55cf2089d86 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -34,6 +34,16 @@ struct ctl_table sysctl_mount_point[] = {
{ }
};
+/*
+ * Used to create permanently empty directories to serve as mount points.
+ * There are some subtle but important permission checks this allows in the
+ * case of unprivileged mounts.
+ */
+struct ctl_table_header *register_sysctl_mount_point(const char *path)
+{
+ return register_sysctl(path, sysctl_mount_point);
+}
+
static bool is_empty_dir(struct ctl_table_header *head)
{
return head->ctl_table[0].child == sysctl_mount_point;
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 9a855a5cefa08..822691ab00ab3 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -207,6 +207,8 @@ void unregister_sysctl_table(struct ctl_table_header * table);
extern int sysctl_init(void);
extern void register_sysctl_init(const char *path, struct ctl_table *table,
const char *table_name);
+extern struct ctl_table_header *register_sysctl_mount_point(const char *path);
+
void do_sysctl_args(void);
extern int pwrsw_enabled;
@@ -222,6 +224,11 @@ static inline struct ctl_table_header *register_sysctl_table(struct ctl_table *
return NULL;
}
+static struct sysctl_header *register_sysctl_mount_point(const char *path)
+{
+ return NULL
+}
+
static inline struct ctl_table_header *register_sysctl_paths(
const struct ctl_path *path, struct ctl_table *table)
{