Commit Graph

137 Commits

Author SHA1 Message Date
Brian Gix
7eaa64dda6 Bluetooth: Generate generic Fails for undeliverable ATT messages
Change-Id: I04f9ec62b15abb090cb90d81442a83caf8caa447
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2011-10-19 13:20:02 -07:00
Inga Stotland
f214b6e656 Bluetooth: Socket lookup for a fixed L2CAP channel
Socket lookup for a fixed channel should be done based on both remote and
local device addresses.

Change-Id: I35f39bea8ade6fd5d8695640251efc54bf21beae
Signed-off-by: Inga Stotland <ingas@codeaurora.org>
2011-10-12 13:09:28 -07:00
Brian Gix
065e8ff2cd Bluetooth: Balance LE hdev refcnt when not pairing.
Signed-off-by: Brian Gix <bgix@codeaurora.org>
2011-10-04 17:14:08 -07:00
Brian Gix
e9ceb522ff Bluetooth: Fix LE Pairing time-out
Timer that was started at beginning of LE Pairing did not correctly
terminate pairing process when it fired, and was not properly cleaned
up on pairing completion.

Signed-off-by: Brian Gix <bgix@codeaurora.org>
2011-10-03 16:21:22 -07:00
Peter Krystad
7400e7f5ec Revert "Bluetooth: check L2CAP length in first ACL fragment"
This reverts commit 8979481328

CRs-fixed: 305959
Signed-off-by: Peter Krystad <pkrystad@codeaurora.org>
2011-10-03 16:21:15 -07:00
Mat Martineau
604c6475ca Bluetooth: AMP move collision loser should not change move state
During a move collision, both devices start out thinking they are the
initiator. The loser of the collision switches from the initiator role
to the responder role when receiving a move request from the remote
device.  However, a move response will also be received by the loser
after the role switch has occurred.

The loser of the collision was incorrectly modifying the AMP move
state in the move response handler.  This kept it from sending a move
channel response to the remote device, which stalled the channel move
process.

This change makes sure the AMP move state remains valid, so the
channel move succeeds.

CRs-fixed: 308382
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
2011-10-03 16:20:54 -07:00
Mat Martineau
55f2a62dff Bluetooth: Wait for info response before accepting AMP connection
An incoming AMP "create channel" connection would trigger an info
request and an AMP physical accept sequence at the same time.  Since
accepting an AMP physical link is a local operation, it would complete
quickly and send a config request before the info response was
received.

If there is an outstanding info request, the AMP physical link should
not be accepted yet.  Existing logic in l2cap_conn_start() will accept
the physical link when the info response is received.

CRs-fixed: 307243
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
2011-10-03 16:20:27 -07:00
Brian Gix
2e2f50d997 Bluetooth: Add LE/BR flag to Connect notification
When remote device is connected outside the control of BlueZ, it
needs to be informed of whether the new connection is LE or BR/EDR.

Signed-off-by: Brian Gix <bgix@codeaurora.org>
2011-10-03 16:19:44 -07:00
Brian Gix
dfdd9360af Bluetooth: Fix Connection persistence, SSP caching
Fix key storage when not bonding
Fix when LE ACL is disconnected after use

Signed-off-by: Brian Gix <bgix@codeaurora.org>
2011-10-03 16:18:52 -07:00
Brian Gix
a68668b4e3 Bluetooth: Add LE SecMgr and mgmtops support
Enabled ECB Block encoding for Low Energy pairing
Implemented missing components of MGMTOPS interface
Differentiated as needed between BR/EDR pairing and LE pairing

Signed-off-by: Brian Gix <bgix@codeaurora.org>

Conflicts:

	net/bluetooth/mgmt.c
2011-10-03 16:18:51 -07:00
Peter Krystad
f453bb396a Bluetooth: Add support for L2CAP Extended Flow Spec option.
Add send and receive of Extended Flow Spec option during L2CAP
lockstep configuration and passing the flow specs to HCI.

Signed-off-by: Peter Krystad <pkrystad@codeaurora.org>

Conflicts:

	include/net/bluetooth/hci.h
	include/net/bluetooth/hci_core.h
	net/bluetooth/l2cap_core.c
2011-10-03 10:27:04 -07:00
Matt Wagantall
f63a88968a msm: clock-8x60: Add local control of vpe_axi_clk and vpe_axi_clk
The MAXI_EN2 register is no longer owned by the RPM. Add local
control of the VPE and Rotator AXI clocks which are in it.

Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
2011-10-03 10:25:57 -07:00
Bryan Huntsman
3f2bc4d6eb Initial Contribution
msm-2.6.38: tag AU_LINUX_ANDROID_GINGERBREAD.02.03.04.00.142

