public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] param_sysfs_builtin memchr argument fix
@ 2007-10-08  6:50 Dave Young
  2007-10-08  7:02 ` WANG Cong
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Young @ 2007-10-08  6:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm, gregkh

If memchr argument is longer than strlen(kp->name), there will be some
weird result. 

Signed-off-by: Dave Young <hidave.darkstar@gmail.com> 

---
params.c |   10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff -upr linux/kernel/params.c linux.new/kernel/params.c
--- linux/kernel/params.c	2007-10-08 14:30:06.000000000 +0800
+++ linux.new/kernel/params.c	2007-10-08 14:31:22.000000000 +0800
@@ -592,15 +592,21 @@ static void __init param_sysfs_builtin(v
 
 	for (i=0; i < __stop___param - __start___param; i++) {
 		char *dot;
+		int kplen;
 
 		kp = &__start___param[i];
+		kplen = strlen(kp->name);
 
 		/* We do not handle args without periods. */
-		dot = memchr(kp->name, '.', MAX_KBUILD_MODNAME);
+		if (kplen > MAX_KBUILD_MODNAME) {
+			DEBUGP("kernel parameter %s is too long\n", kp->name);
+			continue;
+		}
+		dot = memchr(kp->name, '.', kplen);
 		if (!dot) {
 			DEBUGP("couldn't find period in %s\n", kp->name);
 			continue;
-		}
+		} 
 		name_len = dot - kp->name;
 
  		/* new kbuild_modname? */

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

* Re: [PATCH] param_sysfs_builtin memchr argument fix
  2007-10-08  6:50 [PATCH] param_sysfs_builtin memchr argument fix Dave Young
@ 2007-10-08  7:02 ` WANG Cong
  0 siblings, 0 replies; 5+ messages in thread
From: WANG Cong @ 2007-10-08  7:02 UTC (permalink / raw)
  To: Dave Young; +Cc: linux-kernel, akpm, gregkh

On Mon, Oct 08, 2007 at 02:50:10PM +0800, Dave Young wrote:
>If memchr argument is longer than strlen(kp->name), there will be some
>weird result. 
>
>Signed-off-by: Dave Young <hidave.darkstar@gmail.com> 
>
>---
>params.c |   10 ++++++++--
>1 file changed, 8 insertions(+), 2 deletions(-)


Hmm, you used diffstat without -p1?


>
>diff -upr linux/kernel/params.c linux.new/kernel/params.c
>--- linux/kernel/params.c	2007-10-08 14:30:06.000000000 +0800
>+++ linux.new/kernel/params.c	2007-10-08 14:31:22.000000000 +0800
>@@ -592,15 +592,21 @@ static void __init param_sysfs_builtin(v
> 
> 	for (i=0; i < __stop___param - __start___param; i++) {
> 		char *dot;
>+		int kplen;
> 
> 		kp = &__start___param[i];
>+		kplen = strlen(kp->name);

strlen() returns a size_t value, which is unsigned. ;)

> 
> 		/* We do not handle args without periods. */
>-		dot = memchr(kp->name, '.', MAX_KBUILD_MODNAME);
>+		if (kplen > MAX_KBUILD_MODNAME) {
>+			DEBUGP("kernel parameter %s is too long\n", kp->name);
>+			continue;
>+		}
>+		dot = memchr(kp->name, '.', kplen);
> 		if (!dot) {
> 			DEBUGP("couldn't find period in %s\n", kp->name);
> 			continue;
>-		}
>+		} 

You add an extra whitespace in the end of the line.


-- 
I try to say goodbye and I choke.
I try to walk away and I stumble.
I play it off, but I’m dreaming of you.
Though I try to hide it, it’s clear that
my world crumbles when you are not here.

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

