From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Satyam Sharma" Subject: Re: 2.6.21-rc7: BUG: sleeping function called from invalid context at net/core/sock.c:1523 Date: Wed, 16 May 2007 17:06:46 +0530 Message-ID: References: <462D1B09.9050005@goop.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "Marcel Holtmann" , "Greg KH" , "Jeremy Fitzhardinge" , maxk@qualcomm.com, bluez-devel@lists.sourceforge.net, "Cedric Le Goater" , "Linux Kernel Mailing List" , netdev@vger.kernel.org To: "Jiri Kosina" Return-path: Received: from py-out-1112.google.com ([64.233.166.180]:65122 "EHLO py-out-1112.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756570AbXEPLgr (ORCPT ); Wed, 16 May 2007 07:36:47 -0400 Received: by py-out-1112.google.com with SMTP id a29so457440pyi for ; Wed, 16 May 2007 04:36:47 -0700 (PDT) In-Reply-To: Content-Disposition: inline Sender: netdev-owner@vger.kernel.org List-Id: netdev.vger.kernel.org Hi Jiri, On 5/16/07, Jiri Kosina wrote: > On Fri, 11 May 2007, Satyam Sharma wrote: > > (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. Thanks, Satyam