linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* re: params: <level>_initcall-like kernel parameters
@ 2012-02-02  9:56 Dan Carpenter
  2012-02-02 11:08 ` Pawel Moll
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2012-02-02  9:56 UTC (permalink / raw)
  To: pawel.moll; +Cc: linux-kernel

Hello Pawel Moll,

The patch b41c2e271944: "params: <level>_initcall-like kernel 
parameters" from Dec 12, 2011, leads to the following warning:
init/main.c:749 do_initcall_level()
	 error: buffer overflow 'initcall_level_names' 7 <= 7

   743  static void __init do_initcall_level(int level)
   744  {
   745          extern const struct kernel_param __start___param[], __stop___param[];
   746          initcall_t *fn;
   747  
   748          strcpy(static_command_line, saved_command_line);
   749          parse_args(initcall_level_names[level],
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
initcall_level_names[] has 7 elements so initcall_level_names[7] is past
the end of the array.

   750                     static_command_line, __start___param,
   751                     __stop___param - __start___param,
   752                     level, level,
   753                     ignore_unknown_bootoption);
   754  
   755          for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
   756                  do_one_initcall(*fn);
   757  }
   758  
   759  static void __init do_initcalls(void)
   760  {
   761          int level;
   762  
   763          for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++)
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
initcall_levels[] has 9 elements so level is 0-7 here.

   764                  do_initcall_level(level);
   765  }

regards,
dan carpenter


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

* re: params: <level>_initcall-like kernel parameters
  2012-02-02  9:56 params: <level>_initcall-like kernel parameters Dan Carpenter
@ 2012-02-02 11:08 ` Pawel Moll
  2012-02-02 17:01   ` Dan Carpenter
  2012-02-06 22:16   ` Rusty Russell
  0 siblings, 2 replies; 5+ messages in thread
From: Pawel Moll @ 2012-02-02 11:08 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-kernel, Rusty Russell

Morning,

On Thu, 2012-02-02 at 09:56 +0000, Dan Carpenter wrote:
> The patch b41c2e271944: "params: <level>_initcall-like kernel 
> parameters" from Dec 12, 2011, leads to the following warning:
> init/main.c:749 do_initcall_level()
> 	 error: buffer overflow 'initcall_level_names' 7 <= 7
> 
>    743  static void __init do_initcall_level(int level)
>    744  {
>    745          extern const struct kernel_param __start___param[], __stop___param[];
>    746          initcall_t *fn;
>    747  
>    748          strcpy(static_command_line, saved_command_line);
>    749          parse_args(initcall_level_names[level],
>                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> initcall_level_names[] has 7 elements so initcall_level_names[7] is past
> the end of the array.
> 
>    750                     static_command_line, __start___param,
>    751                     __stop___param - __start___param,
>    752                     level, level,
>    753                     ignore_unknown_bootoption);
>    754  
>    755          for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
>    756                  do_one_initcall(*fn);
>    757  }
>    758  
>    759  static void __init do_initcalls(void)
>    760  {
>    761          int level;
>    762  
>    763          for (level = 0; level < ARRAY_SIZE(initcall_levels) - 1; level++)
>                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> initcall_levels[] has 9 elements so level is 0-7 here.
> 
>    764                  do_initcall_level(level);
>    765  }

You're right, of course! The initcall_level_names is missing "early
parameters" string as the first element of the array. Well spotted - may
I asked what tool did you use to get this message?

Rusty, do you want me to re-send the patch with this string fixed? I
think you have rebased it on top of your bool-param series?

Thanks for your time!

Paweł




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

* Re: params: <level>_initcall-like kernel parameters
  2012-02-02 11:08 ` Pawel Moll
@ 2012-02-02 17:01   ` Dan Carpenter
  2012-02-06 22:16   ` Rusty Russell
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2012-02-02 17:01 UTC (permalink / raw)
  To: Pawel Moll; +Cc: linux-kernel, Rusty Russell

[-- Attachment #1: Type: text/plain, Size: 449 bytes --]

On Thu, Feb 02, 2012 at 11:08:57AM +0000, Pawel Moll wrote:
> You're right, of course! The initcall_level_names is missing "early
> parameters" string as the first element of the array. Well spotted - may
> I asked what tool did you use to get this message?
> 

It's a Smatch thing, but it requires the database to be set up
first.  It's a new-ish feature.  I should clean up my build scripts
and publish them...

regards,
dan carpenter

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* re: params: <level>_initcall-like kernel parameters
  2012-02-02 11:08 ` Pawel Moll
  2012-02-02 17:01   ` Dan Carpenter
@ 2012-02-06 22:16   ` Rusty Russell
  2012-02-07 14:45     ` [PATCH] params: Add missing init level name Pawel Moll
  1 sibling, 1 reply; 5+ messages in thread
From: Rusty Russell @ 2012-02-06 22:16 UTC (permalink / raw)
  To: Pawel Moll, Dan Carpenter; +Cc: linux-kernel

On Thu, 02 Feb 2012 11:08:57 +0000, Pawel Moll <pawel.moll@arm.com> wrote:
> You're right, of course! The initcall_level_names is missing "early
> parameters" string as the first element of the array. Well spotted - may
> I asked what tool did you use to get this message?
> 
> Rusty, do you want me to re-send the patch with this string fixed? I
> think you have rebased it on top of your bool-param series?

An incremental patch is preferred.  I can fold it once it's done.

Thanks,
Rusty.

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

* [PATCH] params: Add missing init level name
  2012-02-06 22:16   ` Rusty Russell
@ 2012-02-07 14:45     ` Pawel Moll
  0 siblings, 0 replies; 5+ messages in thread
From: Pawel Moll @ 2012-02-07 14:45 UTC (permalink / raw)
  To: Rusty Russell; +Cc: linux-kernel, Dan Carpenter, Jim Cromie, Pawel Moll

The initcall_level_names array did not contain name of the
"virtual" level 0 (early paramters). Fixed.

Signed-off-by: Pawel Moll <pawel.moll@arm.com>
---
 init/main.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/init/main.c b/init/main.c
index 8e4060c..b229ee6 100644
--- a/init/main.c
+++ b/init/main.c
@@ -726,6 +726,7 @@ static initcall_t *initcall_levels[] __initdata = {
 };
 
 static char *initcall_level_names[] __initdata = {
+	"early parameters",
 	"core parameters",
 	"postcore parameters",
 	"arch parameters",
-- 
1.7.5.4



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

end of thread, other threads:[~2012-02-07 14:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-02  9:56 params: <level>_initcall-like kernel parameters Dan Carpenter
2012-02-02 11:08 ` Pawel Moll
2012-02-02 17:01   ` Dan Carpenter
2012-02-06 22:16   ` Rusty Russell
2012-02-07 14:45     ` [PATCH] params: Add missing init level name Pawel Moll

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).