* Re: [PATCH] param_sysfs_builtin memchr argument fix
@ 2007-10-08  7:17 Dave Young
  2007-10-08 16:13 ` Randy Dunlap
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Young @ 2007-10-08  7:17 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: linux-kernel, akpm, gregkh

Hi,
Thanks for comment.
fixed.

Regards
dave
-----

If memchr argument is longer than strlen(kp->name), there will be some
weird result.

Signed-off-by: Dave Young <hidave.darkstar@gmail.com> 

---
kernel/params.c |    8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff -upr linux/kernel/params.c linux.new/kernel/params.c
--- linux/kernel/params.c	2007-10-08 14:30:06.000000000 +0800
+++ linux.new/kernel/params.c	2007-10-08 15:13:04.000000000 +0800
@@ -592,11 +592,17 @@ static void __init param_sysfs_builtin(v
 
 	for (i=0; i < __stop___param - __start___param; i++) {
 		char *dot;
+		size_t kplen;
 
 		kp = &__start___param[i];
+		kplen = strlen(kp->name);
 
 		/* We do not handle args without periods. */
-		dot = memchr(kp->name, '.', MAX_KBUILD_MODNAME);
+		if (kplen > MAX_KBUILD_MODNAME) {
+			DEBUGP("kernel parameter %s is too long\n", kp->name);
+			continue;
+		}
+		dot = memchr(kp->name, '.', kplen);
 		if (!dot) {
 			DEBUGP("couldn't find period in %s\n", kp->name);
 			continue;

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

* Re: [PATCH] param_sysfs_builtin memchr argument fix
  2007-10-08  7:17 Dave Young
@ 2007-10-08 16:13 ` Randy Dunlap
       [not found]   ` <a8e1da0710081807l74ca63ayf93183eac75193a@mail.gmail.com>
  0 siblings, 1 reply; 5+ messages in thread
From: Randy Dunlap @ 2007-10-08 16:13 UTC (permalink / raw)
  To: Dave Young; +Cc: xiyou.wangcong, linux-kernel, akpm, gregkh

On Mon, 8 Oct 2007 15:17:30 +0800 Dave Young wrote:

> Hi,
> Thanks for comment.
> fixed.
> 
> Regards
> dave
> -----
> 
> If memchr argument is longer than strlen(kp->name), there will be some
> weird result.

Just to clarify:  this was causing duplicate filenames in sysfs ?


> Signed-off-by: Dave Young <hidave.darkstar@gmail.com> 
> 
> ---
> kernel/params.c |    8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff -upr linux/kernel/params.c linux.new/kernel/params.c
> --- linux/kernel/params.c	2007-10-08 14:30:06.000000000 +0800
> +++ linux.new/kernel/params.c	2007-10-08 15:13:04.000000000 +0800
> @@ -592,11 +592,17 @@ static void __init param_sysfs_builtin(v
>  
>  	for (i=0; i < __stop___param - __start___param; i++) {
>  		char *dot;
> +		size_t kplen;
>  
>  		kp = &__start___param[i];
> +		kplen = strlen(kp->name);
>  
>  		/* We do not handle args without periods. */
> -		dot = memchr(kp->name, '.', MAX_KBUILD_MODNAME);
> +		if (kplen > MAX_KBUILD_MODNAME) {
> +			DEBUGP("kernel parameter %s is too long\n", kp->name);

how about
	kernel parameter name %s is too long
or
	kernel parameter name is too long: %s

(primary is addition of "name")

> +			continue;
> +		}
> +		dot = memchr(kp->name, '.', kplen);
>  		if (!dot) {
>  			DEBUGP("couldn't find period in %s\n", kp->name);
>  			continue;
> -


---
~Randy

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

* Re: [PATCH] param_sysfs_builtin memchr argument fix
       [not found]   ` <a8e1da0710081807l74ca63ayf93183eac75193a@mail.gmail.com>
@ 2007-10-09  1:21     ` Dave Young
  0 siblings, 0 replies; 5+ messages in thread
From: Dave Young @ 2007-10-09  1:21 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: linux-kernel, xiyou.wangcong, akpm, gregkh

> > If memchr argument is longer than strlen(kp->name), there will be some
> > weird result.
> 
> Just to clarify:  this was causing duplicate filenames in sysfs ?
Yes, it will casuse duplicate filenames in sysfs. For me, the "nousb"
will cause the "usbcore" created twice. 
> 
> 
> > Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
> >
> > ---
> > kernel/params.c |    8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff -upr linux/kernel/params.c linux.new/kernel/params.c
> > --- linux/kernel/params.c     2007-10-08 14:30:06.000000000 +0800
> > +++ linux.new/kernel/params.c 2007-10-08 15:13:04.000000000 +0800
> > @@ -592,11 +592,17 @@ static void __init param_sysfs_builtin(v
> >
> >       for (i=0; i < __stop___param - __start___param; i++) {
> >               char *dot;
> > +             size_t kplen;
> >
> >               kp = &__start___param[i];
> > +             kplen = strlen(kp->name);
> >
> >               /* We do not handle args without periods. */
> > -             dot = memchr(kp->name, '.', MAX_KBUILD_MODNAME);
> > +             if (kplen > MAX_KBUILD_MODNAME) {
> > +                     DEBUGP("kernel parameter %s is too long\n", kp->name);
> 
> how about
>         kernel parameter name %s is too long
> or
>         kernel parameter name is too long: %s
> 
> (primary is addition of "name")
Yes, "name" should be added, thanks.
> 
> > +                     continue;
> > +             }
> > +             dot = memchr(kp->name, '.', kplen);
> >               if (!dot) {
> >                       DEBUGP("couldn't find period in %s\n", kp->name);
> >                       continue;
> > -
> 

Regards
dave

====================================================

Signed-off-by: Dave Young <hidave.darkstar@gmail.com> 

---
kernel/params.c |    8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff -upr linux/kernel/params.c linux.new/kernel/params.c
--- linux/kernel/params.c	2007-10-08 14:30:06.000000000 +0800
+++ linux.new/kernel/params.c	2007-10-09 09:16:55.000000000 +0800
@@ -592,11 +592,17 @@ static void __init param_sysfs_builtin(v
 
 	for (i=0; i < __stop___param - __start___param; i++) {
 		char *dot;
+		size_t kplen;
 
 		kp = &__start___param[i];
+		kplen = strlen(kp->name);
 
 		/* We do not handle args without periods. */
-		dot = memchr(kp->name, '.', MAX_KBUILD_MODNAME);
+		if (kplen > MAX_KBUILD_MODNAME) {
+			DEBUGP("kernel parameter name is too long: %s\n", kp->name);
+			continue;
+		}
+		dot = memchr(kp->name, '.', kplen);
 		if (!dot) {
 			DEBUGP("couldn't find period in %s\n", kp->name);
 			continue;

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

end of thread, other threads:[~2007-10-09  1:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-08  6:50 [PATCH] param_sysfs_builtin memchr argument fix Dave Young
2007-10-08  7:02 ` WANG Cong
  -- strict thread matches above, loose matches on Subject: below --
2007-10-08  7:17 Dave Young
2007-10-08 16:13 ` Randy Dunlap
     [not found]   ` <a8e1da0710081807l74ca63ayf93183eac75193a@mail.gmail.com>
2007-10-09  1:21     ` Dave Young

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox