fs: move binfmt_misc sysctl to its own file as built-in
Subsystems (2)
PATCH v2 1/1 fs: move binfmt_misc sysctl to its own file as built-in
This is the second attempt to move binfmt_misc sysctl to its own file. The issue with the first move was that we moved the binfmt_misc sysctls to the binfmt_misc module, but the way things work on some systems is that the binfmt_misc module will load if the sysctl is present. If we don't force the sysctl on, the module won't load. The proper thing to do is to register the sysctl if the module was built or the binfmt_misc code was built-in, we do this by using the helper IS_ENABLED() now.
The rationale for the move:
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.
This moves the binfmt_misc sysctl to its own file to help remove clutter from kernel/sysctl.c.
---
Andrew,
If we get tested-by from Domenico and Tong I think this is ready.
Demenico, Tong, can you please test this patch? Linus' tree should already have all the prior work reverted as Domenico requested so this starts fresh.
fs/file_table.c | 2 ++ kernel/sysctl.c | 13 ------------- 2 files changed, 2 insertions(+), 13 deletions(-)
fs/file_table.c +2 -0
@@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[] = {static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) +register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; }fs_initcall (init_fs_stat_sysctls);
kernel/sysctl.c +0 -13
@@ -2735,17 +2735,6 @@ static struct ctl_table vm_table[] = { { } }; -static struct ctl_table fs_table[] = { -#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) - { - .procname = "binfmt_misc", - .mode = 0555, - .child = sysctl_mount_point, - }, -#endif - { } -}; - static struct ctl_table debug_table[] = { #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE {
@@ -2765,7 +2754,6 @@ static struct ctl_table dev_table[] = {DECLARE_SYSCTL_BASE (kernel, kern_table);DECLARE_SYSCTL_BASE (vm, vm_table); -DECLARE_SYSCTL_BASE (fs, fs_table);DECLARE_SYSCTL_BASE (debug, debug_table);DECLARE_SYSCTL_BASE (dev, dev_table);
@@ -2773,7 +2761,6 @@ int __init sysctl_init_bases(void) {register_sysctl_base (kernel);register_sysctl_base (vm); -register_sysctl_base (fs);register_sysctl_base (debug);register_sysctl_base (dev);
Signature · 1 line
2.34.1
Quoted 94 lines · Luis Chamberlain
This is the second attempt to move
binfmt_miscsysctl to its own file. The issue with the first move was that we moved thebinfmt_miscsysctls to thebinfmt_miscmodule, but the way things work on some systems is that thebinfmt_miscmodule will load if the sysctl is present. If we don't force the sysctl on, the module won't load. The proper thing to do is to register the sysctl if the module was built or thebinfmt_misccode was built-in, we do this by using the helperIS_ENABLED()now.The rationale for the move:
kernel/sysctl.cis 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.
This moves the
binfmt_miscsysctl to its own file to help remove clutter fromkernel/sysctl.c.Cc Domenico Andreoli <[email protected]>Cc Tong Zhang <[email protected]>Reviewed-by Tong Zhang <[email protected]>Signed-off-by Luis Chamberlain <[email protected]>---
Andrew,
If we get tested-by from Domenico and Tong I think this is ready.
Demenico, Tong, can you please test this patch? Linus' tree should already have all the prior work reverted as Domenico requested so this starts fresh.
fs/file_table.c | 2 ++ kernel/sysctl.c | 13 ------------- 2 files changed, 2 insertions(+), 13 deletions(-)fs/file_table.c +2
-0@@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[] = {static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) +register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; }fs_initcall (init_fs_stat_sysctls);kernel/sysctl.c +0
-14@@ -2735,17 +2735,6 @@ static struct ctl_table vm_table[] = { { } }; -static struct ctl_table fs_table[] = { -#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) - { - .procname = "binfmt_misc", - .mode = 0555, - .child = sysctl_mount_point, - }, -#endif - { } -}; - static struct ctl_table debug_table[] = { #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE {@@ -2765,7 +2754,6 @@ static struct ctl_table dev_table[] = {DECLARE_SYSCTL_BASE (kernel, kern_table);DECLARE_SYSCTL_BASE (vm, vm_table); -DECLARE_SYSCTL_BASE (fs, fs_table);DECLARE_SYSCTL_BASE (debug, debug_table);DECLARE_SYSCTL_BASE (dev, dev_table);@@ -2773,7 +2761,6 @@ int __init sysctl_init_bases(void) {register_sysctl_base (kernel);register_sysctl_base (vm); -register_sysctl_base (fs);register_sysctl_base (debug);register_sysctl_base (dev); --
Quoted 2 lines
2.34.1
Hi Luis,
Thanks for posting.
I checked the master branch just now and the fix is already in, see commit b42bc9a3c511("Fix regression due to "fs: move binfmt_misc sysctl to its own file"")
I have tested it yesterday on a debian machine and it appears to be ok.
- Tong
Quoted 95 lines · Tong Zhang
Quoted 93 lines · Luis Chamberlain
This is the second attempt to move
binfmt_miscsysctl to its own file. The issue with the first move was that we moved thebinfmt_miscsysctls to thebinfmt_miscmodule, but the way things work on some systems is that thebinfmt_miscmodule will load if the sysctl is present. If we don't force the sysctl on, the module won't load. The proper thing to do is to register the sysctl if the module was built or thebinfmt_misccode was built-in, we do this by using the helperIS_ENABLED()now.The rationale for the move:
kernel/sysctl.cis 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.
This moves the
binfmt_miscsysctl to its own file to help remove clutter fromkernel/sysctl.c.Cc Domenico Andreoli <[email protected]>Cc Tong Zhang <[email protected]>Reviewed-by Tong Zhang <[email protected]>Signed-off-by Luis Chamberlain <[email protected]>---
Andrew,
If we get tested-by from Domenico and Tong I think this is ready.
Demenico, Tong, can you please test this patch? Linus' tree should already have all the prior work reverted as Domenico requested so this starts fresh.
fs/file_table.c | 2 ++ kernel/sysctl.c | 13 ------------- 2 files changed, 2 insertions(+), 13 deletions(-)fs/file_table.c +2
-0@@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[] = {static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) +register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; }fs_initcall (init_fs_stat_sysctls);kernel/sysctl.c +0
-13@@ -2735,17 +2735,6 @@ static struct ctl_table vm_table[] = { { } }; -static struct ctl_table fs_table[] = { -#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) - { - .procname = "binfmt_misc", - .mode = 0555, - .child = sysctl_mount_point, - }, -#endif - { } -}; - static struct ctl_table debug_table[] = { #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE {@@ -2765,7 +2754,6 @@ static struct ctl_table dev_table[] = {DECLARE_SYSCTL_BASE (kernel, kern_table);DECLARE_SYSCTL_BASE (vm, vm_table); -DECLARE_SYSCTL_BASE (fs, fs_table);DECLARE_SYSCTL_BASE (debug, debug_table);DECLARE_SYSCTL_BASE (dev, dev_table);@@ -2773,7 +2761,6 @@ int __init sysctl_init_bases(void) {register_sysctl_base (kernel);register_sysctl_base (vm); -register_sysctl_base (fs);register_sysctl_base (debug);register_sysctl_base (dev);
Quoted 11 lines
Quoted 3 lines
--
2.34.1Hi Luis,
Thanks for posting.
I checked the master branch just now and the fix is already in, see commitb42bc9a3c511("Fix regression due to "fs: move binfmt_misc sysctl to its own file"")
I have tested it yesterday on a debian machine and it appears to be ok.
- Tong
One thing I forget to mention is that since we removed binfmt related stuff from kernel/sysctl.c
#include<linux/binfmts.h> is not needed anymore and can be removed.
kernel/sysctl.c +0 -1
@@ -59,7 +59,6 @@#include <linux/oom.h> #include <linux/kmod.h> #include <linux/capability.h> -#include <linux/binfmts.h> #include <linux/sched/sysctl.h> #include <linux/kexec.h> #include <linux/bpf.h>
- Tong
Quoted 94 lines · Tong Zhang
Quoted 93 lines · Luis Chamberlain
This is the second attempt to move
binfmt_miscsysctl to its own file. The issue with the first move was that we moved thebinfmt_miscsysctls to thebinfmt_miscmodule, but the way things work on some systems is that thebinfmt_miscmodule will load if the sysctl is present. If we don't force the sysctl on, the module won't load. The proper thing to do is to register the sysctl if the module was built or thebinfmt_misccode was built-in, we do this by using the helperIS_ENABLED()now.The rationale for the move:
kernel/sysctl.cis 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.
This moves the
binfmt_miscsysctl to its own file to help remove clutter fromkernel/sysctl.c.Cc Domenico Andreoli <[email protected]>Cc Tong Zhang <[email protected]>Reviewed-by Tong Zhang <[email protected]>Signed-off-by Luis Chamberlain <[email protected]>---
Andrew,
If we get tested-by from Domenico and Tong I think this is ready.
Demenico, Tong, can you please test this patch? Linus' tree should already have all the prior work reverted as Domenico requested so this starts fresh.
fs/file_table.c | 2 ++ kernel/sysctl.c | 13 ------------- 2 files changed, 2 insertions(+), 13 deletions(-)fs/file_table.c +2
-0@@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[] = {static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) +register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; }fs_initcall (init_fs_stat_sysctls);kernel/sysctl.c +0
-13@@ -2735,17 +2735,6 @@ static struct ctl_table vm_table[] = { { } }; -static struct ctl_table fs_table[] = { -#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) - { - .procname = "binfmt_misc", - .mode = 0555, - .child = sysctl_mount_point, - }, -#endif - { } -}; - static struct ctl_table debug_table[] = { #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE {@@ -2765,7 +2754,6 @@ static struct ctl_table dev_table[] = {DECLARE_SYSCTL_BASE (kernel, kern_table);DECLARE_SYSCTL_BASE (vm, vm_table); -DECLARE_SYSCTL_BASE (fs, fs_table);DECLARE_SYSCTL_BASE (debug, debug_table);DECLARE_SYSCTL_BASE (dev, dev_table);@@ -2773,7 +2761,6 @@ int __init sysctl_init_bases(void) {register_sysctl_base (kernel);register_sysctl_base (vm); -register_sysctl_base (fs);register_sysctl_base (debug);register_sysctl_base (dev);
Quoted 10 lines
Quoted 3 lines
--
2.34.1Hi Luis,
Thanks for posting.
I checked the master branch just now and the fix is already in, see commitb42bc9a3c511("Fix regression due to "fs: move binfmt_misc sysctl to its own file"")
I have tested it yesterday on a debian machine and it appears to be ok.
The "fix" was to vert the original effort. This patch continues with the effort and does it properly. As such it is a change which needs to be tested. I'd appreciate if you can test.
Luis
Tong Zhang
Tested-byQuoted 107 lines · Luis Chamberlain
Quoted 94 lines · Tong Zhang
Quoted 93 lines · Luis Chamberlain
This is the second attempt to move
binfmt_miscsysctl to its own file. The issue with the first move was that we moved thebinfmt_miscsysctls to thebinfmt_miscmodule, but the way things work on some systems is that thebinfmt_miscmodule will load if the sysctl is present. If we don't force the sysctl on, the module won't load. The proper thing to do is to register the sysctl if the module was built or thebinfmt_misccode was built-in, we do this by using the helperIS_ENABLED()now.The rationale for the move:
kernel/sysctl.cis 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.
This moves the
binfmt_miscsysctl to its own file to help remove clutter fromkernel/sysctl.c.Cc Domenico Andreoli <[email protected]>Cc Tong Zhang <[email protected]>Reviewed-by Tong Zhang <[email protected]>Signed-off-by Luis Chamberlain <[email protected]>---
Andrew,
If we get tested-by from Domenico and Tong I think this is ready.
Demenico, Tong, can you please test this patch? Linus' tree should already have all the prior work reverted as Domenico requested so this starts fresh.
fs/file_table.c | 2 ++ kernel/sysctl.c | 13 ------------- 2 files changed, 2 insertions(+), 13 deletions(-)fs/file_table.c +2
-0@@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[] = {static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) +register_sysctl_mount_point ("fs/binfmt_misc" );return 0 ; }fs_initcall (init_fs_stat_sysctls);kernel/sysctl.c +0
-13@@ -2735,17 +2735,6 @@ static struct ctl_table vm_table[] = { { } }; -static struct ctl_table fs_table[] = { -#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) - { - .procname = "binfmt_misc", - .mode = 0555, - .child = sysctl_mount_point, - }, -#endif - { } -}; - static struct ctl_table debug_table[] = { #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE {@@ -2765,7 +2754,6 @@ static struct ctl_table dev_table[] = {DECLARE_SYSCTL_BASE (kernel, kern_table);DECLARE_SYSCTL_BASE (vm, vm_table); -DECLARE_SYSCTL_BASE (fs, fs_table);DECLARE_SYSCTL_BASE (debug, debug_table);DECLARE_SYSCTL_BASE (dev, dev_table);@@ -2773,7 +2761,6 @@ int __init sysctl_init_bases(void) {register_sysctl_base (kernel);register_sysctl_base (vm); -register_sysctl_base (fs);register_sysctl_base (debug);register_sysctl_base (dev);Quoted 10 lines
Quoted 3 lines
--
2.34.1Hi Luis,
Thanks for posting.
I checked the master branch just now and the fix is already in, see commitb42bc9a3c511("Fix regression due to "fs: move binfmt_misc sysctl to its own file"")
I have tested it yesterday on a debian machine and it appears to be ok.
Quoted 5 lines
The "fix" was to vert the original effort. This patch continues with the effort and does it properly. As such it is a change which needs to be tested. I'd appreciate if you can test.
Luis
Quoted 47 lines · Tong Zhang
Quoted 45 lines · Luis Chamberlain
Quoted 43 lines · Tong Zhang
Quoted 42 lines · Luis Chamberlain
This is the second attempt to move
binfmt_miscsysctl to its own file. The issue with the first move was that we moved thebinfmt_miscsysctls to thebinfmt_miscmodule, but the way things work on some systems is that thebinfmt_miscmodule will load if the sysctl is present. If we don't force the sysctl on, the module won't load. The proper thing to do is to register the sysctl if the module was built or thebinfmt_misccode was built-in, we do this by using the helperIS_ENABLED()now.The rationale for the move:
kernel/sysctl.cis 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.
This moves the
binfmt_miscsysctl to its own file to help remove clutter fromkernel/sysctl.c.Cc Domenico Andreoli <[email protected]>Cc Tong Zhang <[email protected]>Reviewed-by Tong Zhang <[email protected]>Signed-off-by Luis Chamberlain <[email protected]>---
Andrew,
If we get tested-by from Domenico and Tong I think this is ready.
Demenico, Tong, can you please test this patch? Linus' tree should already have all the prior work reverted as Domenico requested so this starts fresh.
fs/file_table.c | 2 ++ kernel/sysctl.c | 13 ------------- 2 files changed, 2 insertions(+), 13 deletions(-)
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
fs/file_table.c static struct ctl_table fs_stat_sysctls[] = { · line 123
Quoted 10 lines
fs/file_table.c +2
-0@@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[] = {static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) +register_sysctl_mount_point ("fs/binfmt_misc" );
^^^^
I'm looking at this code again and we need to mark this return value in kmemleak to avoid a false positive.
fs/file_table.c +3 -2
@@ -27,6 +27,7 @@#include <linux/task_work.h> #include <linux/ima.h> #include <linux/swap.h> +#include <linux/kmemleak.h> #include <linux/atomic.h>
@@ -119,8 +120,10 @@ static struct ctl_table fs_stat_sysctls[] = {static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); -if (IS_ENABLED (CONFIG_BINFMT_MISC )) -register_sysctl_mount_point ("fs/binfmt_misc" ); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) { + struct ctl_table_header *hdr =
register_sysctl_mount_point("fs/binfmt_misc");
+ kmemleak_not_leak(hdr);
+ }
return 0;
}
fs_initcall(init_fs_stat_sysctls);
Quoted 78 lines · Tong Zhang
Quoted 47 lines · Tong Zhang
Quoted 45 lines · Luis Chamberlain
Quoted 43 lines · Tong Zhang
Quoted 42 lines · Luis Chamberlain
This is the second attempt to move
binfmt_miscsysctl to its own file. The issue with the first move was that we moved thebinfmt_miscsysctls to thebinfmt_miscmodule, but the way things work on some systems is that thebinfmt_miscmodule will load if the sysctl is present. If we don't force the sysctl on, the module won't load. The proper thing to do is to register the sysctl if the module was built or thebinfmt_misccode was built-in, we do this by using the helperIS_ENABLED()now.The rationale for the move:
kernel/sysctl.cis 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.
This moves the
binfmt_miscsysctl to its own file to help remove clutter fromkernel/sysctl.c.Cc Domenico Andreoli <[email protected]>Cc Tong Zhang <[email protected]>Reviewed-by Tong Zhang <[email protected]>Signed-off-by Luis Chamberlain <[email protected]>---
Andrew,
If we get tested-by from Domenico and Tong I think this is ready.
Demenico, Tong, can you please test this patch? Linus' tree should already have all the prior work reverted as Domenico requested so this starts fresh.
fs/file_table.c | 2 ++ kernel/sysctl.c | 13 ------------- 2 files changed, 2 insertions(+), 13 deletions(-)Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
fs/file_table.c static struct ctl_table fs_stat_sysctls[] = { · line 123
Quoted 10 lines
fs/file_table.c +2
-0@@ -119,6 +119,8 @@ static struct ctl_table fs_stat_sysctls[] = {static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) +register_sysctl_mount_point ("fs/binfmt_misc" );^^^^I'm looking at this code again and we need to mark this return value in kmemleak to avoid a false positive.
fs/file_table.c +1
-0@@ -27,6 +27,7 @@#include <linux/task_work.h> #include <linux/ima.h> #include <linux/swap.h> +#include <linux/kmemleak.h> #include <linux/atomic.h>
fs/file_table.c static struct ctl_table fs_stat_sysctls[] = { · line 127
Quoted 10 lines
fs/file_table.c +4
-2@@ -119,8 +120,10 @@ static struct ctl_table fs_stat_sysctls[] = {static int __init init_fs_stat_sysctls (void ) {register_sysctl_init ("fs" , fs_stat_sysctls); -if (IS_ENABLED (CONFIG_BINFMT_MISC )) -register_sysctl_mount_point ("fs/binfmt_misc" ); +if (IS_ENABLED (CONFIG_BINFMT_MISC )) { +struct ctl_table_header *hdr =register_sysctl_mount_point ("fs/binfmt_misc" ); +kmemleak_not_leak (hdr); + }
Good catch, will ammend. I'll give it a few days for others to review and test before a new iteration.
Luis