[PATCH] param_sysfs_builtin memchr argument fix

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Cc: <akpm@...>, <gregkh@...>
Date: Monday, October 8, 2007 - 2:50 am

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? */
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] param_sysfs_builtin memchr argument fix, Dave Young, (Mon Oct 8, 2:50 am)