LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] Kernel parameter parsing fix
@ 2004-05-21 10:07 Zhu, Yi
  2004-05-21 10:13 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Zhu, Yi @ 2004-05-21 10:07 UTC (permalink / raw)
  To: linux-kernel; +Cc: Andrew Morton


Hi,

Must all the kernel parameters have trailing '=' at the end of the param
string?
If not, I think below patch is useful to avoid potential problems.

Thanks,

--- linux-2.6.6.orig/init/main.c	2004-05-14 13:38:31.000000000
+0800
+++ linux-2.6.6/init/main.c	2004-05-15 00:25:41.339261792 +0800
@@ -149,11 +149,15 @@ static int __init obsolete_checksetup(ch  {
 	struct obs_kernel_param *p;
 	extern struct obs_kernel_param __setup_start, __setup_end;
+	char *ptr;
+	int len = strlen(line);
 
+	if ((ptr = strchr(line, '=')))
+		len = ptr - line;
 	p = &__setup_start;
 	do {
 		int n = strlen(p->str);
-		if (!strncmp(line, p->str, n)) {
+		if (len <= n && !strncmp(line, p->str, n)) {
 			if (!p->setup_func) {
 				printk(KERN_WARNING "Parameter %s is
obsolete, ignored\n", p->str);
 				return 1;


-----------------------------------------------------------------
Opinions expressed are those of the author and do not represent Intel
Corp.

- Zhu Yi (Chuyee)

GnuPG v1.0.6 (GNU/Linux)
http://cn.geocities.com/chewie_chuyee/gpg.txt or
$ gpg --keyserver wwwkeys.pgp.net --recv-keys 71C34820
1024D/71C34820 C939 2B0B FBCE 1D51 109A  55E5 8650 DB90 71C3 4820 

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

* Re: [PATCH] Kernel parameter parsing fix
  2004-05-21 10:07 [PATCH] Kernel parameter parsing fix Zhu, Yi
@ 2004-05-21 10:13 ` Andrew Morton
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2004-05-21 10:13 UTC (permalink / raw)
  To: Zhu, Yi; +Cc: linux-kernel

"Zhu, Yi" <yi.zhu@intel.com> wrote:
>
> 
> Hi,
> 
> Must all the kernel parameters have trailing '=' at the end of the param
> string?
> If not, I think below patch is useful to avoid potential problems.

Can you explain waht problem this solves?  An example?

> 
> --- linux-2.6.6.orig/init/main.c	2004-05-14 13:38:31.000000000
> +0800

The patch is wordwrapped


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

* Re: [PATCH] Kernel parameter parsing fix
       [not found] <3ACA40606221794F80A5670F0AF15F8403FD31C2@PDSMSX403.ccr.corp.intel.com>
@ 2004-05-22 14:43 ` Zhu, Yi
  0 siblings, 0 replies; 4+ messages in thread
From: Zhu, Yi @ 2004-05-22 14:43 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Kernel Mailing List

On Fri, 21 May 2004, Andrew Morton wrote:
> 
> Can you explain waht problem this solves?  An example?

The real problem happens on 2.6.5 -mm kernel, but not vanilla kernel
because of the early_param patch.

For example in arch/i386/kernel/setup.c:
__early_param("acpi", early_acpi);

In drivers/acpi/osl.c:
__setup("acpi_os_name=", acpi_os_name_setup);

So if one passes kernel parameter in the bootloader as below,

"acpi=force acpi_os_name=my_override_name"

the "acpi_os_name=" parameter will take the setup func for "acpi",
because they begin with the same string "acpi".


Vanilla kernel doesn't have the problem now because most of the
parameter strings have a trailing '=', so "acpi_os_name" won't
take the setup func for "acpi=". But a safer way is to checkup 
the parameter string when parsing it as the patch did.

> 
> The patch is wordwrapped
Sorry, please try this time.

--- linux-2.6.6.orig/init/main.c	2004-05-14 13:38:31.000000000 +0800
+++ linux-2.6.6/init/main.c	2004-05-15 00:25:41.339261792 +0800
@@ -149,11 +149,15 @@ static int __init obsolete_checksetup(ch
 {
 	struct obs_kernel_param *p;
 	extern struct obs_kernel_param __setup_start, __setup_end;
+	char *ptr;
+	int len = strlen(line);
 
+	if ((ptr = strchr(line, '=')))
+		len = ptr - line;
 	p = &__setup_start;
 	do {
 		int n = strlen(p->str);
-		if (!strncmp(line, p->str, n)) {
+		if (len <= n && !strncmp(line, p->str, n)) {
 			if (!p->setup_func) {
 				printk(KERN_WARNING "Parameter %s is
obsolete, ignored\n", p->str);
 				return 1;


Thanks,
-- 
-----------------------------------------------------------------
Opinions expressed are those of the author and do not represent
Intel Corp.

Zhu Yi (Chuyee)

GnuPG v1.0.6 (GNU/Linux)
http://cn.geocities.com/chewie_chuyee/gpg.txt or
$ gpg --keyserver wwwkeys.pgp.net --recv-keys 71C34820
1024D/71C34820 C939 2B0B FBCE 1D51 109A  55E5 8650 DB90 71C3 4820


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

* [PATCH] Kernel parameter parsing fix
@ 2004-05-21  5:53 Zhu, Yi
  0 siblings, 0 replies; 4+ messages in thread
From: Zhu, Yi @ 2004-05-21  5:53 UTC (permalink / raw)
  To: linux-kernel


Hi,

Must all the kernel parameters have trailing '=' at the end of the param
string?
If not, I think below patch is useful to avoid potential problems.

Thanks,
-yi

--- linux-2.6.6.orig/init/main.c	2004-05-14 13:38:31.000000000
+0800
+++ linux-2.6.6/init/main.c	2004-05-15 00:25:41.339261792 +0800
@@ -149,11 +149,15 @@ static int __init obsolete_checksetup(ch
 {
 	struct obs_kernel_param *p;
 	extern struct obs_kernel_param __setup_start, __setup_end;
+	char *ptr;
+	int len = strlen(line);
 
+	if ((ptr = strchr(line, '=')))
+		len = ptr - line;
 	p = &__setup_start;
 	do {
 		int n = strlen(p->str);
-		if (!strncmp(line, p->str, n)) {
+		if (len <= n && !strncmp(line, p->str, n)) {
 			if (!p->setup_func) {
 				printk(KERN_WARNING "Parameter %s is
obsolete, ignored\n", p->str);
 				return 1;


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

end of thread, other threads:[~2004-05-22 14:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-21 10:07 [PATCH] Kernel parameter parsing fix Zhu, Yi
2004-05-21 10:13 ` Andrew Morton
     [not found] <3ACA40606221794F80A5670F0AF15F8403FD31C2@PDSMSX403.ccr.corp.intel.com>
2004-05-22 14:43 ` Zhu, Yi
  -- strict thread matches above, loose matches on Subject: below --
2004-05-21  5:53 Zhu, Yi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).