linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* udev - Shouldn't we blacklist some devices?
@ 2004-01-03 20:07 Kay Sievers
  2004-01-03 21:48 ` Greg KH
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Kay Sievers @ 2004-01-03 20:07 UTC (permalink / raw)
  To: linux-hotplug

While connecting my flash reader to the USB bus I get:

Jan  3 20:56:58 pim udev[31673]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:2/dev'
Jan  3 20:56:59 pim udev[31695]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:3/dev'
Jan  3 20:56:59 pim udev[31514]: sleep_for_dev: looking for '/sys/class/scsi_host/host54/dev'
Jan  3 20:56:59 pim udev[31627]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:0/dev'
Jan  3 20:56:59 pim udev[31650]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:1/dev'
Jan  3 20:56:59 pim udev[31673]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:2/dev'
Jan  3 20:57:00 pim udev[31695]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:3/dev'
Jan  3 20:57:00 pim udev[31514]: sleep_for_dev: looking for '/sys/class/scsi_host/host54/dev'
Jan  3 20:57:00 pim udev[31627]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:0/dev'
Jan  3 20:57:00 pim udev[31650]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:1/dev'
Jan  3 20:57:00 pim udev[31673]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:2/dev'
Jan  3 20:57:01 pim udev[31695]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:3/dev'
Jan  3 20:57:01 pim udev[31514]: sleep_for_dev: looking for '/sys/class/scsi_host/host54/dev'


Shouldn't we blacklist devices like  /sys/class/scsi_device/*, /sys/class/scsi_host/* ?

thanks,
Kay


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

* Re: udev - Shouldn't we blacklist some devices?
  2004-01-03 20:07 udev - Shouldn't we blacklist some devices? Kay Sievers
@ 2004-01-03 21:48 ` Greg KH
  2004-01-03 23:07 ` Kay Sievers
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2004-01-03 21:48 UTC (permalink / raw)
  To: linux-hotplug

On Sat, Jan 03, 2004 at 09:07:53PM +0100, Kay Sievers wrote:
> While connecting my flash reader to the USB bus I get:
> 
> Jan  3 20:56:58 pim udev[31673]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:2/dev'
> Jan  3 20:56:59 pim udev[31695]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:3/dev'
> Jan  3 20:56:59 pim udev[31514]: sleep_for_dev: looking for '/sys/class/scsi_host/host54/dev'
> Jan  3 20:56:59 pim udev[31627]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:0/dev'
> Jan  3 20:56:59 pim udev[31650]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:1/dev'
> Jan  3 20:56:59 pim udev[31673]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:2/dev'
> Jan  3 20:57:00 pim udev[31695]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:3/dev'
> Jan  3 20:57:00 pim udev[31514]: sleep_for_dev: looking for '/sys/class/scsi_host/host54/dev'
> Jan  3 20:57:00 pim udev[31627]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:0/dev'
> Jan  3 20:57:00 pim udev[31650]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:1/dev'
> Jan  3 20:57:00 pim udev[31673]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:2/dev'
> Jan  3 20:57:01 pim udev[31695]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:3/dev'
> Jan  3 20:57:01 pim udev[31514]: sleep_for_dev: looking for '/sys/class/scsi_host/host54/dev'
> 
> 
> Shouldn't we blacklist devices like  /sys/class/scsi_device/*, /sys/class/scsi_host/* ?

Yes we should, as we try to remove those device nodes when the devices
get removed (look for the 'trying to remove host54' messages), which
could be very dangerous.

thanks,

greg k-h


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

* Re: udev - Shouldn't we blacklist some devices?
  2004-01-03 20:07 udev - Shouldn't we blacklist some devices? Kay Sievers
  2004-01-03 21:48 ` Greg KH
@ 2004-01-03 23:07 ` Kay Sievers
  2004-01-03 23:31 ` Greg KH
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Kay Sievers @ 2004-01-03 23:07 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 1014 bytes --]

