Linux USB
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: USB mailing list <linux-usb@vger.kernel.org>
Subject: Re: [PATCH 2/2] USB: core: Fix deadlock in port "disable" sysfs attribute
Date: Tue, 26 Mar 2024 10:23:25 +0100	[thread overview]
Message-ID: <2024032607-angelfish-scratch-2983@gregkh> (raw)
In-Reply-To: <2024032610-uptown-mammary-f0fb@gregkh>

On Tue, Mar 26, 2024 at 10:22:32AM +0100, Greg KH wrote:
> On Fri, Mar 15, 2024 at 01:06:33PM -0400, Alan Stern wrote:
> > The show and store callback routines for the "disable" sysfs attribute
> > file in port.c acquire the device lock for the port's parent hub
> > device.  This can cause problems if another process has locked the hub
> > to remove it or change its configuration:
> > 
> > 	Removing the hub or changing its configuration requires the
> > 	hub interface to be removed, which requires the port device
> > 	to be removed, and device_del() waits until all outstanding
> > 	sysfs attribute callbacks for the ports have returned.  The
> > 	lock can't be released until then.
> > 
> > 	But the disable_show() or disable_store() routine can't return
> > 	until after it has acquired the lock.
> > 
> > The resulting deadlock can be avoided by calling
> > sysfs_break_active_protection().  This will cause the sysfs core not
> > to wait for the attribute's callback routine to return, allowing the
> > removal to proceed.  The disadvantage is that after making this call,
> > there is no guarantee that the hub structure won't be deallocated at
> > any moment.  To prevent this, we have to acquire a reference to it
> > first by calling hub_get().
> > 
> > Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> > Cc: <stable@vger.kernel.org>	# Needs the previous patch in this series
> 
> What "previous patch"?  I don't see this as a series even on
> lore.kernel.org.

Ah, found it, you sent it only to me for some reason, and not the lists.

thanks,

greg k-h

  reply	other threads:[~2024-03-26  9:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <604da420-ae8a-4a9e-91a4-2d511ff404fb@rowland.harvard.edu>
2024-03-15 17:06 ` [PATCH 2/2] USB: core: Fix deadlock in port "disable" sysfs attribute Alan Stern
2024-03-26  9:22   ` Greg KH
2024-03-26  9:23     ` Greg KH [this message]
2024-03-26 14:32       ` Alan Stern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2024032607-angelfish-scratch-2983@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox