aboutsummaryrefslogtreecommitdiff
path: root/net/bluetooth/l2cap_sock.c
AgeCommit message (Collapse)AuthorFilesLines
2012-06-05Bluetooth: Check MTU value in l2cap_sock_setsockopt_oldAndre Guedes1-0/+21
If user tries to set an invalid MTU value, l2cap_sock_setsockopt_old should return -EINVAL. Signed-off-by: Andre Guedes <[email protected]> Signed-off-by: Gustavo Padovan <[email protected]>
2012-06-05Bluetooth: Move check for backlog size to l2cap_sock.cGustavo Padovan1-0/+6
Remove socket specific code from l2cap_core.c Signed-off-by: Gustavo Padovan <[email protected]> Acked-by: Andrei Emeltchenko <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
2012-06-05Bluetooth: Add l2cap_chan->ops->ready()Andrei Emeltchenko1-0/+21
This move socket specific code to l2cap_sock.c. Signed-off-by: Andrei Emeltchenko <[email protected]> Signed-off-by: Gustavo Padovan <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
2012-06-05Bluetooth: Move clean up code and set of SOCK_ZAPPED to l2cap_sock.cAndrei Emeltchenko1-0/+61
This remove a bit more of socket code from l2cap core, this calls set the SOCK_ZAPPED and do some clean up depending on the socket state. Reported-by: Mat Martineau <[email protected]> Signed-off-by: Andrei Emeltchenko <[email protected]> Signed-off-by: Gustavo Padovan <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
2012-06-05Bluetooth: Use chan as parameters for l2cap chan opsGustavo Padovan1-8/+8
Use chan instead of void * makes more sense here. Signed-off-by: Gustavo Padovan <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
2012-06-05Bluetooth: Define and use PSM identifiersAndrei Emeltchenko1-2/+2
Define assigned Protocol and Service Multiplexor (PSM) identifiers and use them instead of magic numbers. Signed-off-by: Andrei Emeltchenko <[email protected]> Signed-off-by: Gustavo Padovan <[email protected]>
2012-06-05Bluetooth: Remove unnecessary headers includeGustavo Padovan1-1/+0
Most of the include were unnecessary or already included by some other header. Replace module.h by export.h where possible. Signed-off-by: Gustavo Padovan <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
2012-05-16Bluetooth: Create flags for bt_sk()Gustavo Padovan1-8/+13
defer_setup and suspended are now flags into bt_sk(). Signed-off-by: Gustavo Padovan <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
2012-05-16Bluetooth: report the right security level in getsockoptGustavo Padovan1-1/+4
During a security level elevation we need to keep track of the current security level of a connection until the new one is not confirmed. Signed-off-by: Gustavo Padovan <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
2012-05-16Bluetooth: Lock the L2CAP channel when sendingMat Martineau1-6/+6
The ERTM and streaming mode transmit queue must only be accessed while the L2CAP channel lock is held. Locking the channel before calling l2cap_chan_send ensures that multiple threads cannot simultaneously manipulate the queue when sending and receiving concurrently. L2CAP channel locking had previously moved to the l2cap_chan struct instead of the associated socket, so some of the old socket locking can also be removed in this patch. Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: Gustavo Padovan <[email protected]>
2012-05-16Merge git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetoothGustavo Padovan1-4/+8
2012-05-14Bluetooth: notify userspace of security level changeGustavo Padovan1-4/+8
It fixes L2CAP socket based security level elevation during a connection. The HID profile needs this (for keyboards) and it is the only way to achieve the security level elevation when using the management interface to talk to the kernel (hence the management enabling patch being the one that exposes this issue). It enables the userspace a security level change when the socket is already connected and create a way to notify the socket the result of the request. At the moment of the request the socket is made non writable, if the request fails the connections closes, otherwise the socket is made writable again, POLL_OUT is emmited. Signed-off-by: Gustavo Padovan <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]> Signed-off-by: John W. Linville <[email protected]>
2012-05-09Bluetooth: Make better use of l2cap_chan reference countingMat Martineau1-0/+3
L2CAP sockets contain a pointer to l2cap_chan that needs to be reference counted in order to prevent a possible dangling pointer when the channel is freed. There were a few other cases where an l2cap_chan pointer on the stack was dereferenced after a call to l2cap_chan_del. Those pointers are also now reference counted. Signed-off-by: Mat Martineau <[email protected]> Signed-off-by: Gustavo Padovan <[email protected]>
2012-05-09Bluetooth: Use address type info from user-spaceAndre Guedes1-1/+1
In order to establish a LE connection we need the address type information. User-space already pass this information to kernel through struct sockaddr_l2. This patch adds the dst_type parameter to l2cap_chan_connect so we are able to pass the address type info from user-space down to hci_conn layer. Signed-off-by: Andre Guedes <[email protected]> Acked-by: Johan Hedberg <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
2012-05-09Bluetooth: Split error handling for L2CAP listen socketsMarcel Holtmann1-2/+6
Split the checks for sk->sk_state and sk->sk_type for L2CAP listen sockets. This makes the code more readable. Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Gustavo Padovan <[email protected]>
2012-05-09Bluetooth: Remove err parameter from alloc_skb()Gustavo Padovan1-4/+8
Use ERR_PTR maginc instead. Signed-off-by: Gustavo Padovan <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
2012-05-09Bluetooth: Adds set_default function in L2CAP setupAndrei Emeltchenko1-6/+2
Some parameters in L2CAP chan are set to default similar way in socket based channels and A2MP channels. Adds common function which sets all defaults. Signed-off-by: Andrei Emeltchenko <[email protected]> Signed-off-by: Gustavo Padovan <[email protected]>
2012-05-09Bluetooth: Remove unneeded zero initializationAndrei Emeltchenko1-1/+0
Remove zero initialization since channel is allocated with kzalloc in l2cap_chan_create. Signed-off-by: Andrei Emeltchenko <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Signed-off-by: Gustavo Padovan <[email protected]>
2012-05-09Bluetooth: Remove sk parameter from l2cap_chan_create()Gustavo Padovan1-1/+3
Following the separation if core and sock code this change avoid manipulation of sk inside l2cap_chan_create(). Signed-off-by: Gustavo Padovan <[email protected]>
2012-03-28Bluetooth: Fix Endian Bug.Santosh Nayak1-2/+3
Fix network to host endian conversion for L2CAP chan id. Signed-off-by: Santosh Nayak <[email protected]> Acked-by: Andrei Emeltchenko <[email protected]> Signed-off-by: Gustavo F. Padovan <[email protected]>
2012-03-08Bluetooth: fix conding style issues all over the treeGustavo F. Padovan1-1/+2
Signed-off-by: Gustavo F. Padovan <[email protected]>
2012-03-02Bluetooth: Update L2CAP timeout constants to use msecs_to_jiffiesMarcel Holtmann1-1/+1
The L2CAP timeout constants are always used in form of jiffies. So just include the conversion from msecs in the define itself. This has the advantage of making the code where the timeout is used more readable. Signed-off-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
2012-02-23Bluetooth: Remove socket lock checkAndrei Emeltchenko1-4/+4
Simplify code so that we do not need to check whether socket is locked. Signed-off-by: Andrei Emeltchenko <[email protected]> Acked-by: Gustavo F. Padovan <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
2012-02-23Bluetooth: Change sk lock to chan lock in L2CAP coreAndrei Emeltchenko1-2/+16
Change sk lock to chan lock in l2cap core and move sk locks to l2cap sock code. bh_locks were used because of being RCU critical section. When needed use explicit socket locks. Signed-off-by: Andrei Emeltchenko <[email protected]> Reviewed-by: Ulisses Furquim <[email protected]> Acked-by: Gustavo F. Padovan <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
2012-02-23Bluetooth: Revert to mutexes from RCU listAndrei Emeltchenko1-0/+10
Usage of RCU list looks not reasonalbe for a number of reasons: our code sleep and we had to use socket spinlocks. Most parts of code are updaters thus there is little sense to use RCU. Signed-off-by: Andrei Emeltchenko <[email protected]> Reviewed-by: Ulisses Furquim <[email protected]> Acked-by: Gustavo F. Padovan <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
2012-02-17Bluetooth: Use symbolic names for state in debugAndrei Emeltchenko1-1/+1
Use state_to_string function in debug statements. Signed-off-by: Andrei Emeltchenko <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
2012-02-16Bluetooth: Do not dereference zero skAndrei Emeltchenko1-1/+3
Signed-off-by: Andrei Emeltchenko <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
2012-02-13Bluetooth: Add alloc_skb chan operatorAndrei Emeltchenko1-0/+9
Add channel-specific skb allocation method Signed-off-by: Andrei Emeltchenko <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
2012-02-13Bluetooth: silence lockdep warningOctavian Purdila1-0/+2
Since bluetooth uses multiple protocols types, to avoid lockdep warnings, we need to use different lockdep classes (one for each protocol type). This is already done in bt_sock_create but it misses a couple of cases when new connections are created. This patch corrects that to fix the following warning: <4>[ 1864.732366] ======================================================= <4>[ 1864.733030] [ INFO: possible circular locking dependency detected ] <4>[ 1864.733544] 3.0.16-mid3-00007-gc9a0f62 #3 <4>[ 1864.733883] ------------------------------------------------------- <4>[ 1864.734408] t.android.btclc/4204 is trying to acquire lock: <4>[ 1864.734869] (rfcomm_mutex){+.+.+.}, at: [<c14970ea>] rfcomm_dlc_close+0x15/0x30 <4>[ 1864.735541] <4>[ 1864.735549] but task is already holding lock: <4>[ 1864.736045] (sk_lock-AF_BLUETOOTH){+.+.+.}, at: [<c1498bf7>] lock_sock+0xa/0xc <4>[ 1864.736732] <4>[ 1864.736740] which lock already depends on the new lock. <4>[ 1864.736750] <4>[ 1864.737428] <4>[ 1864.737437] the existing dependency chain (in reverse order) is: <4>[ 1864.738016] <4>[ 1864.738023] -> #1 (sk_lock-AF_BLUETOOTH){+.+.+.}: <4>[ 1864.738549] [<c1062273>] lock_acquire+0x104/0x140 <4>[ 1864.738977] [<c13d35c1>] lock_sock_nested+0x58/0x68 <4>[ 1864.739411] [<c1493c33>] l2cap_sock_sendmsg+0x3e/0x76 <4>[ 1864.739858] [<c13d06c3>] __sock_sendmsg+0x50/0x59 <4>[ 1864.740279] [<c13d0ea2>] sock_sendmsg+0x94/0xa8 <4>[ 1864.740687] [<c13d0ede>] kernel_sendmsg+0x28/0x37 <4>[ 1864.741106] [<c14969ca>] rfcomm_send_frame+0x30/0x38 <4>[ 1864.741542] [<c1496a2a>] rfcomm_send_ua+0x58/0x5a <4>[ 1864.741959] [<c1498447>] rfcomm_run+0x441/0xb52 <4>[ 1864.742365] [<c104f095>] kthread+0x63/0x68 <4>[ 1864.742742] [<c14d5182>] kernel_thread_helper+0x6/0xd <4>[ 1864.743187] <4>[ 1864.743193] -> #0 (rfcomm_mutex){+.+.+.}: <4>[ 1864.743667] [<c1061ada>] __lock_acquire+0x988/0xc00 <4>[ 1864.744100] [<c1062273>] lock_acquire+0x104/0x140 <4>[ 1864.744519] [<c14d2c70>] __mutex_lock_common+0x3b/0x33f <4>[ 1864.744975] [<c14d303e>] mutex_lock_nested+0x2d/0x36 <4>[ 1864.745412] [<c14970ea>] rfcomm_dlc_close+0x15/0x30 <4>[ 1864.745842] [<c14990d9>] __rfcomm_sock_close+0x5f/0x6b <4>[ 1864.746288] [<c1499114>] rfcomm_sock_shutdown+0x2f/0x62 <4>[ 1864.746737] [<c13d275d>] sys_socketcall+0x1db/0x422 <4>[ 1864.747165] [<c14d42f0>] syscall_call+0x7/0xb Signed-off-by: Octavian Purdila <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
2012-02-13Bluetooth: Fix sk_sndtimeo initialization for L2CAP socketAndrzej Kaczmarek1-1/+1
sk_sndtime value should be specified in jiffies thus initial value needs to be converted from miliseconds. Otherwise this timeout is unreliable when CONFIG_HZ is not set to 1000. Signed-off-by: Andrzej Kaczmarek <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Signed-off-by: Johan Hedberg <[email protected]>
2012-01-03Bluetooth: Keep chan->state and sk->sk_state in syncGustavo F. Padovan1-0/+2
Those vars need to be in sync, otherwise l2cap_core.c can get the wrong state. Signed-off-by: Gustavo F. Padovan <[email protected]>
2011-12-19Merge branch 'master' of ↵John W. Linville1-58/+4
git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth-next
2011-12-18Bluetooth: Add ProFUSION's copyrightGustavo F. Padovan1-0/+1
Add ProFUSION's copyright to some files I've been touching recently. Signed-off-by: Gustavo F. Padovan <[email protected]>
2011-12-18Bluetooth: invert locking order in connect pathGustavo F. Padovan1-58/+3
This move some checking code that was in l2cap_sock_connect() to l2cap_chan_connect(). Thus we can invert the lock calls, i.e., call lock_sock() before hci_dev_lock() to avoid a deadlock scenario. Acked-by: Marcel Holtmann <[email protected]> Signed-off-by: Gustavo F. Padovan <[email protected]>
2011-12-16Bluetooth: Use chan instead of l2cap_pi macroGustavo F. Padovan1-1/+1
Signed-off-by: Gustavo F. Padovan <[email protected]>
2011-12-06Merge branch 'master' of ↵John W. Linville1-3/+13
git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth-next
2011-11-22Merge branch 'master' of ↵John W. Linville1-0/+1
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux Conflicts: drivers/net/wireless/iwlegacy/iwl-debugfs.c drivers/net/wireless/iwlegacy/iwl-rx.c drivers/net/wireless/iwlegacy/iwl-scan.c drivers/net/wireless/iwlegacy/iwl-tx.c include/net/bluetooth/bluetooth.h
2011-11-10Bluetooth: Allow L2CAP to increase the security levelGustavo F. Padovan1-3/+13
Some incomming connections needs to increase the security level by requesting encryption for example (HID keyboard case). This change allows the userspace to change it through setsockopt with defer_setup enabled. Signed-off-by: Gustavo F. Padovan <[email protected]>
2011-11-09Merge branch 'master' of ↵John W. Linville1-22/+68
git://git.kernel.org/pub/scm/linux/kernel/git/padovan/bluetooth-next Conflicts: net/bluetooth/l2cap_sock.c net/bluetooth/mgmt.c
2011-11-07Bluetooth: Add channel policy to getsockopt/setsockoptMat Martineau1-0/+35
Each channel has a policy to require BR/EDR (the default), prefer BR/EDR, or prefer AMP. Check for valid policy value and L2CAP mode. Signed-off-by: Mat Martineau <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Acked-by: Andrei Emeltchenko <[email protected]> Signed-off-by: Gustavo F. Padovan <[email protected]>
2011-11-07Bluetooth: Initialize tx_win_max for fixed channelAndrei Emeltchenko1-0/+2
tx_win_max is initialized during L2CAP configuration phase. For fixed channels (e.g. A2MP) we want to have it initialized when channel is created. Signed-off-by: Andrei Emeltchenko <[email protected]> Acked-by: Marcel Holtmann <[email protected]> Signed-off-by: Gustavo F. Padovan <[email protected]>
2011-11-07Bluetooth: set skbuffer priority based on L2CAP socket priorityLuiz Augusto von Dentz1-1/+1
This uses SO_PRIORITY to set the skbuffer priority field Signed-off-by: Luiz Augusto von Dentz <[email protected]> Signed-off-by: Gustavo F. Padovan <[email protected]>
2011-10-31net: Add export.h for EXPORT_SYMBOL/THIS_MODULE to non-modulesPaul Gortmaker1-0/+1
These files are non modular, but need to export symbols using the macros now living in export.h -- call out the include so that things won't break when we remove the implicit presence of module.h from everywhere. Signed-off-by: Paul Gortmaker <[email protected]>
2011-10-18bluetooth: Properly clone LSM attributes to newly created child connectionsPaul Moore1-0/+4
The Bluetooth stack has internal connection handlers for all of the various Bluetooth protocols, and unfortunately, they are currently lacking the LSM hooks found in the core network stack's connection handlers. I say unfortunately, because this can cause problems for users who have have an LSM enabled and are using certain Bluetooth devices. See one problem report below: * http://bugzilla.redhat.com/show_bug.cgi?id=741703 In order to keep things simple at this point in time, this patch fixes the problem by cloning the parent socket's LSM attributes to the newly created child socket. If we decide we need a more elaborate LSM marking mechanism for Bluetooth (I somewhat doubt this) we can always revisit this decision in the future. Reported-by: James M. Cape <[email protected]> Signed-off-by: Paul Moore <[email protected]> Acked-by: James Morris <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2011-10-13Bluetooth: EWS: extended window size option supportAndrei Emeltchenko1-4/+4
Adds support for extended window size (EWS) config option. We enable EWS feature in L2CAP Info RSP when hs enabled. EWS option is included in L2CAP Config Req if tx_win (which is set via socket) bigger then standard default value (63) && hs enabled && remote side supports EWS feature. Using EWS selects extended control field in L2CAP. Code partly based on Qualcomm and Atheros patches sent upstream a year ago. Signed-off-by: Andrei Emeltchenko <[email protected]> Signed-off-by: Gustavo F. Padovan <[email protected]>
2011-10-11Bluetooth: convert role_switch variable to flag in l2cap chanAndrei Emeltchenko1-4/+5
role_switch variable inside l2cap_chan is a logical one and can be easily converted to flag Signed-off-by: Andrei Emeltchenko <[email protected]> Signed-off-by: Gustavo F. Padovan <[email protected]>
2011-10-11Bluetooth: convert force_active variable to flag in l2cap chanAndrei Emeltchenko1-5/+7
force_active variable inside l2cap_chan is a logical one and can be easily converted to flag Signed-off-by: Andrei Emeltchenko <[email protected]> Signed-off-by: Gustavo F. Padovan <[email protected]>
2011-10-11Bluetooth: convert force_reliable variable to flag in l2cap chanAndrei Emeltchenko1-4/+6
force_reliable variable inside l2cap_chan is a logical one and can be easily converted to flag Signed-off-by: Andrei Emeltchenko <[email protected]> Signed-off-by: Gustavo F. Padovan <[email protected]>
2011-10-11Bluetooth: convert flushable variable to flag in l2cap chanAndrei Emeltchenko1-4/+8
flushable variable inside l2cap_chan is a logical one and can be easily converted to flag. Added flags in l2cap_chan structure. Signed-off-by: Andrei Emeltchenko <[email protected]> Signed-off-by: Gustavo F. Padovan <[email protected]>
2011-08-11Bluetooth: Fixed wrong L2CAP Sock timer valueChen Ganir1-1/+1
L2CAP connection timeout needs to be assigned as miliseconds and not as jiffies. Signed-off-by: Chen Ganir <[email protected]> Signed-off-by: Gustavo F. Padovan <[email protected]>