Signed-off-by: Bryan Huntsman <bryanh@codeaurora.org>
2011-10-03 09:57:10 -07:00
Peter Hurley
b0ebe79d66 Bluetooth: l2cap: Fix lost wakeup waiting for ERTM acks
Fix race condition which can result in missing wakeup during
l2cap socket shutdown.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-08-02 15:11:15 -07:00
Ilia Kolomisnky
ce4bafd82e Bluetooth: Fix crash with incoming L2CAP connections
Another regression fix considering incomming l2cap connections with
defer_setup enabled. In situations when incomming connection is
extracted with l2cap_sock_accept, it's bt_sock info will have
'parent' member zerroed, but 'parent' may be used unconditionally
in l2cap_conn_start() and l2cap_security_cfm() when defer_setup
is enabled.

Backtrace:
[<bf02d5ac>] (l2cap_security_cfm+0x0/0x2ac [bluetooth]) from [<bf01f01c>] (hci_event_pac
ket+0xc2c/0x4aa4 [bluetooth])
[<bf01e3f0>] (hci_event_packet+0x0/0x4aa4 [bluetooth]) from [<bf01a844>] (hci_rx_task+0x
cc/0x27c [bluetooth])
[<bf01a778>] (hci_rx_task+0x0/0x27c [bluetooth]) from [<c008eee4>] (tasklet_action+0xa0/
0x15c)
[<c008ee44>] (tasklet_action+0x0/0x15c) from [<c008f38c>] (__do_softirq+0x98/0x130)
 r7:00000101 r6:00000018 r5:00000001 r4:efc46000
[<c008f2f4>] (__do_softirq+0x0/0x130) from [<c008f524>] (do_softirq+0x4c/0x58)
[<c008f4d8>] (do_softirq+0x0/0x58) from [<c008f5e0>] (run_ksoftirqd+0xb0/0x1b4)
 r4:efc46000 r3:00000001
[<c008f530>] (run_ksoftirqd+0x0/0x1b4) from [<c009f2a8>] (kthread+0x84/0x8c)
 r7:00000000 r6:c008f530 r5:efc47fc4 r4:efc41f08
[<c009f224>] (kthread+0x0/0x8c) from [<c008cc84>] (do_exit+0x0/0x5f0)

Signed-off-by: Ilia Kolomisnky <iliak@ti.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-07-18 12:28:03 -07:00
Gustavo F. Padovan
8ee057f096 Bluetooth: Fix regression in L2CAP connection procedure
Caused by the following commit, partially revert it.

commit 9fa7e4f76f
Author: Gustavo F. Padovan <padovan@profusion.mobi>
Date:   Thu Jun 30 16:11:30 2011 -0300

    Bluetooth: Fix regression with incoming L2CAP connections

    PTS test A2DP/SRC/SRC_SET/TC_SRC_SET_BV_02_I revealed that
    ( probably after the df3c3931e commit ) the l2cap connection
    could not be established in case when the "Auth Complete" HCI
    event does not arive before the initiator send "Configuration
    request", in which case l2cap replies with "Command rejected"
    since the channel is still in BT_CONNECT2 state.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-07-18 12:28:03 -07:00
Gustavo F. Padovan
63be311edb Bluetooth: Fix regression with incoming L2CAP connections
PTS test A2DP/SRC/SRC_SET/TC_SRC_SET_BV_02_I revealed that
( probably after the df3c3931e commit ) the l2cap connection
could not be established in case when the "Auth Complete" HCI
event does not arive before the initiator send "Configuration
request", in which case l2cap replies with "Command rejected"
since the channel is still in BT_CONNECT2 state.

Based on patch from: Ilia Kolomisnky <iliak@ti.com>

Change-Id: Ifcffe0124adbbc6d1931389ff7476dd0304d6f51
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-18 12:28:02 -07:00
Dan Rosenberg
1752e5327a Bluetooth: Prevent buffer overflow in l2cap config request
A remote user can provide a small value for the command size field in
the command header of an l2cap configuration request, resulting in an
integer underflow when subtracting the size of the configuration request
header.  This results in copying a very large amount of data via
memcpy() and destroying the kernel heap.  Check for underflow.

