2004-11-11 18:13:10

by yiding_wang

[permalink] [raw]
Subject: module tool with 2.6.9 limitation issue

I am using moudle-init-tools-3.1-pre6 with kernel 2.6.9. The new insmod seems have restrictions which failed using parameters to load a driver module.

My module parameter is in the form of modname="*************** ****", a quite long one.
Run - insmod modname.o modname="*********** *******" (with a script), it complains about the space and treats the string next to the space to be a "Unknown parameter".

By replacing the space with any character, then it complains
"modname: string parameter too long"

Reducing the length of the parameter to less than 1k character works fine.

Same long parameter string wit space in between works fine under 2.4.25 with original insmod.

Questions:
1, Is this a bug or new insmod has restrictions?
2, If it is restriction on special character such as space, or limitation on parameter length, then why and what is the limit?
3, If insmod has limitation, then what is better way to pass long parameter with some special character?

Thanks!

Eddie


2004-11-12 04:12:17

by Randy.Dunlap

[permalink] [raw]
Subject: Re: module tool with 2.6.9 limitation issue

[email protected] wrote:
> I am using moudle-init-tools-3.1-pre6 with kernel 2.6.9. The new insmod seems have restrictions which failed using parameters to load a driver module.
>
> My module parameter is in the form of modname="*************** ****", a quite long one.
> Run - insmod modname.o modname="*********** *******" (with a script), it complains about the space and treats the string next to the space to be a "Unknown parameter".
>
> By replacing the space with any character, then it complains
> "modname: string parameter too long"

Patch for that one is attached. It might be overkill,
but it works with this patch (as long as parameter value length
is <= 1024 -- not that I tried one of that length).

Rusty or anyone else, where do the quotes come from?
Here's what I enter:
insmod test_module modprm="this test"

but the kernel sees this parameter string:
"modprm=this test"
(with the quotation marks).
Who/what moved the quotation marks? Is bash doing any of that?
I don't see it in insmod or modprobe (with a quick look).

> Reducing the length of the parameter to less than 1k character works fine.

Right, parameter value length cannot be > 1024.

> Same long parameter string wit space in between works fine under 2.4.25 with original insmod.
>
> Questions:
> 1, Is this a bug or new insmod has restrictions?

The limit is actually in linux/kernel/params.c, not in insmod.
It seems a little arbitrary, but a parameter that long also seems
quite excessive. Just break it into multiple parameters.

> 2, If it is restriction on special character such as space, or limitation on parameter length, then why and what is the limit?

Just 1024 bytes in total length.

> 3, If insmod has limitation, then what is better way to pass long parameter with some special character?

Just break it into multiple parameters....

--
~Randy


Attachments:
modprm_quoted.patch (1.15 kB)

2004-11-12 04:18:25

by Randy.Dunlap

[permalink] [raw]
Subject: [PATCH] handle quoted module parameters

Here's a patch with better description.


Fix module parameter quote handling.
Module parameter strings (with spaces) are quoted like so:
"modprm=this test"
and not like this:
modprm="this test"

Signed-off-by: Randy Dunlap <[email protected]>

diffstat:=
kernel/params.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)


--
~Randy


Attachments:
modprm_quoted.patch (991.00 B)

2004-11-12 19:02:36

by yiding_wang

[permalink] [raw]
Subject: RE: [PATCH] handle quoted module parameters

Hello Randy,

Thanks for your two responses!

Based on your patch, the format of argument will be changed from standard format before:
Used to be:
modprm1=first,ext modprm2=second,ext modprm3="third1,ext third2,ext"
where the quotation in modprm3 represents the whole string, including space, to be the value of third parameter modprm3.

Now the patch changes modprm3 to "modprm3=third1,ext third2,ext" which equivalent to putting quotation mark on normal parameter define "modprm1=first,ext". Do you think linux community will take that change?

Another question is the parameter length is not limited in 2.4.x kernel. Why this is restricted under 2.6.x. (param_set_charp())?

Regards,

Eddie


-----Original Message-----
From: Randy.Dunlap [mailto:[email protected]]
Sent: Thursday, November 11, 2004 8:17 PM
To: Randy.Dunlap
Cc: [email protected]; [email protected];
[email protected]; [email protected]; akpm
Subject: [PATCH] handle quoted module parameters


Here's a patch with better description.


Fix module parameter quote handling.
Module parameter strings (with spaces) are quoted like so:
"modprm=this test"
and not like this:
modprm="this test"

Signed-off-by: Randy Dunlap <[email protected]>

diffstat:=
kernel/params.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)


--
~Randy

2004-11-12 19:41:59

by Adam Heath

[permalink] [raw]
Subject: RE: [PATCH] handle quoted module parameters

On Fri, 12 Nov 2004, wrote:

> Hello Randy,
>
> Thanks for your two responses!
>
> Based on your patch, the format of argument will be changed from standard format before:
> Used to be:
> modprm1=first,ext modprm2=second,ext modprm3="third1,ext third2,ext"
> where the quotation in modprm3 represents the whole string, including space, to be the value of third parameter modprm3.
>
> Now the patch changes modprm3 to "modprm3=third1,ext third2,ext" which equivalent to putting quotation mark on normal parameter define "modprm1=first,ext". Do you think linux community will take that change?
>
> Another question is the parameter length is not limited in 2.4.x kernel. Why this is restricted under 2.6.x. (param_set_charp())?

