diff options
| author | Luis Chamberlain <mcgrof@kernel.org> | 2020-05-29 05:19:08 +0000 |
|---|---|---|
| committer | Luis Chamberlain <mcgrof@kernel.org> | 2021-11-16 19:23:26 -0800 |
| commit | 80084262576dad57737fa04b203e1547ff7ad538 (patch) | |
| tree | 0c89f291e11c402e3b0c745b0e2dd53196d41c2b | |
| parent | fd3c007eaa6397a3be62a11761f620396bed2859 (diff) | |
| download | linux-next-80084262576dad57737fa04b203e1547ff7ad538.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.c | 10 | ||||
| -rw-r--r-- | include/linux/sysctl.h | 7 |
2 files changed, 17 insertions, 0 deletions
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 69cbd70bac1c6..3b13aa724bff1 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 sysctl_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..c384aa53b9002 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 sysctl_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) { |
