diff mbox series

[v2,1/6] panic: Separate sysctl logic from CONFIG_SMP

Message ID 20221109200050.3400857-1-keescook@chromium.org (mailing list archive)
State New
Headers show
Series exit: Put an upper limit on how often we can oops | expand

Commit Message

Kees Cook Nov. 9, 2022, 8 p.m. UTC
In preparation for adding more sysctls directly in kernel/panic.c, split
CONFIG_SMP from the logic that adds sysctls.

Cc: Petr Mladek <pmladek@suse.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: tangmeng <tangmeng@uniontech.com>
Cc: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 kernel/panic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Bill Wendling Nov. 9, 2022, 9:48 p.m. UTC | #1
On Wed, Nov 9, 2022 at 12:01 PM Kees Cook <keescook@chromium.org> wrote:
>
> In preparation for adding more sysctls directly in kernel/panic.c, split
> CONFIG_SMP from the logic that adds sysctls.
>
> Cc: Petr Mladek <pmladek@suse.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: tangmeng <tangmeng@uniontech.com>
> Cc: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
> Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  kernel/panic.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/panic.c b/kernel/panic.c
> index da323209f583..129936511380 100644
> --- a/kernel/panic.c
> +++ b/kernel/panic.c
> @@ -75,8 +75,9 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
>
>  EXPORT_SYMBOL(panic_notifier_list);
>
> -#if defined(CONFIG_SMP) && defined(CONFIG_SYSCTL)
> +#if CONFIG_SYSCTL

Should this be "#ifdef CONFIG_SYSCTL"?

