All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-next:master 5741/5912] kernel/crash_core.c:214:13: warning: argument 2 null where non-null expected
@ 2023-09-19  4:02 kernel test robot
  2023-09-19 16:42 ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: kernel test robot @ 2023-09-19  4:02 UTC (permalink / raw)
  To: Baoquan He
  Cc: oe-kbuild-all, Linux Memory Management List, Andrew Morton, Zhen Lei

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   7fc7222d9680366edeecc219c21ca96310bdbc10
commit: 5c322f6aad10f0920f842a4ccf82e9b9f351c0a5 [5741/5912] crash_core.c: remove unneeded functions
config: s390-buildonly-randconfig-r006-20220512 (https://download.01.org/0day-ci/archive/20230919/202309191144.B0MToaPG-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230919/202309191144.B0MToaPG-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309191144.B0MToaPG-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from arch/s390/include/asm/atomic.h:12,
                    from include/linux/atomic.h:7,
                    from include/linux/mm_types_task.h:13,
                    from include/linux/mm_types.h:5,
                    from include/linux/buildid.h:5,
                    from kernel/crash_core.c:7:
   kernel/crash_core.c: In function 'parse_crashkernel_suffix.constprop':
>> kernel/crash_core.c:214:13: warning: argument 2 null where non-null expected [-Wnonnull]
     214 |         if (strncmp(cur, suffix, strlen(suffix))) {
   include/linux/compiler.h:68:10: note: in definition of macro '__trace_if_value'
      68 |         (cond) ?                                        \
         |          ^~~~
   include/linux/compiler.h:55:28: note: in expansion of macro '__trace_if_var'
      55 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
         |                            ^~~~~~~~~~~~~~
   kernel/crash_core.c:214:9: note: in expansion of macro 'if'
     214 |         if (strncmp(cur, suffix, strlen(suffix))) {
         |         ^~
   In file included from include/linux/bitmap.h:11,
                    from include/linux/cpumask.h:12,
                    from include/linux/mm_types_task.h:14,
                    from include/linux/mm_types.h:5,
                    from include/linux/buildid.h:5,
                    from kernel/crash_core.c:7:
   include/linux/string.h:51:12: note: in a call to function 'strncmp' declared 'nonnull'
      51 | extern int strncmp(const char *,const char *,__kernel_size_t);
         |            ^~~~~~~


vim +214 kernel/crash_core.c

692f66f26a4c19 Hari Bathini 2017-05-08  193  
692f66f26a4c19 Hari Bathini 2017-05-08  194  /*
692f66f26a4c19 Hari Bathini 2017-05-08  195   * That function parses "suffix"  crashkernel command lines like
692f66f26a4c19 Hari Bathini 2017-05-08  196   *
692f66f26a4c19 Hari Bathini 2017-05-08  197   *	crashkernel=size,[high|low]
692f66f26a4c19 Hari Bathini 2017-05-08  198   *
692f66f26a4c19 Hari Bathini 2017-05-08  199   * It returns 0 on success and -EINVAL on failure.
692f66f26a4c19 Hari Bathini 2017-05-08  200   */
692f66f26a4c19 Hari Bathini 2017-05-08  201  static int __init parse_crashkernel_suffix(char *cmdline,
692f66f26a4c19 Hari Bathini 2017-05-08  202  					   unsigned long long	*crash_size,
692f66f26a4c19 Hari Bathini 2017-05-08  203  					   const char *suffix)
692f66f26a4c19 Hari Bathini 2017-05-08  204  {
692f66f26a4c19 Hari Bathini 2017-05-08  205  	char *cur = cmdline;
692f66f26a4c19 Hari Bathini 2017-05-08  206  
692f66f26a4c19 Hari Bathini 2017-05-08  207  	*crash_size = memparse(cmdline, &cur);
692f66f26a4c19 Hari Bathini 2017-05-08  208  	if (cmdline == cur) {
692f66f26a4c19 Hari Bathini 2017-05-08  209  		pr_warn("crashkernel: memory value expected\n");
692f66f26a4c19 Hari Bathini 2017-05-08  210  		return -EINVAL;
692f66f26a4c19 Hari Bathini 2017-05-08  211  	}
692f66f26a4c19 Hari Bathini 2017-05-08  212  
692f66f26a4c19 Hari Bathini 2017-05-08  213  	/* check with suffix */
692f66f26a4c19 Hari Bathini 2017-05-08 @214  	if (strncmp(cur, suffix, strlen(suffix))) {
692f66f26a4c19 Hari Bathini 2017-05-08  215  		pr_warn("crashkernel: unrecognized char: %c\n", *cur);
692f66f26a4c19 Hari Bathini 2017-05-08  216  		return -EINVAL;
692f66f26a4c19 Hari Bathini 2017-05-08  217  	}
692f66f26a4c19 Hari Bathini 2017-05-08  218  	cur += strlen(suffix);
692f66f26a4c19 Hari Bathini 2017-05-08  219  	if (*cur != ' ' && *cur != '\0') {
692f66f26a4c19 Hari Bathini 2017-05-08  220  		pr_warn("crashkernel: unrecognized char: %c\n", *cur);
692f66f26a4c19 Hari Bathini 2017-05-08  221  		return -EINVAL;
692f66f26a4c19 Hari Bathini 2017-05-08  222  	}
692f66f26a4c19 Hari Bathini 2017-05-08  223  
692f66f26a4c19 Hari Bathini 2017-05-08  224  	return 0;
692f66f26a4c19 Hari Bathini 2017-05-08  225  }
692f66f26a4c19 Hari Bathini 2017-05-08  226  

:::::: The code at line 214 was first introduced by commit
:::::: 692f66f26a4c19d73249736aa973c13a1521b387 crash: move crashkernel parsing and vmcore related code under CONFIG_CRASH_CORE

:::::: TO: Hari Bathini <hbathini@linux.vnet.ibm.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [linux-next:master 5741/5912] kernel/crash_core.c:214:13: warning: argument 2 null where non-null expected
  2023-09-19  4:02 [linux-next:master 5741/5912] kernel/crash_core.c:214:13: warning: argument 2 null where non-null expected kernel test robot
@ 2023-09-19 16:42 ` Andrew Morton
  2023-09-19 23:11   ` Baoquan He
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2023-09-19 16:42 UTC (permalink / raw)
  To: kernel test robot
  Cc: Baoquan He, oe-kbuild-all, Linux Memory Management List, Zhen Lei

On Tue, 19 Sep 2023 12:02:17 +0800 kernel test robot <lkp@intel.com> wrote:

> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head:   7fc7222d9680366edeecc219c21ca96310bdbc10
> commit: 5c322f6aad10f0920f842a4ccf82e9b9f351c0a5 [5741/5912] crash_core.c: remove unneeded functions
> config: s390-buildonly-randconfig-r006-20220512 (https://download.01.org/0day-ci/archive/20230919/202309191144.B0MToaPG-lkp@intel.com/config)
> compiler: s390-linux-gcc (GCC) 11.3.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230919/202309191144.B0MToaPG-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202309191144.B0MToaPG-lkp@intel.com/
> 
> All warnings (new ones prefixed by >>):
> 
>    In file included from arch/s390/include/asm/atomic.h:12,
>                     from include/linux/atomic.h:7,
>                     from include/linux/mm_types_task.h:13,
>                     from include/linux/mm_types.h:5,
>                     from include/linux/buildid.h:5,
>                     from kernel/crash_core.c:7:
>    kernel/crash_core.c: In function 'parse_crashkernel_suffix.constprop':
> >> kernel/crash_core.c:214:13: warning: argument 2 null where non-null expected [-Wnonnull]
>      214 |         if (strncmp(cur, suffix, strlen(suffix))) {
>    include/linux/compiler.h:68:10: note: in definition of macro '__trace_if_value'
>       68 |         (cond) ?                                        \
>          |          ^~~~
>    include/linux/compiler.h:55:28: note: in expansion of macro '__trace_if_var'
>       55 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
>          |                            ^~~~~~~~~~~~~~

Looks legit?  parse_crashkernel() does

	ret = __parse_crashkernel(cmdline, system_ram, crash_size,
				crash_base, NULL);

and that suffix==NULL gets passed through to the strncmp()?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [linux-next:master 5741/5912] kernel/crash_core.c:214:13: warning: argument 2 null where non-null expected
  2023-09-19 16:42 ` Andrew Morton
@ 2023-09-19 23:11   ` Baoquan He
  2023-09-20  1:16     ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Baoquan He @ 2023-09-19 23:11 UTC (permalink / raw)
  To: Andrew Morton
  Cc: kernel test robot, oe-kbuild-all, Linux Memory Management List, Zhen Lei

On 09/19/23 at 09:42am, Andrew Morton wrote:
> On Tue, 19 Sep 2023 12:02:17 +0800 kernel test robot <lkp@intel.com> wrote:
> 
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> > head:   7fc7222d9680366edeecc219c21ca96310bdbc10
> > commit: 5c322f6aad10f0920f842a4ccf82e9b9f351c0a5 [5741/5912] crash_core.c: remove unneeded functions
> > config: s390-buildonly-randconfig-r006-20220512 (https://download.01.org/0day-ci/archive/20230919/202309191144.B0MToaPG-lkp@intel.com/config)
> > compiler: s390-linux-gcc (GCC) 11.3.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230919/202309191144.B0MToaPG-lkp@intel.com/reproduce)
> > 
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202309191144.B0MToaPG-lkp@intel.com/
> > 
> > All warnings (new ones prefixed by >>):
> > 
> >    In file included from arch/s390/include/asm/atomic.h:12,
> >                     from include/linux/atomic.h:7,
> >                     from include/linux/mm_types_task.h:13,
> >                     from include/linux/mm_types.h:5,
> >                     from include/linux/buildid.h:5,
> >                     from kernel/crash_core.c:7:
> >    kernel/crash_core.c: In function 'parse_crashkernel_suffix.constprop':
> > >> kernel/crash_core.c:214:13: warning: argument 2 null where non-null expected [-Wnonnull]
> >      214 |         if (strncmp(cur, suffix, strlen(suffix))) {
> >    include/linux/compiler.h:68:10: note: in definition of macro '__trace_if_value'
> >       68 |         (cond) ?                                        \
> >          |          ^~~~
> >    include/linux/compiler.h:55:28: note: in expansion of macro '__trace_if_var'
> >       55 | #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
> >          |                            ^~~~~~~~~~~~~~
> 
> Looks legit?  parse_crashkernel() does
> 
> 	ret = __parse_crashkernel(cmdline, system_ram, crash_size,
> 				crash_base, NULL);
> 
> and that suffix==NULL gets passed through to the strncmp()?

Yeah, this looks like a false positive report. I reproduced this, below
change can mute the warning. However, the null pointer checking has been
done in __parse_crashkernel() when calls parse_crashkernel_suffix().

Add below check anyway to satisfy the W=1 compiling?

diff --git a/kernel/crash_core.c b/kernel/crash_core.c
index 1a77d466eaed..b53270ac3715 100644
--- a/kernel/crash_core.c
+++ b/kernel/crash_core.c
@@ -204,6 +204,9 @@ static int __init parse_crashkernel_suffix(char *cmdline,
 {
 	char *cur = cmdline;
 
+	if(!suffix)
+		return -EINVAL;
+
 	*crash_size = memparse(cmdline, &cur);
 	if (cmdline == cur) {
 		pr_warn("crashkernel: memory value expected\n");


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [linux-next:master 5741/5912] kernel/crash_core.c:214:13: warning: argument 2 null where non-null expected
  2023-09-19 23:11   ` Baoquan He
@ 2023-09-20  1:16     ` Andrew Morton
  2023-09-20  1:36       ` Baoquan He
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2023-09-20  1:16 UTC (permalink / raw)
  To: Baoquan He
  Cc: kernel test robot, oe-kbuild-all, Linux Memory Management List, Zhen Lei

On Wed, 20 Sep 2023 07:11:45 +0800 Baoquan He <bhe@redhat.com> wrote:

> > 
> > 	ret = __parse_crashkernel(cmdline, system_ram, crash_size,
> > 				crash_base, NULL);
> > 
> > and that suffix==NULL gets passed through to the strncmp()?
> 
> Yeah, this looks like a false positive report. I reproduced this, below
> change can mute the warning. However, the null pointer checking has been
> done in __parse_crashkernel() when calls parse_crashkernel_suffix().

How the heck did I miss that.

> Add below check anyway to satisfy the W=1 compiling?

I dunno, gcc is so wrong here I'm inclined to leave it as-is, because
surely this will get fixed in later gcc's.

> --- a/kernel/crash_core.c
> +++ b/kernel/crash_core.c
> @@ -204,6 +204,9 @@ static int __init parse_crashkernel_suffix(char *cmdline,
>  {
>  	char *cur = cmdline;
>  
> +	if(!suffix)
> +		return -EINVAL;
> +
>  	*crash_size = memparse(cmdline, &cur);
>  	if (cmdline == cur) {
>  		pr_warn("crashkernel: memory value expected\n");

If we were to do this, let's have a comment explaining why we're doing
it - otherwise helpful people will try to remove it again.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [linux-next:master 5741/5912] kernel/crash_core.c:214:13: warning: argument 2 null where non-null expected
  2023-09-20  1:16     ` Andrew Morton
@ 2023-09-20  1:36       ` Baoquan He
  0 siblings, 0 replies; 5+ messages in thread
From: Baoquan He @ 2023-09-20  1:36 UTC (permalink / raw)
  To: Andrew Morton
  Cc: kernel test robot, oe-kbuild-all, Linux Memory Management List, Zhen Lei

On 09/19/23 at 06:16pm, Andrew Morton wrote:
> On Wed, 20 Sep 2023 07:11:45 +0800 Baoquan He <bhe@redhat.com> wrote:
> 
> > > 
> > > 	ret = __parse_crashkernel(cmdline, system_ram, crash_size,
> > > 				crash_base, NULL);
> > > 
> > > and that suffix==NULL gets passed through to the strncmp()?
> > 
> > Yeah, this looks like a false positive report. I reproduced this, below
> > change can mute the warning. However, the null pointer checking has been
> > done in __parse_crashkernel() when calls parse_crashkernel_suffix().
> 
> How the heck did I miss that.
> 
> > Add below check anyway to satisfy the W=1 compiling?
> 
> I dunno, gcc is so wrong here I'm inclined to leave it as-is, because
> surely this will get fixed in later gcc's.
> 
> > --- a/kernel/crash_core.c
> > +++ b/kernel/crash_core.c
> > @@ -204,6 +204,9 @@ static int __init parse_crashkernel_suffix(char *cmdline,
> >  {
> >  	char *cur = cmdline;
> >  
> > +	if(!suffix)
> > +		return -EINVAL;
> > +
> >  	*crash_size = memparse(cmdline, &cur);
> >  	if (cmdline == cur) {
> >  		pr_warn("crashkernel: memory value expected\n");
> 
> If we were to do this, let's have a comment explaining why we're doing
> it - otherwise helpful people will try to remove it again.

I will post v4 patchset anyway to include another fixing in patch 6/9
since LKP spotted a real issue causing compiling warning. I can add this
change with a comment to explain why the checking is needed here.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-20  1:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-19  4:02 [linux-next:master 5741/5912] kernel/crash_core.c:214:13: warning: argument 2 null where non-null expected kernel test robot
2023-09-19 16:42 ` Andrew Morton
2023-09-19 23:11   ` Baoquan He
2023-09-20  1:16     ` Andrew Morton
2023-09-20  1:36       ` Baoquan He

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.