diff options
| author | Luis Chamberlain <mcgrof@kernel.org> | 2020-05-29 05:19:08 +0000 |
|---|---|---|
| committer | Luis Chamberlain <mcgrof@kernel.org> | 2021-11-16 18:24:57 -0800 |
| commit | 39ba9159476b6d86288f95f4cb62ad7055680395 (patch) | |
| tree | 0236fa0a0daf78f8dee315f8fcaa406a35750631 | |
| parent | f769932277d473a4413bd59bd39b8473c5627c83 (diff) | |
| download | linux-next-39ba9159476b6d86288f95f4cb62ad7055680395.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-- | include/linux/sysctl.h | 7 | ||||
| -rw-r--r-- | kernel/sysctl.c | 10 |
2 files changed, 17 insertions, 0 deletions
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) { diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 58724e5df524c..d894a5ff2b2c8 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -3322,6 +3322,16 @@ void __init register_sysctl_init(const char *path, struct ctl_table *table, } kmemleak_not_leak(hdr); } + +/* + * 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); +} #endif /* CONFIG_SYSCTL */ /* * No sense putting this after each symbol definition, twice, |
