Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753005AbdF2SKn (ORCPT ); Thu, 29 Jun 2017 14:10:43 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:40264 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1752454AbdF2SKg (ORCPT ); Thu, 29 Jun 2017 14:10:36 -0400 Date: Thu, 29 Jun 2017 14:10:35 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: Ben Hutchings cc: linux-kernel@vger.kernel.org, , Felipe Balbi , Greg Kroah-Hartman Subject: Re: [PATCH 4.4 22/30] USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks In-Reply-To: <1498755471.1935.55.camel@codethink.co.uk> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1454 Lines: 37 On Thu, 29 Jun 2017, Ben Hutchings wrote: > On Mon, 2017-06-19 at 23:20 +0800, Greg Kroah-Hartman wrote: > > 4.4-stable review patch. If anyone has any objections, please let me know. > > > > ------------------ > > > > From: Alan Stern > > > > commit f16443a034c7aa359ddf6f0f9bc40d01ca31faea upstream. > [...] > > The result of this race, as seen above, is that set_link_state() can > > invoke a callback in gadgetfs even after gadgetfs has been unbound > > from dummy_hcd's UDC and its private data structures have been > > deallocated. > > > > include/linux/usb/gadget.h documents that the ->reset, ->disconnect, > > ->suspend, and ->resume callbacks may be invoked in interrupt context. > > In general this is necessary, to prevent races with gadget driver > > removal. This patch fixes dummy_hcd to retain the spinlock across > > these calls, and it adds a spinlock acquisition to dummy_udc_stop() to > > prevent the race. > > > > The net2280 driver makes the same mistake of dropping the private > > spinlock for its ->disconnect and ->reset callback invocations. The > > patch fixes it too. > [...] > > Why only these two drivers? Most of the other UDC drivers seem to do > the same thing. I'm not at all familiar with the other UDC drivers, only those two. If the maintainers for other UDC drivers would like to discuss the problem and consider whether changes are needed, I'd be glad to help. Alan Stern