On Sat, Jan 03, 2004 at 01:48:57PM -0800, Greg KH wrote:
> On Sat, Jan 03, 2004 at 09:07:53PM +0100, Kay Sievers wrote:
> > While connecting my flash reader to the USB bus I get:
> > 
> > Jan  3 20:56:58 pim udev[31673]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:2/dev'
> > Jan  3 20:56:59 pim udev[31695]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:3/dev'
> > Jan  3 20:56:59 pim udev[31514]: sleep_for_dev: looking for '/sys/class/scsi_host/host54/dev'
> > 
> > Shouldn't we blacklist devices like  /sys/class/scsi_device/*, /sys/class/scsi_host/* ?
> 
> Yes we should, as we try to remove those device nodes when the devices
> get removed (look for the 'trying to remove host54' messages), which
> could be very dangerous.
> 

So, here we go:

Blacklist devices that we don't want to process, like:
/sys/class/scsi_device/*, /sys/class/scsi_host/*,
cause these devices are handled by the block device events we receive
and we don't try to remove non existing nodes.


thanks,
Kay

[-- Attachment #2: 01-blacklist-for-devices.diff --]
[-- Type: text/plain, Size: 802 bytes --]

diff -Nru a/udev.c b/udev.c
--- a/udev.c	Sat Jan  3 23:58:38 2004
+++ b/udev.c	Sat Jan  3 23:58:38 2004
@@ -139,12 +139,19 @@
 	return retval;
 }
 
+static char *dev_path_blacklist[] = {
+	"class/scsi_host",
+	"class/scsi_device",
+	""
+};
+
 static inline int udev_hotplug(int argc, char **argv)
 {
 	char *action;
 	char *devpath;
 	char *subsystem;
 	int retval = -EINVAL;
+	int i;
 
 	subsystem = argv[1];
 
@@ -160,6 +167,16 @@
 	    !strstr(devpath, "block")) {
 		dbg("not a block or class device");
 		goto exit;
+	}
+
+	/* skip blacklisted path */
+	i = 0;
+	while (dev_path_blacklist[i][0] != '\0') {
+		if (strstr(devpath, dev_path_blacklist[i])) {
+			dbg("device with path '%s' is blacklisted", devpath);
+			goto exit;
+		}
+		i++;
 	}
 
 	/* but we don't care about net class devices */

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

* Re: udev - Shouldn't we blacklist some devices?
  2004-01-03 20:07 udev - Shouldn't we blacklist some devices? Kay Sievers
  2004-01-03 21:48 ` Greg KH
  2004-01-03 23:07 ` Kay Sievers
@ 2004-01-03 23:31 ` Greg KH
  2004-01-03 23:42 ` Kay Sievers
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2004-01-03 23:31 UTC (permalink / raw)
  To: linux-hotplug

