public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* two 2.5 modules bugs
@ 2002-12-27 16:16 Mikael Pettersson
  2002-12-27 23:24 ` Petr Vandrovec
  2002-12-28 10:37 ` Rusty Russell
  0 siblings, 2 replies; 17+ messages in thread
From: Mikael Pettersson @ 2002-12-27 16:16 UTC (permalink / raw)
  To: rusty; +Cc: linux-kernel

1. With kernel 2.5.53 and module-init-tools-0.9.6, "modprobe tulip"
   fails and goes into an infinite CPU-consuming loop. The problem
   appears to be related to the dependency from tulip to crc32. If I
   manually modprobe crc32 before modprobe tulip, it works. If crc32
   isn't loaded, modprobe tulip first loads crc32 and then loops.

   module-init-tools-0.9.5 did not have this problem.

2. The implementation of old-style MODULE_PARMs with type "1-16s"
   is broken. Instead of splicing the parameter at the commas and
   storing pointers to the substrings in consecutive array elements,
   the whole string is stored in the array instead.

   Consider parport_pc.c, which contains (simplified):

   static const char *irq[16];
   MODULE_PARM(irq, "1-16s");

   "modprobe parport_pc irq=007" should store a pointer to "007" in
   irq[0], but instead (unsigned int)irq[0] == 0x00373030, the ASCII
   representation of "007" in little-endian. (Kernel 2.5.53 on x86,
   with module-init-tools-0.9.[56].)

/Mikael

^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: two 2.5 modules bugs
@ 2002-12-29 20:18 Mikael Pettersson
  2002-12-30  6:13 ` Rusty Russell
  0 siblings, 1 reply; 17+ messages in thread
From: Mikael Pettersson @ 2002-12-29 20:18 UTC (permalink / raw)
  To: rusty; +Cc: linux-kernel

On Sat, 28 Dec 2002 21:37:22 +1100, Rusty Russell wrote:
>> 1. With kernel 2.5.53 and module-init-tools-0.9.6, "modprobe tulip"
>>    fails and goes into an infinite CPU-consuming loop. The problem
>>    appears to be related to the dependency from tulip to crc32. If I
>>    manually modprobe crc32 before modprobe tulip, it works. If crc32
>>    isn't loaded, modprobe tulip first loads crc32 and then loops.
>> 
>>    module-init-tools-0.9.5 did not have this problem.
>
>This should be fixed in 0.9.6: a double free caused all kinds of wierd
>behavior.  Please tell me if this fixes it.

module-init-tools-0.9.7 fixed the problem.

>Ew.  I horribly misinterpreted "1-16s" to mean "a string 1-16 chars
>long".  The obvious fix (untested) is:
>
>diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.5.53/kernel/module.c working-2.5.53-sparam/kernel/module.c
>--- linux-2.5.53/kernel/module.c	2002-12-26 15:41:06.000000000 +1100
>+++ working-2.5.53-sparam/kernel/module.c	2002-12-28 21:32:34.000000000 +1100
>@@ -604,7 +604,8 @@ extern int set_obsolete(const char *val,
> 		return param_array(kp->name, val, min, max, obsparm->addr,
> 				   sizeof(long), param_set_long);
> 	case 's':
>-		return param_string(kp->name, val, min, max, obsparm->addr);
>+		return param_array(kp->name, val, min, max, obsparm->addr,
>+				   sizeof(char *), param_set_charp);
> 	}
> 	printk(KERN_ERR "Unknown obsolete parameter type %s\n", obsparm->type);
> 	return -EINVAL;

Tested. This patch makes the parport_pc module work again. Thanks.

/Mikael

^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: two 2.5 modules bugs
@ 2002-12-30 11:39 Rusty Russell
  0 siblings, 0 replies; 17+ messages in thread
From: Rusty Russell @ 2002-12-30 11:39 UTC (permalink / raw)
  To: Mikael Pettersson; +Cc: linux-kernel, torvalds

> In message <200212292018.VAA25446@harpo.it.uu.se> you write:
> > >long".  The obvious fix (untested) is:
> > >
> > Tested. This patch makes the parport_pc module work again. Thanks.
> 
> Linus, please apply.  Mikael, thanks for the excellent bug report!
> 
> Rusty.
> --
>   Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
> 
> Name: Fix MODULE_PARM for arrays of s.

And this as well.  We restore the ","s after parsing: if expect to
keep pointers to this stuff, we must not do that.

Linus, please apply.

diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .5399-linux-2.5-bk/kernel/params.c .5399-linux-2.5-bk.updated/kernel/params.c
--- .5399-linux-2.5-bk/kernel/params.c	2002-12-26 15:41:06.000000000 +1100
+++ .5399-linux-2.5-bk.updated/kernel/params.c	2002-12-30 20:30:38.000000000 +1100
@@ -233,6 +233,7 @@ int param_array(const char *name,
 	int ret;
 	unsigned int count = 0;
 	struct kernel_param kp;
+	char save;
 
 	/* Get the name right for errors. */
 	kp.name = name;
@@ -247,7 +248,6 @@ int param_array(const char *name,
 	/* We expect a comma-separated list of values. */
 	do {
 		int len;
-		char save;
 
 		if (count > max) {
 			printk(KERN_ERR "%s: can only take %i arguments\n",
@@ -256,18 +256,17 @@ int param_array(const char *name,
 		}
 		len = strcspn(val, ",");
 
-		/* Temporarily nul-terminate and parse */
+		/* nul-terminate and parse */
 		save = val[len];
 		((char *)val)[len] = '\0';
 		ret = set(val, &kp);
-		((char *)val)[len] = save;
 
 		if (ret != 0)
 			return ret;
 		kp.arg += elemsize;
 		val += len+1;
 		count++;
-	} while (val[-1] == ',');
+	} while (save == ',');
 
 	if (count < min) {
 		printk(KERN_ERR "%s: needs at least %i arguments\n",

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

end of thread, other threads:[~2002-12-30 11:31 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-27 16:16 two 2.5 modules bugs Mikael Pettersson
2002-12-27 23:24 ` Petr Vandrovec
2002-12-28 10:37 ` Rusty Russell
2002-12-28 15:40   ` Want a random entropy source? Stephen Satchell
2002-12-28 16:00     ` John Bradford
2002-12-28 16:38       ` Dr. David Alan Gilbert
2002-12-28 16:47       ` Russell King
2002-12-28 17:15         ` John Bradford
2002-12-28 20:28       ` Folkert van Heusden
2002-12-28 20:39         ` John Bradford
2002-12-28 20:53           ` Folkert van Heusden
2002-12-28 23:20         ` Stephen Satchell
2002-12-28 23:41           ` John Bradford
2002-12-28 20:27     ` Folkert van Heusden
  -- strict thread matches above, loose matches on Subject: below --
2002-12-29 20:18 two 2.5 modules bugs Mikael Pettersson
2002-12-30  6:13 ` Rusty Russell
2002-12-30 11:39 Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox