diff options
author | Jan Kiszka <jan.kiszka@web.de> | 2007-11-14 17:00:08 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-11-16 08:12:43 -0800 |
commit | e8af293bb2f8cc44868a67e2af8010feaa7c309b (patch) | |
tree | 35c0cf39657968a98d6a58a06fc0a10b4b6db5b1 | |
parent | 2b5ee2866a4a4781158986f21fdaa3395bc27d13 (diff) | |
download | lwn-e8af293bb2f8cc44868a67e2af8010feaa7c309b.tar.gz lwn-e8af293bb2f8cc44868a67e2af8010feaa7c309b.zip |
fix param_sysfs_builtin name length check
patch 22800a2830ec07e7cc5c837999890ac47cc7f5de in mainline.
Commit faf8c714f4508207a9c81cc94dafc76ed6680b44 caused a regression:
parameter names longer than MAX_KBUILD_MODNAME will now be rejected,
although we just need to keep the module name part that short. This patch
restores the old behaviour while still avoiding that memchr is called with
its length parameter larger than the total string length.
Signed-off-by: Jan Kiszka <jan.kiszka@web.de>
Cc: Dave Young <hidave.darkstar@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Chuck Ebbert <cebbert@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | kernel/params.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/kernel/params.c b/kernel/params.c index e6101d78edf2..5e5651fd6c0b 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -595,19 +595,16 @@ static void __init param_sysfs_builtin(void) for (i=0; i < __stop___param - __start___param; i++) { char *dot; - size_t kplen; + size_t max_name_len; kp = &__start___param[i]; - kplen = strlen(kp->name); + max_name_len = + min_t(size_t, MAX_KBUILD_MODNAME, strlen(kp->name)); - /* We do not handle args without periods. */ - if (kplen > MAX_KBUILD_MODNAME) { - DEBUGP("kernel parameter name is too long: %s\n", kp->name); - continue; - } - dot = memchr(kp->name, '.', kplen); + dot = memchr(kp->name, '.', max_name_len); if (!dot) { - DEBUGP("couldn't find period in %s\n", kp->name); + DEBUGP("couldn't find period in first %d characters " + "of %s\n", MAX_KBUILD_MODNAME, kp->name); continue; } name_len = dot - kp->name; |