Skip to contentSkip to conversation

param_sysfs_builtin memchr argument fix

PATCH Dave Young 2 participants 3 messages Oct 8, 2007 – Oct 9, 2007 1 message not in the archive

lore
Share & tools
lore

Dave Young

author
#0 lore raw

Hi,
Thanks for comment.
fixed.

Regards
dave
-----

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

---
kernel/params.c | 8 +++++++-

1 file changed, 7 insertions(+), 1 deletion(-)
kernel/params.c +7 -1
diff -upr linux/kernel/params.c linux.new/kernel/params.c
@@ -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;
#1 lore raw
Quoted 10 lines · 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 ?

Quoted 12 lines

---
kernel/params.c | 8 +++++++-

1 file changed, 7 insertions(+), 1 deletion(-)

diff -upr linux/kernel/params.c linux.new/kernel/params.c

kernel/params.c +0 -0
@@ -592,11 +592,17 @@ static void __init param_sysfs_builtin(v
 
 	for (i=0; i < __stop___param - __start___param; i++) {

kernel/params.c static void __init param_sysfs_builtin(v · line 602

Quoted 10 lines
kernel/params.c +4 -1
 		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")

kernel/params.c static void __init param_sysfs_builtin(v

Quoted 7 lines
kernel/params.c +3 -1
+			continue;
+		}
+		dot = memchr(kp->name, '.', kplen);
 		if (!dot) {
 			DEBUGP("couldn't find period in %s\n", kp->name);
 			continue;
-

---
~Randy

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#3 lore raw
Quoted 4 lines
Quoted 2 lines

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.

Quoted 30 lines
Quoted 14 lines

---
kernel/params.c | 8 +++++++-

1 file changed, 7 insertions(+), 1 deletion(-)

diff -upr linux/kernel/params.c linux.new/kernel/params.c

kernel/params.c 2007-10-08 15:13:04.000000000 +0800 renamed from kernel/params.c 2007-10-08 14:30:06.000000000 +0800 +0 -0
@@ -592,11 +592,17 @@ static void __init param_sysfs_builtin(v
 
      for (i=0; i < __stop___param - __start___param; i++) {

kernel/params.c 2007-10-08 15:13:04.000000000 +0800 static void __init param_sysfs_builtin(v · line 602

Quoted 10 lines
kernel/params.c 2007-10-08 15:13:04.000000000 +0800 renamed from kernel/params.c 2007-10-08 14:30:06.000000000 +0800 +4 -1
              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

Quoted 1 line

(primary is addition of "name")

Yes, "name" should be added, thanks.

Quoted 9 lines

kernel/params.c 2007-10-08 15:13:04.000000000 +0800 static void __init param_sysfs_builtin(v

Quoted 8 lines
kernel/params.c 2007-10-08 15:13:04.000000000 +0800 renamed from kernel/params.c 2007-10-08 14:30:06.000000000 +0800 +3 -1
+                     continue;
+             }
+             dot = memchr(kp->name, '.', kplen);
              if (!dot) {
                      DEBUGP("couldn't find period in %s\n", kp->name);
                      continue;
-

Regards
dave

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

---
kernel/params.c | 8 +++++++-

1 file changed, 7 insertions(+), 1 deletion(-)
kernel/params.c +7 -1
diff -upr linux/kernel/params.c linux.new/kernel/params.c
@@ -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;