linux/net/bluetooth
Jiri Kosina b40df5743e [PATCH] bluetooth: fix socket locking in hci_sock_dev_event()
[Bluetooth] Fix socket locking in hci_sock_dev_event()

hci_sock_dev_event() uses bh_lock_sock() to lock the socket lock.
This is not deadlock-safe against locking of the same socket lock in
l2cap_connect_cfm() from softirq context. In addition to that,
hci_sock_dev_event() doesn't seem to be called from softirq context,
so it is safe to use lock_sock()/release_sock() instead.

The lockdep warning can be triggered on my T42p simply by switching
the Bluetooth off by the keyboard button.

  =================================
  [ INFO: inconsistent lock state ]
  2.6.21-rc2 #4
  ---------------------------------
  inconsistent {in-softirq-W} -> {softirq-on-W} usage.
  khubd/156 [HC0[0]:SC0[0]:HE1:SE1] takes:
   (slock-AF_BLUETOOTH){-+..}, at: [<e0ca5520>] hci_sock_dev_event+0xa8/0xc5 [bluetooth]
  {in-softirq-W} state was registered at:
    [<c012d1db>] mark_lock+0x59/0x414
    [<e0cef688>] l2cap_connect_cfm+0x4e/0x11f [l2cap]
    [<c012dfd7>] __lock_acquire+0x3e5/0xb99
    [<e0cef688>] l2cap_connect_cfm+0x4e/0x11f [l2cap]
    [<c012e7f2>] lock_acquire+0x67/0x81
    [<e0cef688>] l2cap_connect_cfm+0x4e/0x11f [l2cap]
    [<c036ee72>] _spin_lock+0x29/0x34
    [<e0cef688>] l2cap_connect_cfm+0x4e/0x11f [l2cap]
    [<e0cef688>] l2cap_connect_cfm+0x4e/0x11f [l2cap]
    [<e0ca17c3>] hci_send_cmd+0x126/0x14f [bluetooth]
    [<e0ca4ce4>] hci_event_packet+0x729/0xebd [bluetooth]
    [<e0ca205b>] hci_rx_task+0x2a/0x20f [bluetooth]
    [<e0ca209d>] hci_rx_task+0x6c/0x20f [bluetooth]
    [<c012d7be>] trace_hardirqs_on+0x10d/0x14e
    [<c011ac85>] tasklet_action+0x3d/0x68
    [<c011abba>] __do_softirq+0x41/0x92
    [<c011ac32>] do_softirq+0x27/0x3d
    [<c0105134>] do_IRQ+0x7b/0x8f
    [<c0103dec>] common_interrupt+0x24/0x34
    [<c0103df6>] common_interrupt+0x2e/0x34
    [<c0248e65>] acpi_processor_idle+0x1b3/0x34a
    [<c0248e68>] acpi_processor_idle+0x1b6/0x34a
    [<c010232b>] cpu_idle+0x39/0x4e
    [<c04bab0c>] start_kernel+0x372/0x37a
    [<c04ba42b>] unknown_bootoption+0x0/0x202
    [<ffffffff>] 0xffffffff

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-03-08 07:38:21 -08:00
..
bnep [PATCH] remove many unneeded #includes of sched.h 2007-02-14 08:09:54 -08:00
cmtp [PATCH] remove many unneeded #includes of sched.h 2007-02-14 08:09:54 -08:00
hidp [Bluetooth] Add open and close callbacks for HID device 2007-02-26 11:42:39 -08:00
rfcomm [Bluetooth] Make use of device_move() for RFCOMM TTY devices 2007-02-26 11:42:41 -08:00
af_bluetooth.c [NET] BLUETOOTH: Fix whitespace errors. 2007-02-10 23:19:20 -08:00
hci_conn.c [PATCH] remove many unneeded #includes of sched.h 2007-02-14 08:09:54 -08:00
hci_core.c [NET] BLUETOOTH: Fix whitespace errors. 2007-02-10 23:19:20 -08:00
hci_event.c [PATCH] remove many unneeded #includes of sched.h 2007-02-14 08:09:54 -08:00
hci_sock.c [PATCH] bluetooth: fix socket locking in hci_sock_dev_event() 2007-03-08 07:38:21 -08:00
hci_sysfs.c [Bluetooth] Handle device registration failures 2007-01-09 00:29:56 -08:00
Kconfig Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
l2cap.c [NET] BLUETOOTH: Fix whitespace errors. 2007-02-10 23:19:20 -08:00
lib.c [NET] BLUETOOTH: Fix whitespace errors. 2007-02-10 23:19:20 -08:00
Makefile Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
sco.c [NET] BLUETOOTH: Fix whitespace errors. 2007-02-10 23:19:20 -08:00