public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* modprobe bug for aliases with regular expressions
@ 2006-04-13 23:35 Greg KH
  2006-04-14  4:59 ` Rusty Russell
  2006-04-14  5:17 ` Thayumanavar Sachithanantham
  0 siblings, 2 replies; 4+ messages in thread
From: Greg KH @ 2006-04-13 23:35 UTC (permalink / raw)
  To: Rusty Russell; +Cc: kay.sievers, linux-kernel

Recently it's been pointed out to me that the modprobe functionality
with aliases doesn't quite work properly for some USB modules.
Specifically, the usb-storage driver has a lot of aliases with regular
expressions for the bcd ranges.  Here's an example of it failing with a
real device:

$ modprobe -n -v --first-time usb:v054Cp0010d0410dc00dsc00dp00ic08iscFFip01
FATAL: Module usb:v054Cp0010d0410dc00dsc00dp00ic08iscFFip01 not found.

yet if we change the bcd range by replacing the first 0 with a 1 it
somehow works:

$ modprobe -n -v --first-time usb:v054Cp0010d0400dc00dsc00dp00ic08iscFFip01
insmod /lib/modules/2.6.17-rc1-gkh/kernel/drivers/usb/storage/libusual.ko

(yet this isn't a solution as the device does not have a 1 in that
position...)

If you look at the aliases for this driver, it looks like it should all
work properly:

$ modinfo libusual | grep v054Cp0010
alias:          usb:v054Cp0010d010[6-9]dc*dsc*dp*ic*isc*ip*
alias:          usb:v054Cp0010d0450dc*dsc*dp*ic*isc*ip*
alias:          usb:v054Cp0010d01[1-9]*dc*dsc*dp*ic*isc*ip*
alias:          usb:v054Cp0010d04[0-4]*dc*dsc*dp*ic*isc*ip*
alias:          usb:v054Cp0010d0[2-3]*dc*dsc*dp*ic*isc*ip*
alias:          usb:v054Cp0010d0600dc*dsc*dp*ic*isc*ip*
alias:          usb:v054Cp0010d05*dc*dsc*dp*ic*isc*ip*


I tried a simple fnmatch() call with the string and pattern, and it
works just fine:

#include <fnmatch.h>
#include <stdio.h>

int main (void)
{
	char *pattern = "usb:v054Cp0010d010[6-9]dc*dsc*dp*ic*isc*ip*";
	char *string = "usb:v054Cp0010d0410dc00dsc00dp00ic08iscFFip01";
	int result;

	result = fnmatch(pattern, string, 0);
	printf("result = %d\n", result);
	return 0;
}


$ gcc test.c -o test
$ ./test
result = 0

I tried to dig through the module-init-tools code (am using version
3.2.2 here) and try to track it down, but failed badly.  Any thoughts as
to what would be wrong here?

thanks,

greg k-h

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

* Re: modprobe bug for aliases with regular expressions
  2006-04-13 23:35 modprobe bug for aliases with regular expressions Greg KH
@ 2006-04-14  4:59 ` Rusty Russell
  2006-04-14 16:19   ` Greg KH
  2006-04-14  5:17 ` Thayumanavar Sachithanantham
  1 sibling, 1 reply; 4+ messages in thread
From: Rusty Russell @ 2006-04-14  4:59 UTC (permalink / raw)
  To: Greg KH; +Cc: kay.sievers, linux-kernel

On Thu, 2006-04-13 at 16:35 -0700, Greg KH wrote:
> Recently it's been pointed out to me that the modprobe functionality
> with aliases doesn't quite work properly for some USB modules.

Sorry, my bad.  I got a patch for this a while ago from Sam Morris.
Originally noone was using ranges in [].

This is fixed in 3.3-pre1.  I should release 3.3 proper sometime this
weekend.

Thanks for the poke!
Rusty.
-- 
 ccontrol: http://ozlabs.org/~rusty/ccontrol


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

* Re: modprobe bug for aliases with regular expressions
  2006-04-13 23:35 modprobe bug for aliases with regular expressions Greg KH
  2006-04-14  4:59 ` Rusty Russell
