linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* usb hotplug \$DEVICE empty
@ 2004-10-25 12:32 Klaus Dittrich
  0 siblings, 0 replies; 5+ messages in thread
From: Klaus Dittrich @ 2004-10-25 12:32 UTC (permalink / raw)
  To: linux mailing-list

In 2.6.10-rc1-bk2 my hotplug script does not get the
usb-device via $DEVICE any more. 

(Yes, I have CONFIG_USB_DEVICEFS=y in .config)

Other information like ACTION PRODUCT .. is still passed.

The last kernel (I have here) which worked in this respect 
is 2.6.9-rc4-bk7.

--
Klaus

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

* Re: usb hotplug $DEVICE empty
@ 2004-10-27 11:59 Klaus Dittrich
  2004-10-29  4:24 ` [PATCH] kobject hotplug: don't let SEQNUM overwrite other vars (was Re: usb hotplug $DEVICE empty) Roland Dreier
  0 siblings, 1 reply; 5+ messages in thread
From: Klaus Dittrich @ 2004-10-27 11:59 UTC (permalink / raw)
  To: linux mailing-list

I found out why $DEVICE did not show of in /sbin/hotplug
any more. (2.6.10-rc1-bk5)

Depending on the setting of CONFIG_USB_DEVICEFS
either the environment variables DEVICE or PRODUCT
which should be passed to /sbin/hotplug become overwritten
by the environment variable SEQNUM.

This happens in kobject_hotplug() of lib/kobject_uevent.c.

The here called hotplug_ops->hotplug function usb_hotplug()
advances both, the index to envp and the pointer into buffer
but the calling function gets no notice of that.

So to add SEQNUM later on it advances index/pointer to
envp/buffer from where it has stopped before calling
usb_hotplug(), thus overwriting the first entry that 
usb_hotplug() has added before.


-- 
Klaus

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

* [PATCH] kobject hotplug: don't let SEQNUM overwrite other vars (was Re: usb hotplug $DEVICE empty)
  2004-10-27 11:59 usb hotplug $DEVICE empty Klaus Dittrich
@ 2004-10-29  4:24 ` Roland Dreier
  2004-10-29  4:38   ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Roland Dreier @ 2004-10-29  4:24 UTC (permalink / raw)
  To: Klaus Dittrich, greg; +Cc: linux mailing-list

I think this trivial patch should fix this for you.  (Greg, not sure
if you have this already -- it's not in Linus's tree yet in any case)

Prevent SEQNUM from overwriting kset-specific hotplug environment vars.

Signed-off-by: Roland Dreier <roland@topspin.com>

Index: linux-bk/lib/kobject_uevent.c
===================================================================
--- linux-bk.orig/lib/kobject_uevent.c	2004-10-28 21:20:10.000000000 -0700
+++ linux-bk/lib/kobject_uevent.c	2004-10-28 21:21:10.000000000 -0700
@@ -258,6 +258,13 @@
 	envp [i++] = scratch;
 	scratch += sprintf(scratch, "SUBSYSTEM=%s", name) + 1;
 
+	spin_lock(&sequence_lock);
+	seq = ++hotplug_seqnum;
+	spin_unlock(&sequence_lock);
+
+	envp [i++] = scratch;
+	scratch += sprintf(scratch, "SEQNUM=%lld", (long long)seq) + 1;
+
 	if (hotplug_ops->hotplug) {
 		/* have the kset specific function add its stuff */
 		retval = hotplug_ops->hotplug (kset, kobj,
@@ -270,13 +277,6 @@
 		}
 	}
 
-	spin_lock(&sequence_lock);
-	seq = ++hotplug_seqnum;
-	spin_unlock(&sequence_lock);
-
-	envp [i++] = scratch;
-	scratch += sprintf(scratch, "SEQNUM=%lld", (long long)seq) + 1;
-
 	pr_debug ("%s: %s %s seq=%lld %s %s %s %s %s\n",
 		  __FUNCTION__, argv[0], argv[1], (long long)seq,
 		  envp[0], envp[1], envp[2], envp[3], envp[4]);

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

* Re: [PATCH] kobject hotplug: don't let SEQNUM overwrite other vars (was Re: usb hotplug $DEVICE empty)
  2004-10-29  4:24 ` [PATCH] kobject hotplug: don't let SEQNUM overwrite other vars (was Re: usb hotplug $DEVICE empty) Roland Dreier
@ 2004-10-29  4:38   ` Greg KH
  2004-10-29 18:44     ` [PATCH] kobject hotplug: don't let SEQNUM overwrite other vars Roland Dreier
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2004-10-29  4:38 UTC (permalink / raw)
  To: Roland Dreier; +Cc: Klaus Dittrich, linux mailing-list

On Thu, Oct 28, 2004 at 09:24:15PM -0700, Roland Dreier wrote:
> I think this trivial patch should fix this for you.  (Greg, not sure
> if you have this already -- it's not in Linus's tree yet in any case)

No, people are still working on getting this right.

> Prevent SEQNUM from overwriting kset-specific hotplug environment vars.

No, this puts back the problem where if the hotplug() subsystem call
fails, we have already incremented the seqnum without emitting a call
with that number.

Now I know userspace needs to handle this properly anyway, but we might
as well get the kernel right, and not do stuff to make userspace unhappy
if we can obviously help it.

I'll work on fixing this up properly tomorrow,

thanks,

greg k-h

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

* Re: [PATCH] kobject hotplug: don't let SEQNUM overwrite other vars
  2004-10-29  4:38   ` Greg KH
@ 2004-10-29 18:44     ` Roland Dreier
  0 siblings, 0 replies; 5+ messages in thread
From: Roland Dreier @ 2004-10-29 18:44 UTC (permalink / raw)
  To: Greg KH; +Cc: Klaus Dittrich, linux mailing-list

    Greg> No, this puts back the problem where if the hotplug()
    Greg> subsystem call fails, we have already incremented the seqnum
    Greg> without emitting a call with that number.

    Greg> Now I know userspace needs to handle this properly anyway,
    Greg> but we might as well get the kernel right, and not do stuff
    Greg> to make userspace unhappy if we can obviously help it.

Got it... I had remembered you saying gaps in the sequence numbers
were OK in the past.

 - R.

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

end of thread, other threads:[~2004-10-30  1:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-27 11:59 usb hotplug $DEVICE empty Klaus Dittrich
2004-10-29  4:24 ` [PATCH] kobject hotplug: don't let SEQNUM overwrite other vars (was Re: usb hotplug $DEVICE empty) Roland Dreier
2004-10-29  4:38   ` Greg KH
2004-10-29 18:44     ` [PATCH] kobject hotplug: don't let SEQNUM overwrite other vars Roland Dreier
  -- strict thread matches above, loose matches on Subject: below --
2004-10-25 12:32 usb hotplug \$DEVICE empty Klaus Dittrich

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