Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761293AbXEPL4u (ORCPT ); Wed, 16 May 2007 07:56:50 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757862AbXEPL4k (ORCPT ); Wed, 16 May 2007 07:56:40 -0400 Received: from wr-out-0506.google.com ([64.233.184.228]:10957 "EHLO wr-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756374AbXEPL4j (ORCPT ); Wed, 16 May 2007 07:56:39 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=EPSTekySB0yvyMmUdsUWtfWiuoEaVmFyB32EnYHpoW6gi5pUjspN+uL9cDxPEt6dnilv0c83SuEIXmUSIXfmpJubQ8//ry7CvP6HZ1q6Yq5NVypYGUSJCVAQO8JulKEBLOWUfLg3r+NLsqDWizHfmNX20ocPxsfIeeYArO1pd6Q= Message-ID: Date: Wed, 16 May 2007 17:26:38 +0530 From: "Satyam Sharma" To: "Marcel Holtmann" Subject: Re: 2.6.21-rc7: BUG: sleeping function called from invalid context at net/core/sock.c:1523 Cc: "Jiri Kosina" , "Greg KH" , "Jeremy Fitzhardinge" , maxk@qualcomm.com, bluez-devel@lists.sourceforge.net, "Cedric Le Goater" , "Linux Kernel Mailing List" , netdev@vger.kernel.org In-Reply-To: <1179315904.10069.67.camel@violet> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <462D1B09.9050005@goop.org> <1179315904.10069.67.camel@violet> Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2453 Lines: 63 Hi Marcel, On 5/16/07, Marcel Holtmann wrote: > Hi Satayam, > > > > > (later) > > > > I Googled a bit to see if this problem was faced elsewhere in the kernel > > > > too. Saw the following commit by Ingo Molnar > > > > (9883a13c72dbf8c518814b6091019643cdb34429): > > > > - lock_sock(sock->sk); > > > > + local_bh_disable(); > > > > + bh_lock_sock_nested(sock->sk); > > > > rc = selinux_netlbl_socket_setsid(sock, sksec->sid); > > > > - release_sock(sock->sk); > > > > + bh_unlock_sock(sock->sk); > > > > + local_bh_enable(); > > > > Is it _really_ *this* simple? > > > [...] > > > actually this *seems* to be proper solution also for our case, thanks for > > > pointing this out. I will think about it once again, do some more tests > > > with this locking scheme, and will let you know. > > > > Yes, I can almost confirm that this (open-coding of spin_lock_bh, > > effectively) is the proper solution (Rusty's unreliable guide to > > kernel-locking needs to be next to every developer's keyboard :-) > > I also came across this idiom in other places in the networking code > > so it seems to be pretty much the standard way. I wish I owned > > bluetooth hardware, could've tested this for you myself. > > does this mean we should revert previous changes to the locking or only > apply this on top of it? I've fixed a simple patch on top of 2.6.22-rc1 below. Signed-off-by: Satyam Sharma diff -ruNp a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c --- a/net/bluetooth/hci_sock.c 2007-05-16 17:31:06.000000000 +0530 +++ b/net/bluetooth/hci_sock.c 2007-05-16 17:33:36.000000000 +0530 @@ -665,7 +665,8 @@ static int hci_sock_dev_event(struct not /* Detach sockets from device */ read_lock(&hci_sk_list.lock); sk_for_each(sk, node, &hci_sk_list.head) { - lock_sock(sk); + local_bh_disable(); + bh_lock_sock_nested(sk); if (hci_pi(sk)->hdev == hdev) { hci_pi(sk)->hdev = NULL; sk->sk_err = EPIPE; @@ -674,6 +675,8 @@ static int hci_sock_dev_event(struct not hci_dev_put(hdev); } + bh_unlock_sock(sk); + local_bh_enable(); release_sock(sk); } read_unlock(&hci_sk_list.lock); - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/