From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from rn-out-0910.google.com ([64.233.170.185]:29436 "EHLO rn-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754180AbZBKPMV (ORCPT ); Wed, 11 Feb 2009 10:12:21 -0500 Received: by rn-out-0910.google.com with SMTP id k40so228198rnd.17 for ; Wed, 11 Feb 2009 07:12:20 -0800 (PST) From: Sujith MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Message-ID: <18834.60020.961395.8177@gargle.gargle.HOWL> (sfid-20090211_161232_736081_93808C02) Date: Wed, 11 Feb 2009 20:40:44 +0530 To: Johannes Berg Cc: "Luis R. Rodriguez" , linux-wireless Subject: lock inversion with regulatory code In-Reply-To: <1234282434.4229.9.camel@johannes.local> References: <1234282434.4229.9.camel@johannes.local> Sender: linux-wireless-owner@vger.kernel.org List-ID: Johannes Berg wrote: > I'm getting this lockdep report -- the problem is that zd1211 calls > regulatory_hint within the rtnl (because it's within ieee80211_open), > but all cfg80211 locking so far has been the other way around. > > Not sure how to fix it, here are a couple of possibilities: > (1) invert all cfg80211 locking, i.e. do rtnl_lock() around everything > in each nl80211 handler > (2) defer regulatory hints and treat them outside of the context of > regulatory_hint() (use schedule_work or so) > (3) disallow doing regulatory hints from _open() > Saw this today when I stopped wpa_supplicant. [ 513.426737] ======================================================= [ 513.430019] [ INFO: possible circular locking dependency detected ] [ 513.430019] 2.6.29-rc4-wl #7 [ 513.430019] ------------------------------------------------------- [ 513.430019] wpa_supplicant/3333 is trying to acquire lock: [ 513.430019] (&ifsta->work){--..}, at: [] __cancel_work_timer+0x5d/0x1f0 [ 513.430019] [ 513.430019] but task is already holding lock: [ 513.430019] (rtnl_mutex){--..}, at: [] devinet_ioctl+0x136/0x7a0 [ 513.430019] [ 513.430019] which lock already depends on the new lock. [ 513.430019] [ 513.430019] [ 513.430019] the existing dependency chain (in reverse order) is: [ 513.488268] [ 513.488268] -> #3 (rtnl_mutex){--..}: [ 513.488268] [] add_lock_to_list+0x67/0xf0 [ 513.488268] [] nl80211_dump_station+0x139/0x1f0 [cfg80211] [ 513.488268] [] __lock_acquire+0x1520/0x1c40 [ 513.488268] [] nl80211_dump_station+0x139/0x1f0 [cfg80211] [ 513.488268] [] lock_acquire+0x55/0x70 [ 513.488268] [] nl80211_dump_station+0x139/0x1f0 [cfg80211] [ 513.488268] [] mutex_lock_nested+0xca/0x370 [ 513.488268] [] nl80211_dump_station+0x139/0x1f0 [cfg80211] [ 513.488268] [] __mutex_unlock_slowpath+0x125/0x1c0 [ 513.488268] [] trace_hardirqs_on_caller+0x15a/0x1a0 [ 513.488268] [] nl80211_dump_station+0x139/0x1f0 [cfg80211] [ 513.488268] [] mutex_lock_nested+0x2d1/0x370 [ 513.488268] [] netlink_dump+0x4d/0x1f0 [ 513.488268] [] netlink_dump+0x67/0x1f0 [ 513.488268] [] netlink_dump_start+0x16d/0x190 [ 513.488268] [] genl_rcv_msg+0x118/0x1f0 [ 513.488268] [] genl_rcv+0x12/0x30 [ 513.488268] [] genl_rcv_msg+0x0/0x1f0 [ 513.488268] [] netlink_rcv_skb+0x79/0xa0 [ 513.488268] [] genl_rcv+0x21/0x30 [ 513.488268] [] netlink_unicast+0x2ca/0x2e0 [ 513.488268] [] __alloc_skb+0x72/0x150 [ 513.488268] [] netlink_sendmsg+0x20a/0x320 [ 513.488268] [] sock_sendmsg+0x12e/0x150 [ 513.488268] [] autoremove_wake_function+0x0/0x30 [ 513.488268] [] move_addr_to_kernel+0x2e/0x40 [ 513.488268] [] sys_sendmsg+0x1e7/0x370 [ 513.488268] [] do_page_fault+0x361/0x9a0 [ 513.488268] [] kmem_cache_free+0xaf/0x130 [ 513.488268] [] trace_hardirqs_on_caller+0x15a/0x1a0 [ 513.488268] [] d_kill+0x60/0x80 [ 513.488268] [] dput+0xbb/0x1a0 [ 513.488268] [] trace_hardirqs_on_caller+0x15a/0x1a0 [ 513.488268] [] trace_hardirqs_on_thunk+0x3a/0x3f [ 513.488268] [] system_call_fastpath+0x16/0x1b [ 513.488268] [] 0xffffffffffffffff [ 513.488268] [ 513.488268] -> #2 (&drv->mtx){--..}: [ 513.488268] [] add_lock_to_list+0x67/0xf0 [ 513.488268] [] cfg80211_get_dev_from_ifindex+0x60/0x90 [cfg80211] [ 513.488268] [] __lock_acquire+0x1520/0x1c40 [ 513.488268] [] cfg80211_get_dev_from_ifindex+0x60/0x90 [cfg80211] [ 513.488268] [] lock_acquire+0x55/0x70 [ 513.488268] [] cfg80211_get_dev_from_ifindex+0x60/0x90 [cfg80211] [ 513.488268] [] mutex_lock_nested+0xca/0x370 [ 513.488268] [] cfg80211_get_dev_from_ifindex+0x60/0x90 [cfg80211] [ 513.488268] [] cfg80211_get_dev_from_ifindex+0x60/0x90 [cfg80211] [ 513.488268] [] get_drv_dev_by_info_ifindex+0x68/0x90 [cfg80211] [ 513.488268] [] nl80211_get_interface+0x27/0xf0 [cfg80211] [ 513.488268] [] genl_rcv_msg+0x1b7/0x1f0 [ 513.488268] [] genl_rcv_msg+0x0/0x1f0 [ 513.488268] [] netlink_rcv_skb+0x79/0xa0 [ 513.488268] [] genl_rcv+0x21/0x30 [ 513.488268] [] netlink_unicast+0x2ca/0x2e0 [ 513.488268] [] __alloc_skb+0x72/0x150 [ 513.488268] [] netlink_sendmsg+0x20a/0x320 [ 513.488268] [] sock_sendmsg+0x12e/0x150 [ 513.488268] [] autoremove_wake_function+0x0/0x30 [ 513.488268] [] move_addr_to_kernel+0x2e/0x40 [ 513.488268] [] sys_sendmsg+0x1e7/0x370 [ 513.488268] [] do_page_fault+0x361/0x9a0 [ 513.488268] [] kmem_cache_free+0xaf/0x130 [ 513.488268] [] trace_hardirqs_on_caller+0x15a/0x1a0 [ 513.488268] [] d_kill+0x60/0x80 [ 513.488268] [] dput+0xbb/0x1a0 [ 513.488268] [] trace_hardirqs_on_caller+0x15a/0x1a0 [ 513.488268] [] trace_hardirqs_on_thunk+0x3a/0x3f [ 513.488268] [] system_call_fastpath+0x16/0x1b [ 513.488268] [] 0xffffffffffffffff [ 513.488268] [ 513.488268] -> #1 (cfg80211_drv_mutex){--..}: [ 513.488268] [] add_lock_to_list+0x67/0xf0 [ 513.488268] [] regulatory_hint_11d+0x44/0x370 [cfg80211] [ 513.488268] [] __lock_acquire+0x1520/0x1c40 [ 513.488268] [] __lock_acquire+0x18c/0x1c40 [ 513.488268] [] mark_held_locks+0x4d/0x90 [ 513.488268] [] local_bh_enable_ip+0x9c/0x130 [ 513.488268] [] regulatory_hint_11d+0x44/0x370 [cfg80211] [ 513.488268] [] lock_acquire+0x55/0x70 [ 513.488268] [] regulatory_hint_11d+0x44/0x370 [cfg80211] [ 513.488268] [] mutex_lock_nested+0xca/0x370 [ 513.488268] [] regulatory_hint_11d+0x44/0x370 [cfg80211] [ 513.488268] [] __lock_acquire+0x18c/0x1c40 [ 513.488268] [] regulatory_hint_11d+0x44/0x370 [cfg80211] [ 513.488268] [] ieee80211_rx_mgmt_beacon+0x33b/0x400 [mac80211] [ 513.488268] [] ieee80211_rx_mgmt_beacon+0x253/0x400 [mac80211] [ 513.488268] [] skb_dequeue+0x21/0x80 [ 513.488268] [] ieee80211_sta_work+0x180/0xe60 [mac80211] [ 513.488268] [] _spin_unlock_irq+0x24/0x50 [ 513.488268] [] ieee80211_sta_work+0x0/0xe60 [mac80211] [ 513.488268] [] ieee80211_sta_work+0x0/0xe60 [mac80211] [ 513.488268] [] run_workqueue+0xfb/0x250 [ 513.488268] [] run_workqueue+0xa9/0x250 [ 513.488268] [] trace_hardirqs_on_caller+0x15a/0x1a0 [ 513.488268] [] worker_thread+0xa7/0x110 [ 513.488268] [] autoremove_wake_function+0x0/0x30 [ 513.488268] [] worker_thread+0x0/0x110 [ 513.488268] [] worker_thread+0x0/0x110 [ 513.488268] [] kthread+0x47/0x90 [ 513.488268] [] trace_hardirqs_on_thunk+0x3a/0x3f [ 513.488268] [] child_rip+0xa/0x20 [ 513.488268] [] restore_args+0x0/0x30 [ 513.488268] [] kthread+0x0/0x90 [ 513.488268] [] child_rip+0x0/0x20 [ 513.488268] [] 0xffffffffffffffff [ 513.488268] [ 513.488268] -> #0 (&ifsta->work){--..}: [ 513.488268] [] __lock_acquire+0x16cd/0x1c40 [ 513.488268] [] lock_acquire+0x55/0x70 [ 513.488268] [] __cancel_work_timer+0x5d/0x1f0 [ 513.488268] [] __cancel_work_timer+0x8f/0x1f0 [ 513.488268] [] __cancel_work_timer+0x5d/0x1f0 [ 513.488268] [] mark_held_locks+0x4d/0x90 [ 513.488268] [] _spin_unlock_irqrestore+0x65/0x80 [ 513.488268] [] trace_hardirqs_on_caller+0x15a/0x1a0 [ 513.488268] [] try_to_del_timer_sync+0x54/0x60 [ 513.488268] [] ieee80211_stop+0x212/0x600 [mac80211] [ 513.488268] [] ieee80211_stop+0x72/0x600 [mac80211] [ 513.488268] [] local_bh_enable_ip+0x9c/0x130 [ 513.488268] [] dev_deactivate+0x1ab/0x1d0 [ 513.488268] [] dev_close+0x83/0xd0 [ 513.488268] [] dev_change_flags+0x9b/0x1e0 [ 513.488268] [] devinet_ioctl+0x78e/0x7a0 [ 513.488268] [] sock_ioctl+0x6a/0x290 [ 513.488268] [] vfs_ioctl+0x2f/0xb0 [ 513.488268] [] do_vfs_ioctl+0x98/0x5c0 [ 513.488268] [] sysret_check+0x27/0x62 [ 513.488268] [] sys_ioctl+0xa1/0xb0 [ 513.488268] [] system_call_fastpath+0x16/0x1b [ 513.488268] [] 0xffffffffffffffff [ 513.488268] [ 513.488268] other info that might help us debug this: [ 513.488268] [ 513.488268] 1 lock held by wpa_supplicant/3333: [ 513.488268] #0: (rtnl_mutex){--..}, at: [] devinet_ioctl+0x136/0x7a0 [ 513.488268] [ 513.488268] stack backtrace: [ 513.488268] Pid: 3333, comm: wpa_supplicant Not tainted 2.6.29-rc4-wl #7 [ 513.488268] Call Trace: [ 513.488268] [] print_circular_bug_tail+0xf0/0x100 [ 513.488268] [] __lock_acquire+0x16cd/0x1c40 [ 513.488268] [] lock_acquire+0x55/0x70 [ 513.488268] [] __cancel_work_timer+0x5d/0x1f0 [ 513.488268] [] __cancel_work_timer+0x8f/0x1f0 [ 513.488268] [] __cancel_work_timer+0x5d/0x1f0 [ 513.488268] [] mark_held_locks+0x4d/0x90 [ 513.488268] [] _spin_unlock_irqrestore+0x65/0x80 [ 513.488268] [] trace_hardirqs_on_caller+0x15a/0x1a0 [ 513.488268] [] try_to_del_timer_sync+0x54/0x60 [ 513.488268] [] ieee80211_stop+0x212/0x600 [mac80211] [ 513.488268] [] ieee80211_stop+0x72/0x600 [mac80211] [ 513.488268] [] local_bh_enable_ip+0x9c/0x130 [ 513.488268] [] dev_deactivate+0x1ab/0x1d0 [ 513.488268] [] dev_close+0x83/0xd0 [ 513.488268] [] dev_change_flags+0x9b/0x1e0 [ 513.488268] [] devinet_ioctl+0x78e/0x7a0 [ 513.488268] [] sock_ioctl+0x6a/0x290 [ 513.488268] [] vfs_ioctl+0x2f/0xb0 [ 513.488268] [] do_vfs_ioctl+0x98/0x5c0 [ 513.488268] [] sysret_check+0x27/0x62 [ 513.488268] [] sys_ioctl+0xa1/0xb0 [ 513.488268] [] system_call_fastpath+0x16/0x1b