Signed-off-by: Dan Rosenberg <drosenberg@vsecurity.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-18 12:28:02 -07:00
Vinicius Costa Gomes
c1d5e1dab8 Bluetooth: Add support for SMP phase 3 (key distribution)
This adds support for generating and distributing all the keys
specified in the third phase of SMP.

This will make possible to re-establish secure connections, resolve
private addresses and sign commands.

For now, the values generated are random.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:34 -07:00
Mat Martineau
119c689389 Bluetooth: Remove L2CAP busy queue
The ERTM receive buffer is now handled in a way that does not require
the busy queue and the associated polling code.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:34 -07:00
Mat Martineau
c0675b8d3c Bluetooth: Use event-driven approach for handling ERTM receive buffer
This change moves most L2CAP ERTM receive buffer handling out of the
L2CAP core and in to the socket code.  It's up to the higher layer
(the socket code, in this case) to tell the core when its buffer is
full or has space available.  The recv op should always accept
incoming ERTM data or else the connection will go down.

Within the socket layer, an skb that does not fit in the socket
receive buffer will be temporarily stored.  When the socket is read
from, that skb will be placed in the receive buffer if possible.  Once
adequate buffer space becomes available, the L2CAP core is informed
and the ERTM local busy state is cleared.

Receive buffer management for non-ERTM modes is unchanged.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:33 -07:00
Mat Martineau
d0336628cc Bluetooth: Move code for ERTM local busy state to separate functions
The local busy state is entered and exited based on buffer status in
the socket layer (or other upper layer).  This change is in
preparation for general buffer status reports from the socket layer,
which will then be used to change the local busy status.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:33 -07:00
Mat Martineau
758b9e9a24 Bluetooth: Check earlier for L2CAP ERTM frames to drop
Even when the received tx_seq is expected, the frame still needs to be
dropped if the TX window is exceeded or the receiver is in the local
busy state.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:28 -07:00
Gustavo F. Padovan
0e43af4287 Bluetooth: Fix bad locking balance
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:27 -07:00
Joe Perches
d8e4f87b5c Bluetooth: Rename function bt_err to bt_to_errno
Make it easier to use more normal logging styles later.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:26 -07:00
Mat Martineau
6e35f04700 Bluetooth: ERTM timeouts need to be converted to jiffies
ERTM timeouts are defined in milliseconds, but need to be converted
to jiffies when passed to mod_timer().

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:26 -07:00
Mat Martineau
783db135d9 Bluetooth: Fix indentation whitespace
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:25 -07:00
Vinicius Costa Gomes
a8eaf8b382 Bluetooth: Fix not setting the chan state
When the connection is ready we should set the connection
to CONNECTED so userspace can use it.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:25 -07:00
Vinicius Costa Gomes
43d669e7b6 Bluetooth: Remove useless access to the socket
We already have access to the chan, we don't have to access the
socket to get its imtu.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:25 -07:00
Vinicius Costa Gomes
16af3daa4a Bluetooth: Fix crash when setting a LE socket to ready
We should not try to do any other type of configuration for
LE links when they become ready.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:24 -07:00
Gustavo F. Padovan
e299c1cdf8 Bluetooth: Use bit operations on conn_state
Instead of setting bits manually we use set_bit, test_bit, etc.
Also remove L2CAP_ prefix from macros.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:24 -07:00
Gustavo F. Padovan
2ddee5a3fd Bluetooth: use bit operation on conf_state
Instead of making the bit operations manually, we now use set_bit,
test_bit, etc.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:24 -07:00
Vinicius Costa Gomes
b19d5cea66 Bluetooth: Add support for SMP timeout
This patch adds support for disconnecting the link when SMP procedure
takes more than 30 seconds.

SMP begins when either the Pairing Request command is sent or the
Pairing Response is received, and it ends when the link is encrypted
(or terminated). Vol 3, Part H Section 3.4.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:23 -07:00
Vinicius Costa Gomes
a5474a8d5a Bluetooth: Add support for resuming socket when SMP is finished
This adds support for resuming the user space traffic when SMP
negotiation is complete.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:22 -07:00
Anderson Briglia
ea37012695 Bluetooth: Start SMP procedure
Start SMP procedure for LE connections. This modification intercepts
l2cap received frames and call proper SMP functions to start the SMP
procedure. By now, no keys are being used.

Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
Signed-off-by: Anderson Briglia <anderson.briglia@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:20 -07:00
Gustavo F. Padovan
d7649a5cab Bluetooth: Don't forget to check for LE_LINK
Otherwise the wrong error can be returned.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:20 -07:00
Gustavo F. Padovan
446b49bee3 Bluetooth: keep reference if any ERTM timer is enabled
ERTM use the generic L2CAP timer functions to keep a reference to the
channel. This is useful for avoiding crashes.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:20 -07:00
Gustavo F. Padovan
bd69b5ae05 Bluetooth: Make timer functions generic
We now plan to use l2cap_set_timer and l2cap_clear_timer in ERTM timers.