@ 2006-04-14  5:17 ` Thayumanavar Sachithanantham
  1 sibling, 0 replies; 4+ messages in thread
From: Thayumanavar Sachithanantham @ 2006-04-14  5:17 UTC (permalink / raw)
  To: Greg KH; +Cc: Rusty Russell, kay.sievers, linux-kernel

On 4/14/06, Greg KH <greg@kroah.com> wrote:
> Recently it's been pointed out to me that the modprobe functionality
> with aliases doesn't quite work properly for some USB modules.
> Specifically, the usb-storage driver has a lot of aliases with regular
> expressions for the bcd ranges.  Here's an example of it failing with a
> real device:
>
> $ modprobe -n -v --first-time usb:v054Cp0010d0410dc00dsc00dp00ic08iscFFip01
> FATAL: Module usb:v054Cp0010d0410dc00dsc00dp00ic08iscFFip01 not found.
>
> yet if we change the bcd range by replacing the first 0 with a 1 it
> somehow works:
>
> $ modprobe -n -v --first-time usb:v054Cp0010d0400dc00dsc00dp00ic08iscFFip01
> insmod /lib/modules/2.6.17-rc1-gkh/kernel/drivers/usb/storage/libusual.ko
>
> (yet this isn't a solution as the device does not have a 1 in that
> position...)

      It's because in modprobe.c, in the read_config_file , in the
wildcard , the "-" (hyphen) is turned into underscore (_) causing the
fnmatch not to match the first RE.
  a quick change to check this issue is
following change in read_config_file function of modprobe.c should fix it.
                if (strcmp(cmd, "alias") == 0) {
                        char *wildcard
                                = strsep_skipspace(&ptr, "\t ");
                        char *realname
                                = strsep_skipspace(&ptr, "\t ");


S.Thayumanavar

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

* Re: modprobe bug for aliases with regular expressions
  2006-04-14  4:59 ` Rusty Russell
@ 2006-04-14 16:19   ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2006-04-14 16:19 UTC (permalink / raw)
  To: Rusty Russell; +Cc: kay.sievers, linux-kernel

On Fri, Apr 14, 2006 at 02:59:30PM +1000, Rusty Russell wrote:
> On Thu, 2006-04-13 at 16:35 -0700, Greg KH wrote:
> > Recently it's been pointed out to me that the modprobe functionality
> > with aliases doesn't quite work properly for some USB modules.
> 
> Sorry, my bad.  I got a patch for this a while ago from Sam Morris.
> Originally noone was using ranges in [].
> 
> This is fixed in 3.3-pre1.  I should release 3.3 proper sometime this
> weekend.

So, the patch that fixes it is the patch below? (needed for distros that
don't want to rev the whole package...)

thanks,

greg k-h


diff -Naur module-init-tools-3.2.2/modprobe.c module-init-tools-3.3-pre1/modprobe.c
--- module-init-tools-3.2.2/modprobe.c	2005-12-01 15:42:09.000000000 -0800
+++ module-init-tools-3.3-pre1/modprobe.c	2006-02-04 15:18:07.000000000 -0800
@@ -990,13 +990,27 @@
 	return ret;
 }
 
+/* Careful!  Don't munge - in [ ] as per Debian Bug#350915 */
 static char *underscores(char *string)
 {
 	if (string) {
 		unsigned int i;
-		for (i = 0; string[i]; i++)
-			if (string[i] == '-')
-				string[i] = '_';
+		int inbracket = 0;
+		for (i = 0; string[i]; i++) {
+			switch (string[i]) {
+			case '[':
+				inbracket++;
+				break;
+			case ']':
+				inbracket--;
+				break;
+			case '-':
+				if (!inbracket)
+					string[i] = '_';
+			}
+		}
+		if (inbracket)
+			warn("Unmatched bracket in %s\n", string);
 	}
 	return string;
 }

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

end of thread, other threads:[~2006-04-14 16:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-13 23:35 modprobe bug for aliases with regular expressions Greg KH
2006-04-14  4:59 ` Rusty Russell
2006-04-14 16:19   ` Greg KH
2006-04-14  5:17 ` Thayumanavar Sachithanantham

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