sysctl: deprecate register_sysctl_paths()
Subsystems (11)
cover sysctl: deprecate register_sysctl_paths()
As we trim down the insane kernel/sysctl.c large array and move sysctls out we're looking to optimize the way we do syctl registrations so we deal with just flat entries so to make the registration code much easier to maintain and so it does not recurse. In dealing with some of these things it reminded us that we will eventually get to the point of just passing in the ARRAY_SIZE() we want, to get there we should strive to move away from the older callers that do need the recursion. Turns out tons of users don't need the recursion already so we can start converting those over.
register_sysctl_paths() can do recursion when its users have sysctl entries with directories and and then subdirectories with other entries. This *typically* was the use case in the large sysctl array in kernel/sysctl.c but as we trim that down we're phasing out the users that have subdirectories. This means that the code path that can do recursion is being mitigated over time and the code can be simplified as well.
There are however many existing users of register_sysctl_paths() which don't need to deal with subdirectories, and register_sysctl() and the init version register_sysctl_init() (used when you don't care for the initial return value / need to de-register) can create subdirectories for you if you have no entries in between. So just convert these users to the simpler APIs and deprecate out register_sysctl_paths().
The next step after this is to to start deprecating slowly the callers of register_sysctl_table(). I'll send a out second batch for those that apply on top of this.
Unless folks have an issue, I can offer to take these in the sysctl-next tree as we sweep these out, but I'm happy for folks to take these into their tree as well if they want. The only possible conflict would be timing, ie, if the final patch which removes the API call. That patch could also just wait another or two cycles later.
Luis Chamberlain (11):
proc_sysctl: update docs for __register_sysctl_table()
proc_sysctl: move helper which creates required subdirectories
sysctl: clarify register_sysctl_init() base directory order
apparmor: simplify sysctls with register_sysctl_init()
loadpin: simplify sysctls use with register_sysctl()
yama: simplfy sysctls with register_sysctl()
seccomp: simplify sysctls with register_sysctl_init()
kernel: pid_namespace: simplify sysctls with register_sysctl()
fs-verity: simplify sysctls with register_sysctl()
csky: simplify alignment sysctl registration
proc_sysctl: deprecate register_sysctl_paths()
arch/csky/abiv1/alignment.c | 15 +----- fs/proc/proc_sysctl.c | 95 +++++++++++++++++++------------------ fs/verity/signature.c | 9 +--- include/linux/sysctl.h | 11 ----- kernel/pid_namespace.c | 3 +- kernel/pid_sysctl.h | 3 +- kernel/seccomp.c | 15 +----- security/apparmor/lsm.c | 8 +--- security/loadpin/loadpin.c | 8 +--- security/yama/yama_lsm.c | 8 +--- 10 files changed, 56 insertions(+), 119 deletions(-)
Signature · 1 line
2.39.1
PATCH 1/11 proc_sysctl: update docs for __register_sysctl_table()
Update the docs for __register_sysctl_table() to make it clear no child entries can be passed. When the child is true these are non-leaf entries on the ctl table and sysctl treats these as directories. The point to __register_sysctl_table() is to deal only with directories not part of the ctl table where thay may riside, to be simple and avoid recursion.
While at it, hint towards using long on extra1 and extra2 later.
--- fs/proc/proc_sysctl.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
fs/proc/proc_sysctl.c +11 -3
@@ -1287,7 +1287,7 @@ static int insert_links(struct ctl_table_header *head)* __register_sysctl_table - register a leaf sysctl table * @set: Sysctl tree to register on * @path: The path to the directory the sysctl table is in. -* @table: the top-level table structure +* @table: the top-level table structure without any child * * Register a sysctl table hierarchy. @table should be a filled in ctl_table * array. A completely 0 filled entry terminates the table.
@@ -1308,9 +1308,12 @@ static int insert_links(struct ctl_table_header *head)* proc_handler - the text handler routine (described below) * * extra1, extra2 - extra pointers usable by the proc handler routines +* XXX: we should eventually modify these to use long min / max [0] +* [0] https://lkml.kernel.org/[email protected] * * Leaf nodes in the sysctl tree will be represented by a single file -* under /proc; non-leaf nodes will be represented by directories. +* under /proc; non-leaf nodes (where child is not NULL) are not allowed, +* sysctl_check_table() verifies this. * * There must be a proc_handler routine for any terminal nodes. * Several default handlers are available to cover common cases -
@@ -1352,7 +1355,7 @@ struct ctl_table_header *__register_sysctl_table(spin_lock (&sysctl_lock); dir = &set->dir; -/* Reference moved down the diretory tree get_subdir */ +/* Reference moved down the directory tree get_subdir */ dir->header.nreg++;spin_unlock (&sysctl_lock);
@@ -1369,6 +1372,11 @@ struct ctl_table_header *__register_sysctl_table(if (namelen ==0 )continue ; +/* +* namelen ensures if name is "foo/bar/yay" only foo is +* registered first. We traverse as if using mkdir -p and +* return a ctl_dir for the last directory entry. +*/ dir =get_subdir (dir, name, namelen);if (IS_ERR (dir)) goto fail;
Signature · 1 line
2.39.1
PATCH 2/11 proc_sysctl: move helper which creates required subdirectories
In reply to Luis ChamberlainMove the code which creates the subdirectories for a ctl table into a helper routine so to make it easier to review. Document the goal.
This creates no functional changes.
--- fs/proc/proc_sysctl.c | 56 ++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 24 deletions(-)
fs/proc/proc_sysctl.c +32 -24
@@ -1283,6 +1283,35 @@ static int insert_links(struct ctl_table_header *head)return err; } +/* Find the directory for the ctl_table. If one is not found create it. */ +static struct ctl_dir *sysctl_mkdir_p (struct ctl_dir *dir,const char *path) +{ +const char *name, *nextname; + +for (name = path; name; name = nextname) { +int namelen; + nextname =strchr (name,'/' ); +if (nextname) { + namelen = nextname - name; + nextname++; + }else { + namelen =strlen (name); + } +if (namelen ==0 ) +continue ; + +/* +* namelen ensures if name is "foo/bar/yay" only foo is +* registered first. We traverse as if using mkdir -p and +* return a ctl_dir for the last directory entry. +*/ + dir =get_subdir (dir, name, namelen); +if (IS_ERR (dir)) +break ; + } +return dir; +} +/** * __register_sysctl_table - register a leaf sysctl table * @set: Sysctl tree to register on
@@ -1334,7 +1363,6 @@ struct ctl_table_header *__register_sysctl_table( {struct ctl_table_root *root = set->dir.header.root;struct ctl_table_header *header; -const char *name, *nextname;struct ctl_dir *dir;struct ctl_table *entry;struct ctl_node *node;
@@ -1359,29 +1387,9 @@ struct ctl_table_header *__register_sysctl_table( dir->header.nreg++;spin_unlock (&sysctl_lock); -/* Find the directory for the ctl_table */ -for (name = path; name; name = nextname) { -int namelen; - nextname =strchr (name,'/' ); -if (nextname) { - namelen = nextname - name; - nextname++; - }else { - namelen =strlen (name); - } -if (namelen ==0 ) -continue ; - -/* -* namelen ensures if name is "foo/bar/yay" only foo is -* registered first. We traverse as if using mkdir -p and -* return a ctl_dir for the last directory entry. -*/ - dir =get_subdir (dir, name, namelen); -if (IS_ERR (dir)) - goto fail; - } - + dir =sysctl_mkdir_p (dir, path); +if (IS_ERR (dir)) + goto fail;spin_lock (&sysctl_lock);if (insert_header (dir, header)) goto fail_put_dir_locked;
Signature · 1 line
2.39.1
Re: [PATCH 02/11] proc_sysctl: move helper which creates required subdirectories
Quoted 7 lines · Luis Chamberlain
Move the code which creates the subdirectories for a ctl table into a helper routine so to make it easier to review. Document the goal.
This creates no functional changes.
Signed-off-by Luis Chamberlain <[email protected]>
Quoted 85 lines
--- fs/proc/proc_sysctl.c | 56 ++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 24 deletions(-)fs/proc/proc_sysctl.c +32
-24@@ -1283,6 +1283,35 @@ static int insert_links(struct ctl_table_header *head)return err; } +/* Find the directory for the ctl_table. If one is not found create it. */ +static struct ctl_dir *sysctl_mkdir_p (struct ctl_dir *dir,const char *path) +{ +const char *name, *nextname; + +for (name = path; name; name = nextname) { +int namelen; + nextname =strchr (name,'/' ); +if (nextname) { + namelen = nextname - name; + nextname++; + }else { + namelen =strlen (name); + } +if (namelen ==0 ) +continue ; + +/* +* namelen ensures if name is "foo/bar/yay" only foo is +* registered first. We traverse as if using mkdir -p and +* return a ctl_dir for the last directory entry. +*/ + dir =get_subdir (dir, name, namelen); +if (IS_ERR (dir)) +break ; + } +return dir; +} +/** * __register_sysctl_table - register a leaf sysctl table * @set: Sysctl tree to register on @@ -1334,7 +1363,6 @@ struct ctl_table_header *__register_sysctl_table( {struct ctl_table_root *root = set->dir.header.root;struct ctl_table_header *header; -const char *name, *nextname;struct ctl_dir *dir;struct ctl_table *entry;struct ctl_node *node;@@ -1359,29 +1387,9 @@ struct ctl_table_header *__register_sysctl_table( dir->header.nreg++;spin_unlock (&sysctl_lock); -/* Find the directory for the ctl_table */ -for (name = path; name; name = nextname) { -int namelen; - nextname =strchr (name,'/' ); -if (nextname) { - namelen = nextname - name; - nextname++; - }else { - namelen =strlen (name); - } -if (namelen ==0 ) -continue ; - -/* -* namelen ensures if name is "foo/bar/yay" only foo is -* registered first. We traverse as if using mkdir -p and -* return a ctl_dir for the last directory entry. -*/ - dir =get_subdir (dir, name, namelen); -if (IS_ERR (dir)) - goto fail; - } - + dir =sysctl_mkdir_p (dir, path); +if (IS_ERR (dir)) + goto fail;spin_lock (&sysctl_lock);if (insert_header (dir, header)) goto fail_put_dir_locked;
PATCH 3/11 sysctl: clarify register_sysctl_init() base directory order
In reply to Luis ChamberlainRelatively new docs which I added which hinted the base directories needed to be created before is wrong, remove that incorrect comment. This has been hinted before by Eric twice already [0] [1], I had just not verified that until now. Now that I've verified that updates the docs to relax the context described.
[0] https://lkml.kernel.org/r/[email protected]
[1] https://lkml.kernel.org/r/[email protected]
--- fs/proc/proc_sysctl.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
fs/proc/proc_sysctl.c +1 -4
@@ -1440,10 +1440,7 @@ EXPORT_SYMBOL(register_sysctl);* register_sysctl() failing on init are extremely low, and so for both reasons * this function does not return any error as it is used by initialization code. * -* Context: Can only be called after your respective sysctl base path has been -* registered. So for instance, most base directories are registered early on -* init before init levels are processed through proc_sys_init() and -* sysctl_init_bases(). +* Context: if your base directory does not exist it will be created for you. */ void __init __register_sysctl_init (const char *path,struct ctl_table *table,const char *table_name)
Signature · 1 line
2.39.1
PATCH 4/11 apparmor: simplify sysctls with register_sysctl_init()
In reply to Luis ChamberlainUsing register_sysctl_paths() is really only needed if you have subdirectories with entries. We can use the simple register_sysctl() instead.
--- security/apparmor/lsm.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
security/apparmor/lsm.c +1 -7
@@ -1764,11 +1764,6 @@ static int apparmor_dointvec(struct ctl_table *table, int write,return proc_dointvec (table, write, buffer, lenp, ppos); } -static struct ctl_path apparmor_sysctl_path[] = { - { .procname ="kernel" , }, - { } -}; -static struct ctl_table apparmor_sysctl_table[] = { { .procname ="unprivileged_userns_apparmor_policy" ,
@@ -1790,8 +1785,7 @@ static struct ctl_table apparmor_sysctl_table[] = {static int __init apparmor_init_sysctl (void ) { -return register_sysctl_paths (apparmor_sysctl_path, - apparmor_sysctl_table) ?0 : -ENOMEM ; +return register_sysctl ("kernel" , apparmor_sysctl_table) ?0 : -ENOMEM ; }#else static inline int apparmor_init_sysctl (void )
Signature · 1 line
2.39.1
Re: [PATCH 04/11] apparmor: simplify sysctls with register_sysctl_init()
Quoted 26 lines · Luis Chamberlain
Using
register_sysctl_paths()is really only needed if you have subdirectories with entries. We can use the simpleregister_sysctl()instead.Signed-off-by Luis Chamberlain <[email protected]>--- security/apparmor/lsm.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)security/apparmor/lsm.c +0
-5@@ -1764,11 +1764,6 @@ static int apparmor_dointvec(struct ctl_table *table, int write,return proc_dointvec (table, write, buffer, lenp, ppos); } -static struct ctl_path apparmor_sysctl_path[] = { - { .procname ="kernel" , }, - { } -}; -static struct ctl_table apparmor_sysctl_table[] = { { .procname ="unprivileged_userns_apparmor_policy" ,
security/apparmor/lsm.c static struct ctl_table apparmor_sysctl_table[] = { · line 1791
Quoted 9 lines
security/apparmor/lsm.c +1
-2@@ -1790,8 +1785,7 @@ static struct ctl_table apparmor_sysctl_table[] = {static int __init apparmor_init_sysctl (void ) { -return register_sysctl_paths (apparmor_sysctl_path, - apparmor_sysctl_table) ?0 : -ENOMEM ; +return register_sysctl ("kernel" , apparmor_sysctl_table) ?0 : -ENOMEM ; }#else static inline int apparmor_init_sysctl (void )
Re: [PATCH 04/11] apparmor: simplify sysctls with register_sysctl_init()
In reply to Luis ChamberlainQuoted 5 lines · Luis Chamberlain
Using
register_sysctl_paths()is really only needed if you have subdirectories with entries. We can use the simpleregister_sysctl()instead.Signed-off-by Luis Chamberlain <[email protected]>
Quoted 30 lines
--- security/apparmor/lsm.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)security/apparmor/lsm.c +1
-7@@ -1764,11 +1764,6 @@ static int apparmor_dointvec(struct ctl_table *table, int write,return proc_dointvec (table, write, buffer, lenp, ppos); } -static struct ctl_path apparmor_sysctl_path[] = { - { .procname ="kernel" , }, - { } -}; -static struct ctl_table apparmor_sysctl_table[] = { { .procname ="unprivileged_userns_apparmor_policy" ,@@ -1790,8 +1785,7 @@ static struct ctl_table apparmor_sysctl_table[] = {static int __init apparmor_init_sysctl (void ) { -return register_sysctl_paths (apparmor_sysctl_path, - apparmor_sysctl_table) ?0 : -ENOMEM ; +return register_sysctl ("kernel" , apparmor_sysctl_table) ?0 : -ENOMEM ; }#else static inline int apparmor_init_sysctl (void )
PATCH 5/11 loadpin: simplify sysctls use with register_sysctl()
In reply to Luis Chamberlainregister_sysctl_paths() is not required, we can just use register_sysctl() with the required path specified.
--- security/loadpin/loadpin.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
security/loadpin/loadpin.c +1 -7
@@ -52,12 +52,6 @@ static bool deny_reading_verity_digests;#endif #ifdef CONFIG_SYSCTL -static struct ctl_path loadpin_sysctl_path[] = { - { .procname = "kernel", }, - { .procname = "loadpin", }, - { } -}; - static struct ctl_table loadpin_sysctl_table[] = { { .procname = "enforce",
@@ -262,7 +256,7 @@ static int __init loadpin_init(void) enforce ? "" : "not ");parse_exclude ();#ifdef CONFIG_SYSCTL -if (!register_sysctl_paths (loadpin_sysctl_path, loadpin_sysctl_table)) +if (!register_sysctl ("kernel/loadpin" , loadpin_sysctl_table))pr_notice ("sysctl registration failed!\n" );#endif security_add_hooks (loadpin_hooks,ARRAY_SIZE (loadpin_hooks),"loadpin" );
Signature · 1 line
2.39.1
Re: [PATCH 05/11] loadpin: simplify sysctls use with register_sysctl()
Quoted 4 lines · Luis Chamberlain
register_sysctl_paths()is not required, we can just useregister_sysctl()with the required path specified.Signed-off-by Luis Chamberlain <[email protected]>
Signature · 1 line
Kees Cook
Re: [PATCH 05/11] loadpin: simplify sysctls use with register_sysctl()
In reply to Luis ChamberlainQuoted 4 lines · Luis Chamberlain
register_sysctl_paths()is not required, we can just useregister_sysctl()with the required path specified.Signed-off-by Luis Chamberlain <[email protected]>
Quoted 30 lines
--- security/loadpin/loadpin.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)security/loadpin/loadpin.c +1
-7@@ -52,12 +52,6 @@ static bool deny_reading_verity_digests;#endif #ifdef CONFIG_SYSCTL -static struct ctl_path loadpin_sysctl_path[] = { - { .procname = "kernel", }, - { .procname = "loadpin", }, - { } -}; - static struct ctl_table loadpin_sysctl_table[] = { { .procname = "enforce",@@ -262,7 +256,7 @@ static int __init loadpin_init(void) enforce ? "" : "not ");parse_exclude ();#ifdef CONFIG_SYSCTL -if (!register_sysctl_paths (loadpin_sysctl_path, loadpin_sysctl_table)) +if (!register_sysctl ("kernel/loadpin" , loadpin_sysctl_table))pr_notice ("sysctl registration failed!\n" );#endif security_add_hooks (loadpin_hooks,ARRAY_SIZE (loadpin_hooks),"loadpin" );
PATCH 6/11 yama: simplfy sysctls with register_sysctl()
In reply to Luis Chamberlainregister_sysctl_paths() is only need if you have directories with entries, simplify this by using register_sysctl().
--- security/yama/yama_lsm.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
security/yama/yama_lsm.c +1 -7
@@ -447,12 +447,6 @@ static int yama_dointvec_minmax(struct ctl_table *table, int write,static int max_scope =YAMA_SCOPE_NO_ATTACH ; -static struct ctl_path yama_sysctl_path[] = { - { .procname ="kernel" , }, - { .procname ="yama" , }, - { } -}; -static struct ctl_table yama_sysctl_table[] = { { .procname ="ptrace_scope" ,
@@ -467,7 +461,7 @@ static struct ctl_table yama_sysctl_table[] = { };static void __init yama_init_sysctl (void ) { -if (!register_sysctl_paths (yama_sysctl_path, yama_sysctl_table)) +if (!register_sysctl ("kernel/yama" , yama_sysctl_table))panic ("Yama: sysctl registration failed.\n" ); }#else
Signature · 1 line
2.39.1
Re: [PATCH 06/11] yama: simplfy sysctls with register_sysctl()
Quoted 4 lines · Luis Chamberlain
register_sysctl_paths()is only need if you have directories with entries, simplify this by usingregister_sysctl().Signed-off-by Luis Chamberlain <[email protected]>
Signature · 1 line
Kees Cook
PATCH 7/11 seccomp: simplify sysctls with register_sysctl_init()
In reply to Luis Chamberlainregister_sysctl_paths() is only needed if you have childs (directories) with entries. Just use register_sysctl_init() as it also does the kmemleak check for you.
--- kernel/seccomp.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
kernel/seccomp.c +1 -14
@@ -2368,12 +2368,6 @@ static int seccomp_actions_logged_handler(struct ctl_table *ro_table, int write,return ret; } -static struct ctl_path seccomp_sysctl_path[] = { - { .procname ="kernel" , }, - { .procname ="seccomp" , }, - { } -}; -static struct ctl_table seccomp_sysctl_table[] = { { .procname ="actions_avail" ,
@@ -2392,14 +2386,7 @@ static struct ctl_table seccomp_sysctl_table[] = {static int __init seccomp_sysctl_init (void ) { -struct ctl_table_header *hdr; - - hdr =register_sysctl_paths (seccomp_sysctl_path, seccomp_sysctl_table); -if (!hdr) -pr_warn ("sysctl registration failed\n" ); -else -kmemleak_not_leak (hdr); - +register_sysctl_init ("kernel/seccomp" , seccomp_sysctl_table);return 0 ; }
Signature · 1 line
2.39.1
Re: [PATCH 07/11] seccomp: simplify sysctls with register_sysctl_init()
Quoted 5 lines · Luis Chamberlain
register_sysctl_paths()is only needed if you have childs (directories) with entries. Just useregister_sysctl_init()as it also does the kmemleak check for you.Signed-off-by Luis Chamberlain <[email protected]>
Signature · 1 line
Kees Cook
PATCH 8/11 kernel: pid_namespace: simplify sysctls with register_sysctl()
In reply to Luis Chamberlainregister_sysctl_paths() is only required if your child (directories) have entries and pid_namespace does not. So use register_sysctl_init() instead where we don't care about the return value and use register_sysctl() where we do.
--- kernel/pid_namespace.c | 3 +-- kernel/pid_sysctl.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
kernel/pid_namespace.c +1 -2
@@ -314,7 +314,6 @@ static struct ctl_table pid_ns_ctl_table[] = { }, { } }; -static struct ctl_path kern_path[] = { { .procname ="kernel" , }, { } };#endif /* CONFIG_CHECKPOINT_RESTORE */ int reboot_pid_ns (struct pid_namespace *pid_ns,int cmd)
@@ -473,7 +472,7 @@ static __init int pid_namespaces_init(void) pid_ns_cachep =KMEM_CACHE (pid_namespace,SLAB_PANIC |SLAB_ACCOUNT );#ifdef CONFIG_CHECKPOINT_RESTORE -register_sysctl_paths (kern_path, pid_ns_ctl_table); +register_sysctl_init ("kernel" , pid_ns_ctl_table);#endif register_pid_ns_sysctl_table_vm ();
kernel/pid_sysctl.h +1 -2
@@ -46,10 +46,9 @@ static struct ctl_table pid_ns_ctl_table_vm[] = { }, { } }; -static struct ctl_path vm_path[] = { { .procname ="vm" , }, { } };static inline void register_pid_ns_sysctl_table_vm (void ) { -register_sysctl_paths (vm_path, pid_ns_ctl_table_vm); +register_sysctl ("vm" , pid_ns_ctl_table_vm); }#else static inline void initialize_memfd_noexec_scope (struct pid_namespace *ns) {}
Signature · 1 line
2.39.1
Re: [PATCH 08/11] kernel: pid_namespace: simplify sysctls with register_sysctl()
Quoted 50 lines · Luis Chamberlain
register_sysctl_paths()is only required if your child (directories) have entries andpid_namespacedoes not. So useregister_sysctl_init()instead where we don't care about the return value and useregister_sysctl()where we do.Signed-off-by Luis Chamberlain <[email protected]>--- kernel/pid_namespace.c | 3 +-- kernel/pid_sysctl.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)kernel/pid_namespace.c +1
-2@@ -314,7 +314,6 @@ static struct ctl_table pid_ns_ctl_table[] = { }, { } }; -static struct ctl_path kern_path[] = { { .procname ="kernel" , }, { } };#endif /* CONFIG_CHECKPOINT_RESTORE */ int reboot_pid_ns (struct pid_namespace *pid_ns,int cmd)@@ -473,7 +472,7 @@ static __init int pid_namespaces_init(void) pid_ns_cachep =KMEM_CACHE (pid_namespace,SLAB_PANIC |SLAB_ACCOUNT );#ifdef CONFIG_CHECKPOINT_RESTORE -register_sysctl_paths (kern_path, pid_ns_ctl_table); +register_sysctl_init ("kernel" , pid_ns_ctl_table);#endif register_pid_ns_sysctl_table_vm ();kernel/pid_sysctl.h +1
-3@@ -46,10 +46,9 @@ static struct ctl_table pid_ns_ctl_table_vm[] = { }, { } }; -static struct ctl_path vm_path[] = { { .procname ="vm" , }, { } };static inline void register_pid_ns_sysctl_table_vm (void ) { -register_sysctl_paths (vm_path, pid_ns_ctl_table_vm); +register_sysctl ("vm" , pid_ns_ctl_table_vm); }#else static inline void initialize_memfd_noexec_scope (struct pid_namespace *ns) {} --
Quoted 2 lines
2.39.1
Re: [PATCH 08/11] kernel: pid_namespace: simplify sysctls with register_sysctl()
Quoted 5 lines · Jeff Xu
Quoted 3 lines · Luis Chamberlain
kernel/pid_sysctl.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)Acked-by Jeff Xu <[email protected]>
Andrew, kernel/pid_sysctl.h is new, not on v6.3-rc1 and so I cannot carry this on sysctl-next. Can you carry this patch on your tree?
I see Eric Biggers already took in the fs-verity patch, so I will drop that from my queue.
I can take the rest in this series.
I will also hold off on the last patch which deprecates the routine register_sysctl_paths() until after say the first part of the merge window.
This will allow all of our trees to work on linux-next without conflict.
Let me know if this is OK with you and Eric!
Luis
Re: [PATCH 08/11] kernel: pid_namespace: simplify sysctls with register_sysctl()
Quoted 2 lines · On Thu, 9 Mar 2023 14:11:27 -0800 Luis Chamberlain <[email protected]> wrote:
Andrew,
kernel/pid_sysctl.his new, not on v6.3-rc1 and so I cannot carry this on sysctl-next. Can you carry this patch on your tree?
Sure, no probs.
Re: [PATCH 08/11] kernel: pid_namespace: simplify sysctls with register_sysctl()
Quoted 6 lines · Andrew Morton
Quoted 2 lines · On Thu, 9 Mar 2023 14:11:27 -0800 Luis Chamberlain <[email protected]> wrote:
Andrew,
kernel/pid_sysctl.his new, not on v6.3-rc1 and so I cannot carry this on sysctl-next. Can you carry this patch on your tree?Sure, no probs.
Andrew, this one patch will have to go through your tree as kernel/pid_sysctl.h only exist on your tree. I'll drop it on my end!
Thanks!
Luis
Eric Biggers
maintainerRe: [PATCH 08/11] kernel: pid_namespace: simplify sysctls with register_sysctl()
In reply to Luis ChamberlainQuoted 15 lines · Luis Chamberlain
Quoted 5 lines · Jeff Xu
Quoted 3 lines · Luis Chamberlain
kernel/pid_sysctl.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)Acked-by Jeff Xu <[email protected]>Andrew,
kernel/pid_sysctl.his new, not on v6.3-rc1 and so I cannot carry this on sysctl-next. Can you carry this patch on your tree?I see Eric Biggers already took in the fs-verity patch, so I will drop that from my queue.
I can take the rest in this series.
Quoted 8 lines
I will also hold off on the last patch which deprecates the routine
register_sysctl_paths()until after say the first part of the merge window.This will allow all of our trees to work on linux-next without conflict.
Let me know if this is OK with you and Eric!
That's fine with me. I applied the fsverity patch based on your cover letter that said it was okay
(https://lore.kernel.org/r/[email protected]). If you'd like to take all the patches so that you can remove register_sysctl_paths() in the same cycle, that would be fine too; it's up to you.
- Eric
Re: [PATCH 08/11] kernel: pid_namespace: simplify sysctls with register_sysctl()
Quoted 20 lines · Eric Biggers
Quoted 19 lines · Luis Chamberlain
Quoted 5 lines · Jeff Xu
Quoted 3 lines · Luis Chamberlain
kernel/pid_sysctl.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)Acked-by Jeff Xu <[email protected]>Andrew,
kernel/pid_sysctl.his new, not on v6.3-rc1 and so I cannot carry this on sysctl-next. Can you carry this patch on your tree?I see Eric Biggers already took in the fs-verity patch, so I will drop that from my queue.
I can take the rest in this series.
I will also hold off on the last patch which deprecates the routine
register_sysctl_paths()until after say the first part of the merge window.
Quoted 8 lines
Quoted 4 lines
This will allow all of our trees to work on linux-next without conflict.
Let me know if this is OK with you and Eric!
That's fine with me. I applied the fsverity patch based on your cover letter that said it was okay
(https://lore.kernel.org/r/[email protected]).
Yeah it perfectly fine!
Quoted 3 lines
If you'd
like to take all the patches so that you can removeregister_sysctl_paths()in the same cycle, that would be fine too; it's up to you.
Nah it's fine, no rush in this. One small step at a time.
Luis
PATCH 9/11 fs-verity: simplify sysctls with register_sysctl()
In reply to Luis Chamberlainregister_sysctl_paths() is only needed if your child (directories) have entries but this does not so just use register_sysctl() so to do away with the path specification.
--- fs/verity/signature.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
fs/verity/signature.c +1 -8
@@ -88,12 +88,6 @@ int fsverity_verify_signature(const struct fsverity_info *vi, #ifdef CONFIG_SYSCTL static struct ctl_table_header *fsverity_sysctl_header; -static const struct ctl_path fsverity_sysctl_path[] = { - { .procname = "fs", }, - { .procname = "verity", }, - { } -}; - static struct ctl_table fsverity_sysctl_table[] = { { .procname = "require_signatures",
@@ -109,8 +103,7 @@ static struct ctl_table fsverity_sysctl_table[] = {static int __init fsverity_sysctl_init (void ) { - fsverity_sysctl_header =register_sysctl_paths (fsverity_sysctl_path, - fsverity_sysctl_table); + fsverity_sysctl_header =register_sysctl ("fs/verity" , fsverity_sysctl_table);if (!fsverity_sysctl_header) {pr_err ("sysctl registration failed!\n" );return -ENOMEM ;
Signature · 1 line
2.39.1
Re: [PATCH 09/11] fs-verity: simplify sysctls with register_sysctl()
Quoted 8 lines · Luis Chamberlain
register_sysctl_paths()is only needed if your child (directories) have entries but this does not so just useregister_sysctl()so to do away with the path specification.Signed-off-by Luis Chamberlain <[email protected]>--- fs/verity/signature.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
Applied to https://git.kernel.org/pub/scm/fs/fsverity/linux.git/log/?h=for-next
- Eric
PATCH 10/11 csky: simplify alignment sysctl registration
In reply to Luis ChamberlainUsing register_sysctl_paths() is only required if we are using leafs with entries but all we are doing is creates leafs with just one leaf and then entries and register_sysctl_init() works well with that already.
The 555 permission is already retained by the new_dir() proc sysctl directory creator.
--- arch/csky/abiv1/alignment.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
arch/csky/abiv1/alignment.c +1 -14
@@ -332,22 +332,9 @@ static struct ctl_table alignment_tbl[5] = { {} }; -static struct ctl_table sysctl_table[2 ] = { - { - .procname ="csky_alignment" , - .mode =0555 , - .child = alignment_tbl}, - {} -}; - -static struct ctl_path sysctl_path[2 ] = { - {.procname ="csky" }, - {} -}; -static int __init csky_alignment_init (void ) { -register_sysctl_paths (sysctl_path, sysctl_table); +register_sysctl_init ("csky/csky_alignment" , alignment_tbl);return 0 ; }
Signature · 1 line
2.39.1
PATCH 11/11 proc_sysctl: deprecate register_sysctl_paths()
In reply to Luis ChamberlainNow that all users are removed, drop the export for register_sysctl_paths()
--- fs/proc/proc_sysctl.c | 30 +++++++++--------------------- include/linux/sysctl.h | 11 ----------- 2 files changed, 9 insertions(+), 32 deletions(-)
fs/proc/proc_sysctl.c +9 -21
@@ -1486,6 +1486,7 @@ static int count_subheaders(struct ctl_table *table)return nr_subheaders + has_files; } +/* Note: this can recurse and call itself when dealing with subdirectories */ static int register_leaf_sysctl_tables (const char *path,char *pos,struct ctl_table_header ***subheader,struct ctl_table_set *set,struct ctl_table *table)
@@ -1571,9 +1572,10 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,* Register a sysctl table hierarchy. @table should be a filled in ctl_table * array. A completely 0 filled entry terminates the table. * -* See __register_sysctl_table for more details. +* See __register_sysctl_table for more details. This routine can +* recurse by having register_leaf_sysctl_tables() call itself. */ -struct ctl_table_header *__register_sysctl_paths ( +static struct ctl_table_header *__register_sysctl_paths (struct ctl_table_set *set,const struct ctl_path *path,struct ctl_table *table) {
@@ -1613,6 +1615,7 @@ struct ctl_table_header *__register_sysctl_paths( subheader = subheaders; header->ctl_table_arg = ctl_table_arg; +/* this can recurse */ if (register_leaf_sysctl_tables (new_path, pos, &subheader, set, table)) goto err_register_leaves;
@@ -1635,37 +1638,22 @@ struct ctl_table_header *__register_sysctl_paths( }/** -* register_sysctl_paths - register a sysctl table hierarchy -* @path: The path to the directory the sysctl table is in. +* register_sysctl_table - register a sysctl table hierarchy * @table: the top-level table structure * * Register a sysctl table hierarchy. @table should be a filled in ctl_table * array. A completely 0 filled entry terminates the table. * * See __register_sysctl_paths for more details. -*/ -struct ctl_table_header *register_sysctl_paths (const struct ctl_path *path, -struct ctl_table *table) -{ -return __register_sysctl_paths (&sysctl_table_root.default_set, - path, table); -} -EXPORT_SYMBOL (register_sysctl_paths); - -/** -* register_sysctl_table - register a sysctl table hierarchy -* @table: the top-level table structure -* -* Register a sysctl table hierarchy. @table should be a filled in ctl_table -* array. A completely 0 filled entry terminates the table. * -* See register_sysctl_paths for more details. +* This is a deprecated compatibility wrapper. You should avoid adding new +* users of this into the kernel. */ struct ctl_table_header *register_sysctl_table (struct ctl_table *table) {static const struct ctl_path null_path[] = { {} }; -return register_sysctl_paths (null_path, table); +return __register_sysctl_paths (&sysctl_table_root.default_set, null_path, table); }EXPORT_SYMBOL (register_sysctl_table);
include/linux/sysctl.h +0 -11
@@ -221,13 +221,8 @@ extern void retire_sysctl_set(struct ctl_table_set *set);struct ctl_table_header *__register_sysctl_table (struct ctl_table_set *set,const char *path,struct ctl_table *table); -struct ctl_table_header *__register_sysctl_paths ( -struct ctl_table_set *set, -const struct ctl_path *path,struct ctl_table *table);struct ctl_table_header *register_sysctl (const char *path,struct ctl_table *table);struct ctl_table_header *register_sysctl_table (struct ctl_table * table); -struct ctl_table_header *register_sysctl_paths (const struct ctl_path *path, -struct ctl_table *table);void unregister_sysctl_table (struct ctl_table_header * table);
@@ -277,12 +272,6 @@ static inline struct ctl_table_header *register_sysctl_mount_point(const char *preturn NULL ; } -static inline struct ctl_table_header *register_sysctl_paths ( -const struct ctl_path *path,struct ctl_table *table) -{ -return NULL ; -} -static inline struct ctl_table_header *register_sysctl (const char *path,struct ctl_table *table) {return NULL ;
Signature · 1 line
2.39.1
Eric Biggers
maintainerRe: [PATCH 11/11] proc_sysctl: deprecate register_sysctl_paths()
Quoted 19 lines · Luis Chamberlain
include/linux/sysctl.h +0
-5@@ -221,13 +221,8 @@ extern void retire_sysctl_set(struct ctl_table_set *set);struct ctl_table_header *__register_sysctl_table (struct ctl_table_set *set,const char *path,struct ctl_table *table); -struct ctl_table_header *__register_sysctl_paths ( -struct ctl_table_set *set, -const struct ctl_path *path,struct ctl_table *table);struct ctl_table_header *register_sysctl (const char *path,struct ctl_table *table);struct ctl_table_header *register_sysctl_table (struct ctl_table * table); -struct ctl_table_header *register_sysctl_paths (const struct ctl_path *path, -struct ctl_table *table);void unregister_sysctl_table (struct ctl_table_header * table);
include/linux/sysctl.h static inline struct ctl_table_header *register_sysctl_mount_point(const char *p · line 285
Quoted 9 lines
include/linux/sysctl.h +0
-6@@ -277,12 +272,6 @@ static inline struct ctl_table_header *register_sysctl_mount_point(const char *preturn NULL ; } -static inline struct ctl_table_header *register_sysctl_paths ( -const struct ctl_path *path,struct ctl_table *table) -{ -return NULL ; -} -
Seems that this patch should be titled "remove register_sysctl_paths()", not "deprecate register_sysctl_paths()"?
- Eric
Re: [PATCH 11/11] proc_sysctl: deprecate register_sysctl_paths()
Quoted 23 lines · Eric Biggers
Quoted 22 lines · Luis Chamberlain
include/linux/sysctl.h +0
-5@@ -221,13 +221,8 @@ extern void retire_sysctl_set(struct ctl_table_set *set);struct ctl_table_header *__register_sysctl_table (struct ctl_table_set *set,const char *path,struct ctl_table *table); -struct ctl_table_header *__register_sysctl_paths ( -struct ctl_table_set *set, -const struct ctl_path *path,struct ctl_table *table);struct ctl_table_header *register_sysctl (const char *path,struct ctl_table *table);struct ctl_table_header *register_sysctl_table (struct ctl_table * table); -struct ctl_table_header *register_sysctl_paths (const struct ctl_path *path, -struct ctl_table *table);void unregister_sysctl_table (struct ctl_table_header * table);@@ -277,12 +272,6 @@ static inline struct ctl_table_header *register_sysctl_mount_point(const char *preturn NULL ; }
Quoted 9 lines
include/linux/sysctl.h static inline struct ctl_table_header *register_sysctl_mount_point(const char *p · line 285
Quoted 6 lines
include/linux/sysctl.h +0
-6-static inline struct ctl_table_header *register_sysctl_paths ( -const struct ctl_path *path,struct ctl_table *table) -{ -return NULL ; -} -Seems that this patch should be titled "remove
register_sysctl_paths()", not "deprecateregister_sysctl_paths()"?
Good call! Will adjust.
Luis