>  static struct ctl_table kern_panic_table[] = {
> +#if defined(CONFIG_SMP)

nit: This could be "#ifdef CONFIG_SMP"

>         {
>                 .procname       = "oops_all_cpu_backtrace",
>                 .data           = &sysctl_oops_all_cpu_backtrace,
> @@ -86,6 +87,7 @@ static struct ctl_table kern_panic_table[] = {
>                 .extra1         = SYSCTL_ZERO,
>                 .extra2         = SYSCTL_ONE,
>         },
> +#endif
>         { }
>  };
>
> --
> 2.34.1
>
Kees Cook Nov. 10, 2022, 12:02 a.m. UTC | #2
On Wed, Nov 09, 2022 at 01:48:45PM -0800, Bill Wendling wrote:
> On Wed, Nov 9, 2022 at 12:01 PM Kees Cook <keescook@chromium.org> wrote:
> >
> > In preparation for adding more sysctls directly in kernel/panic.c, split
> > CONFIG_SMP from the logic that adds sysctls.
> >
> > Cc: Petr Mladek <pmladek@suse.com>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: tangmeng <tangmeng@uniontech.com>
> > Cc: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
> > Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
> > Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> > Signed-off-by: Kees Cook <keescook@chromium.org>
> > ---
> >  kernel/panic.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/kernel/panic.c b/kernel/panic.c
> > index da323209f583..129936511380 100644
> > --- a/kernel/panic.c
> > +++ b/kernel/panic.c
> > @@ -75,8 +75,9 @@ ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
> >
> >  EXPORT_SYMBOL(panic_notifier_list);
> >
> > -#if defined(CONFIG_SMP) && defined(CONFIG_SYSCTL)
> > +#if CONFIG_SYSCTL
> 
> Should this be "#ifdef CONFIG_SYSCTL"?
> 
> >  static struct ctl_table kern_panic_table[] = {
> > +#if defined(CONFIG_SMP)
> 
> nit: This could be "#ifdef CONFIG_SMP"

Whoops, yes. Thanks. I'll fix these for v3.
kernel test robot Nov. 12, 2022, 10:44 a.m. UTC | #3
Hi Kees,

I love your patch! Perhaps something to improve:

[auto build test WARNING on next-20221109]

url:    https://github.com/intel-lab-lkp/linux/commits/Kees-Cook/exit-Put-an-upper-limit-on-how-often-we-can-oops/20221110-040244
patch link:    https://lore.kernel.org/r/20221109200050.3400857-1-keescook%40chromium.org
patch subject: [PATCH v2 1/6] panic: Separate sysctl logic from CONFIG_SMP
config: m68k-randconfig-r024-20221111
compiler: m68k-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/d1ce412a5f8b37476d703c7891272265f7d658f0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Kees-Cook/exit-Put-an-upper-limit-on-how-often-we-can-oops/20221110-040244
        git checkout d1ce412a5f8b37476d703c7891272265f7d658f0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> kernel/panic.c:79:5: warning: "CONFIG_SYSCTL" is not defined, evaluates to 0 [-Wundef]
      79 | #if CONFIG_SYSCTL
         |     ^~~~~~~~~~~~~
   kernel/panic.c: In function '__warn':
   kernel/panic.c:616:17: warning: function '__warn' might be a candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format]
     616 |                 vprintk(args->fmt, args->args);
         |                 ^~~~~~~
   kernel/panic.c: At top level:
   kernel/panic.c:639:6: warning: no previous prototype for 'warn_slowpath_fmt' [-Wmissing-prototypes]
     639 | void warn_slowpath_fmt(const char *file, int line, unsigned taint,
         |      ^~~~~~~~~~~~~~~~~


vim +/CONFIG_SYSCTL +79 kernel/panic.c

    78	
  > 79	#if CONFIG_SYSCTL
    80	static struct ctl_table kern_panic_table[] = {
    81	#if defined(CONFIG_SMP)
    82		{
    83			.procname       = "oops_all_cpu_backtrace",
    84			.data           = &sysctl_oops_all_cpu_backtrace,
    85			.maxlen         = sizeof(int),
    86			.mode           = 0644,
    87			.proc_handler   = proc_dointvec_minmax,
    88			.extra1         = SYSCTL_ZERO,
    89			.extra2         = SYSCTL_ONE,
    90		},
    91	#endif
    92		{ }
    93	};
    94
kernel test robot Nov. 13, 2022, 6:43 p.m. UTC | #4
Hi Kees,

I love your patch! Perhaps something to improve:

[auto build test WARNING on next-20221109]

url:    https://github.com/intel-lab-lkp/linux/commits/Kees-Cook/exit-Put-an-upper-limit-on-how-often-we-can-oops/20221110-040244
patch link:    https://lore.kernel.org/r/20221109200050.3400857-1-keescook%40chromium.org
patch subject: [PATCH v2 1/6] panic: Separate sysctl logic from CONFIG_SMP
config: riscv-randconfig-s053-20221113
compiler: riscv32-linux-gcc (GCC) 12.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://github.com/intel-lab-lkp/linux/commit/d1ce412a5f8b37476d703c7891272265f7d658f0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Kees-Cook/exit-Put-an-upper-limit-on-how-often-we-can-oops/20221110-040244
        git checkout d1ce412a5f8b37476d703c7891272265f7d658f0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=riscv SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

sparse warnings: (new ones prefixed by >>)
   WARNING: invalid argument to '-march': '_zihintpause'
>> kernel/panic.c:79:5: sparse: sparse: undefined preprocessor identifier 'CONFIG_SYSCTL'

vim +/CONFIG_SYSCTL +79 kernel/panic.c

    78	
  > 79	#if CONFIG_SYSCTL
    80	static struct ctl_table kern_panic_table[] = {
    81	#if defined(CONFIG_SMP)
    82		{
    83			.procname       = "oops_all_cpu_backtrace",
    84			.data           = &sysctl_oops_all_cpu_backtrace,
    85			.maxlen         = sizeof(int),
    86			.mode           = 0644,
    87			.proc_handler   = proc_dointvec_minmax,
    88			.extra1         = SYSCTL_ZERO,
    89			.extra2         = SYSCTL_ONE,
    90		},
    91	#endif
    92		{ }
    93	};
    94
diff mbox series

Patch

diff --git a/kernel/panic.c b/kernel/panic.c
index da323209f583..129936511380 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -75,8 +75,9 @@  ATOMIC_NOTIFIER_HEAD(panic_notifier_list);
 
 EXPORT_SYMBOL(panic_notifier_list);
 
-#if defined(CONFIG_SMP) && defined(CONFIG_SYSCTL)
+#if CONFIG_SYSCTL
 static struct ctl_table kern_panic_table[] = {
+#if defined(CONFIG_SMP)
 	{
 		.procname       = "oops_all_cpu_backtrace",
 		.data           = &sysctl_oops_all_cpu_backtrace,
@@ -86,6 +87,7 @@  static struct ctl_table kern_panic_table[] = {
 		.extra1         = SYSCTL_ZERO,
 		.extra2         = SYSCTL_ONE,
 	},
+#endif
 	{ }
 };