On Sun, Jan 04, 2004 at 12:07:21AM +0100, Kay Sievers wrote:
> On Sat, Jan 03, 2004 at 01:48:57PM -0800, Greg KH wrote:
> > On Sat, Jan 03, 2004 at 09:07:53PM +0100, Kay Sievers wrote:
> > > While connecting my flash reader to the USB bus I get:
> > > 
> > > Jan  3 20:56:58 pim udev[31673]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:2/dev'
> > > Jan  3 20:56:59 pim udev[31695]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:3/dev'
> > > Jan  3 20:56:59 pim udev[31514]: sleep_for_dev: looking for '/sys/class/scsi_host/host54/dev'
> > > 
> > > Shouldn't we blacklist devices like  /sys/class/scsi_device/*, /sys/class/scsi_host/* ?
> > 
> > Yes we should, as we try to remove those device nodes when the devices
> > get removed (look for the 'trying to remove host54' messages), which
> > could be very dangerous.
> > 
> 
> So, here we go:
> 
> Blacklist devices that we don't want to process, like:
> /sys/class/scsi_device/*, /sys/class/scsi_host/*,
> cause these devices are handled by the block device events we receive
> and we don't try to remove non existing nodes.

How about this patch instead (not tested)?  It removes the explicit test
for net class devices.

thanks,

greg k-h


=== udev.c 1.27 vs edited ==--- 1.27/udev.c	Tue Dec 30 16:33:12 2003
+++ edited/udev.c	Sat Jan  3 15:29:00 2004
@@ -139,12 +139,20 @@
 	return retval;
 }
 
+static char *subsystem_blacklist[] = {
+	"net",
+	"scsi_host",
+	"scsi_device",
+	"",
+};
+
 static inline int udev_hotplug(int argc, char **argv)
 {
 	char *action;
 	char *devpath;
 	char *subsystem;
 	int retval = -EINVAL;
+	int i;
 
 	subsystem = argv[1];
 
@@ -162,10 +170,14 @@
 		goto exit;
 	}
 
-	/* but we don't care about net class devices */
-	if (strcmp(subsystem, "net") = 0) {
-		dbg("don't care about net devices");
-		goto exit;
+	/* skip blacklisted subsystems */
+	i = 0;
+	while (subsystem_blacklist[i][0] != '\0') {
+		if (strcmp(subsystem, subsystem_blacklist[i])) {
+			dbg("don't care about '%s' devices", subsystem);
+			goto exit;
+		}
+		i++;
 	}
 
 	action = get_action();


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

* Re: udev - Shouldn't we blacklist some devices?
  2004-01-03 20:07 udev - Shouldn't we blacklist some devices? Kay Sievers
                   ` (2 preceding siblings ...)
  2004-01-03 23:31 ` Greg KH
@ 2004-01-03 23:42 ` Kay Sievers
  2004-01-04  0:07 ` Kay Sievers
  2004-01-04  8:20 ` Greg KH
  5 siblings, 0 replies; 7+ messages in thread
From: Kay Sievers @ 2004-01-03 23:42 UTC (permalink / raw)
  To: linux-hotplug

On Sat, Jan 03, 2004 at 03:31:49PM -0800, Greg KH wrote:
> On Sun, Jan 04, 2004 at 12:07:21AM +0100, Kay Sievers wrote:
> > On Sat, Jan 03, 2004 at 01:48:57PM -0800, Greg KH wrote:
> > > On Sat, Jan 03, 2004 at 09:07:53PM +0100, Kay Sievers wrote:
> > > > While connecting my flash reader to the USB bus I get:
> > > > 
> > > > Jan  3 20:56:58 pim udev[31673]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:2/dev'
> > > > Jan  3 20:56:59 pim udev[31695]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:3/dev'
> > > > Jan  3 20:56:59 pim udev[31514]: sleep_for_dev: looking for '/sys/class/scsi_host/host54/dev'
> > > > 
> > > > Shouldn't we blacklist devices like  /sys/class/scsi_device/*, /sys/class/scsi_host/* ?
> > > 
> > > Yes we should, as we try to remove those device nodes when the devices
> > > get removed (look for the 'trying to remove host54' messages), which
> > > could be very dangerous.
> > > 
> > 
> > So, here we go:
> > 
> > Blacklist devices that we don't want to process, like:
> > /sys/class/scsi_device/*, /sys/class/scsi_host/*,
> > cause these devices are handled by the block device events we receive
> > and we don't try to remove non existing nodes.
> 
> How about this patch instead (not tested)?  It removes the explicit test
> for net class devices.

Nice, looks good.
I've tested it:

Jan  4 00:38:40 pim udev[4389]: udev_hotplug: looking at '/class/scsi_device/62:0:0:0'
Jan  4 00:38:40 pim udev[4389]: udev_hotplug: don't care about 'scsi_device' devices

Jan  4 00:38:41 pim udev[4562]: udev_hotplug: looking at '/class/scsi_host/host62'
Jan  4 00:38:41 pim udev[4562]: udev_hotplug: don't care about 'scsi_host' devices


Kay


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

* Re: udev - Shouldn't we blacklist some devices?
  2004-01-03 20:07 udev - Shouldn't we blacklist some devices? Kay Sievers
                   ` (3 preceding siblings ...)
  2004-01-03 23:42 ` Kay Sievers
@ 2004-01-04  0:07 ` Kay Sievers
  2004-01-04  8:20 ` Greg KH
  5 siblings, 0 replies; 7+ messages in thread
From: Kay Sievers @ 2004-01-04  0:07 UTC (permalink / raw)
  To: linux-hotplug

On Sun, Jan 04, 2004 at 12:42:04AM +0100, Kay Sievers wrote:
> On Sat, Jan 03, 2004 at 03:31:49PM -0800, Greg KH wrote:
> > On Sun, Jan 04, 2004 at 12:07:21AM +0100, Kay Sievers wrote:
> > > On Sat, Jan 03, 2004 at 01:48:57PM -0800, Greg KH wrote:
> > > > On Sat, Jan 03, 2004 at 09:07:53PM +0100, Kay Sievers wrote:
> > > > > While connecting my flash reader to the USB bus I get:
> > > > > 
> > > > > Jan  3 20:56:58 pim udev[31673]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:2/dev'
> > > > > Jan  3 20:56:59 pim udev[31695]: sleep_for_dev: looking for '/sys/class/scsi_device/54:0:0:3/dev'
> > > > > Jan  3 20:56:59 pim udev[31514]: sleep_for_dev: looking for '/sys/class/scsi_host/host54/dev'
> > > > > 
> > > > > Shouldn't we blacklist devices like  /sys/class/scsi_device/*, /sys/class/scsi_host/* ?
> > > > 
> > > > Yes we should, as we try to remove those device nodes when the devices
> > > > get removed (look for the 'trying to remove host54' messages), which
> > > > could be very dangerous.
> > > > 
> > > 
> > > So, here we go:
> > > 
> > > Blacklist devices that we don't want to process, like:
> > > /sys/class/scsi_device/*, /sys/class/scsi_host/*,
> > > cause these devices are handled by the block device events we receive
> > > and we don't try to remove non existing nodes.
> > 
> > How about this patch instead (not tested)?  It removes the explicit test
> > for net class devices.
> 
> Nice, looks good.
> I've tested it:
> 
> Jan  4 00:38:40 pim udev[4389]: udev_hotplug: looking at '/class/scsi_device/62:0:0:0'
> Jan  4 00:38:40 pim udev[4389]: udev_hotplug: don't care about 'scsi_device' devices
> 
> Jan  4 00:38:41 pim udev[4562]: udev_hotplug: looking at '/class/scsi_host/host62'
> Jan  4 00:38:41 pim udev[4562]: udev_hotplug: don't care about 'scsi_host' devices

Oh, my testing is good, but reading to the end of the debug is better :)
It should be:
  if (strcmp(subsystem, subsystem_blacklist[i]) = 0) {

otherwise we skip everything.

Kay


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

* Re: udev - Shouldn't we blacklist some devices?
  2004-01-03 20:07 udev - Shouldn't we blacklist some devices? Kay Sievers
                   ` (4 preceding siblings ...)
  2004-01-04  0:07 ` Kay Sievers
@ 2004-01-04  8:20 ` Greg KH
  5 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2004-01-04  8:20 UTC (permalink / raw)
  To: linux-hotplug

On Sun, Jan 04, 2004 at 01:07:49AM +0100, Kay Sievers wrote:
> 
> Oh, my testing is good, but reading to the end of the debug is better :)
> It should be:
>   if (strcmp(subsystem, subsystem_blacklist[i]) = 0) {
> 
> otherwise we skip everything.

Heh, oops.  Thanks, I've fixed that and pushed the change.

thanks,

greg k-h


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

end of thread, other threads:[~2004-01-04  8:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-03 20:07 udev - Shouldn't we blacklist some devices? Kay Sievers
2004-01-03 21:48 ` Greg KH
2004-01-03 23:07 ` Kay Sievers
2004-01-03 23:31 ` Greg KH
2004-01-03 23:42 ` Kay Sievers
2004-01-04  0:07 ` Kay Sievers
2004-01-04  8:20 ` Greg KH

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).