Er, no, that's a wrong assumption.

Quoting like this is handled by the shell. It tells it how to parse the
single cmdline string, into separate parts.

There is *no* difference between:

foo="111 222 333"\ 444' 555'

and

foo='111 222 333 444 555'

and

foo="111 222 333 444 555'

2004-11-12 21:58:16

by yiding_wang

[permalink] [raw]
Subject: RE: [PATCH] handle quoted module parameters

>There is *no* difference between:
>foo="111 222 333"\ 444' 555'
>and
>foo='111 222 333 444 555'
>and
>foo="111 222 333 444 555'

But there is a difference between foo="111 222 333" and "foo=111 222 333". The new patch is changing from former to later.

Eddie


-----Original Message-----
From: Adam Heath [mailto:[email protected]]
Sent: Friday, November 12, 2004 11:41 AM
To: [email protected]
Cc: [email protected]; [email protected];
[email protected]; [email protected]; [email protected]
Subject: RE: [PATCH] handle quoted module parameters


On Fri, 12 Nov 2004, wrote:

> Hello Randy,
>
> Thanks for your two responses!
>
> Based on your patch, the format of argument will be changed from standard format before:
> Used to be:
> modprm1=first,ext modprm2=second,ext modprm3="third1,ext third2,ext"
> where the quotation in modprm3 represents the whole string, including space, to be the value of third parameter modprm3.
>
> Now the patch changes modprm3 to "modprm3=third1,ext third2,ext" which equivalent to putting quotation mark on normal parameter define "modprm1=first,ext". Do you think linux community will take that change?
>
> Another question is the parameter length is not limited in 2.4.x kernel. Why this is restricted under 2.6.x. (param_set_charp())?

Er, no, that's a wrong assumption.

Quoting like this is handled by the shell. It tells it how to parse the
single cmdline string, into separate parts.

There is *no* difference between:

foo="111 222 333"\ 444' 555'

and

foo='111 222 333 444 555'

and

foo="111 222 333 444 555'

2004-11-15 00:18:36

by Rusty Russell

[permalink] [raw]
Subject: Re: [PATCH] handle quoted module parameters

On Sat, 2004-11-13 at 14:22 -0800, Randy.Dunlap wrote:
> [email protected] wrote:
> >>There is *no* difference between:
> >>foo="111 222 333"\ 444' 555'
> >>and
> >>foo='111 222 333 444 555'
> >>and
> >>foo="111 222 333 444 555'
> >
> >
> > But there is a difference between foo="111 222 333" and "foo=111 222 333". The new patch is changing from former to later.
>
> Actually the patch allows (or _should allow_) either format for quote
> marks. I didn't remove the older code, just added support for the
> case of quote marks as "foo=this is a test".

Yes, I have no fundamental problem with the patch, but it'd need
thorough testing (eg. with __setup) since this area has broken before.

> Why is the module param length limit of 1024 a problem?

The 1024 test is there because we want to limit how much we output
through sysfs. We could up it to PAGE_SIZE-1.

Rusty.
--
A bad analogy is like a leaky screwdriver -- Richard Braakman

2004-11-15 01:17:03

by Rusty Russell

[permalink] [raw]
Subject: Re: [PATCH] handle quoted module parameters

On Thu, 2004-11-11 at 20:16 -0800, Randy.Dunlap wrote:
> Here's a patch with better description.
>
>
> Fix module parameter quote handling.
> Module parameter strings (with spaces) are quoted like so:
> "modprm=this test"
> and not like this:
> modprm="this test"

Well, the quote handling in insmod was ripped out after 3.0, exactly
because it was broken like this. But modprobe will use the latter form,
since it will paste it straight from the modprobe.conf file (which needs
quotes in options lines).

Hope that clarifies,
Rusty.
PS. module-init-tools 3.1 just out...
--
A bad analogy is like a leaky screwdriver -- Richard Braakman

2004-11-18 20:00:18

by yiding_wang

[permalink] [raw]
Subject: RE: [PATCH] handle quoted module parameters

Hello Rusty,

The broken part I encountered is from the latest module-init-tools 3.1. Is that possible to restore the allowable parameter length as it for 2.4.x, at least increase it from 1K to 4K?

Regards,

Eddie

-----Original Message-----
From: Rusty Russell [mailto:[email protected]]
Sent: Sunday, November 14, 2004 5:15 PM
To: Randy.Dunlap
Cc: [email protected]; [email protected]; lkml - Kernel Mailing
List; Andrew Morton
Subject: Re: [PATCH] handle quoted module parameters


On Thu, 2004-11-11 at 20:16 -0800, Randy.Dunlap wrote:
> Here's a patch with better description.
>
>
> Fix module parameter quote handling.
> Module parameter strings (with spaces) are quoted like so:
> "modprm=this test"
> and not like this:
> modprm="this test"

Well, the quote handling in insmod was ripped out after 3.0, exactly
because it was broken like this. But modprobe will use the latter form,
since it will paste it straight from the modprobe.conf file (which needs
quotes in options lines).

Hope that clarifies,
Rusty.
PS. module-init-tools 3.1 just out...
--
A bad analogy is like a leaky screwdriver -- Richard Braakman