Change-Id: Ie62b01e003f8885ae89c73e2e64195c21cbadddd
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:20 -07:00
Gustavo F. Padovan
4a6aa524c9 Bluetooth: Add refcnt to struct l2cap_chan
struct l2cap_chan has now its own refcnt that is compatible with the
socket refcnt, i.e., we won't see sk_refcnt = 0 and chan->refcnt > 0.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:19 -07:00
Gustavo F. Padovan
f1b394acd9 Bluetooth: Add state tracking to struct l2cap_chan
Now socket state is tracked by struct sock and channel state is tracked by
chan->state. At this point both says the same, but this is going to change
when we add AMP Support for example.

Change-Id: Idbf873f5e8dd94f5b2482ba960c52193d28ce5dd
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:19 -07:00
Gustavo F. Padovan
c4cf743414 Bluetooth: add close() callback to l2cap_chan_ops
close() calls l2cap_sock_kill() on l2cap_sock.c

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:19 -07:00
Gustavo F. Padovan
162025cbf7 Bluetooth: add recv() callback to l2cap_chan_ops
This abstracts the call to sock_queue_recv_skb() into
l2cap_chan_ops->recv().

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:19 -07:00
Gustavo F. Padovan
b090c4b586 Bluetooth: Add l2cap_chan_ops abstraction
Add an abstraction layer between L2CAP core and its users (only
l2cap_sock.c now). The first function implemented is new_connection() that
replaces calls to l2cap_sock_alloc() in l2cap_core.c

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:19 -07:00
Gustavo F. Padovan
b87bf5b81d Bluetooth: Merge l2cap_chan_create() in the l2cap_sock_alloc()
As a first step to remove l2cap_sock_alloc() and l2cap_sock_init() from
l2cap_core.c

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:18 -07:00
Mat Martineau
f78088ad4f Bluetooth: Fix check for the ERTM local busy state
Local busy is encoded in a bitfield, but was not masked out correctly.

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:18 -07:00
Mat Martineau
5125e9e810 Bluetooth: Restore accidentally-deleted line
When code was moved from l2cap_core.c to l2cap_sock.c in commit
6de0702b5b, one line was dropped
from the old __l2cap_sock_close() implementation. This sk_state
change should still be in l2cap_chan_close().

Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:17 -07:00
Jaikumar Ganesh
514abe61e1 Bluetooth: Add BT_POWER L2CAP socket option.
Add BT_POWER socket option used to control the power
characteristics of the underlying ACL link. When the remote end
has put the link in sniff mode and the host stack wants to send
data we need need to explicitly exit sniff mode to work well with
certain devices (For example, A2DP on Plantronics Voyager 855).
However, this causes problems with HID devices.

Hence, moving into active mode when sending data, irrespective
of who set the sniff mode has been made as a socket option. By
default, we will move into active mode. HID devices can set the
L2CAP socket option to prevent this from happening.

Currently, this has been implemented for L2CAP sockets. This has been
tested with incoming and outgoing L2CAP sockets for HID and A2DP.

Based on discussions on linux-bluetooth and patches submitted by
Andrei Emeltchenko.

Signed-off-by: Jaikumar Ganesh <jaikumar@google.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:17 -07:00
Johannes Berg
ef69a01db2 Bluetooth: fix sparse & gcc warnings
sparse complains about a few things that should
be static.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:16 -07:00
Gustavo F. Padovan
762a9905bd Bluetooth: Rename __l2cap_chan_close() to l2cap_chan_close()
To make it consistent with the rest of the API.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:13 -07:00
Gustavo F. Padovan
1eb5ad7859 Bluetooth: Remove export of l2cap_chan_clear_timer()
The call to l2cap_chan_clear_timer() is not really needed in l2cap_sock.c.
This patch also adds a call to l2cap_chan_clear_timer() to the only place
in __l2cap_sock_close() that wasn't calling it. It's safe call it there
because l2cap_chan_clear_timer() check first for timer_peding().

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
2011-07-11 11:59:13 -07:00