mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Young <hidave.darkstar@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, gregkh@suse.de
Subject: [PATCH] param_sysfs_builtin memchr argument fix
Date: Mon, 8 Oct 2007 14:50:10 +0800	[thread overview]
Message-ID: <20071008065009.GA2862@darkstar.te-china.tietoenator.com> (raw)

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? */

             reply	other threads:[~2007-10-08  6:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-08  6:50 Dave Young [this message]
2007-10-08  7:02 ` WANG Cong
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071008065009.GA2862@darkstar.te-china.tietoenator.com \
    --to=hidave.darkstar@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®