17 Feb, 2011

1 commit


02 Feb, 2011

1 commit

  • This patch fixes a minor issue that two connection responses will be sent
    for one L2CAP connection request. If the L2CAP connection request is first
    blocked due to security reason and responded with reason "security block",
    the state of the connection remains BT_CONNECT2. If a pairing procedure
    completes successfully before the ACL connection is down, local host will
    send another connection complete response. See the following packets
    captured by hcidump.

    2010-12-07 22:21:24.928096 < ACL data: handle 12 flags 0x00 dlen 16
    0000: 0c 00 01 00 03 19 08 00 41 00 53 00 03 00 00 00 ........A.S.....
    ... ...

    2010-12-07 22:21:35.791747 > HCI Event: Auth Complete (0x06) plen 3
    status 0x00 handle 12
    ... ...

    2010-12-07 22:21:35.872372 > ACL data: handle 12 flags 0x02 dlen 16
    L2CAP(s): Connect rsp: dcid 0x0054 scid 0x0040 result 0 status 0
    Connection successful

    Signed-off-by: Liang Bao
    Acked-by: Ville Tervo
    Signed-off-by: Gustavo F. Padovan

    Bao Liang
     

20 Jan, 2011

8 commits

  • The conn->sec_level value is supposed to represent the current level of
    security that the connection has. However, by assigning to it before
    requesting authentication it will have the wrong value during the
    authentication procedure. To fix this a pending_sec_level variable is
    added which is used to track the desired security level while making
    sure that sec_level always represents the current level of security.

    Signed-off-by: Johan Hedberg
    Signed-off-by: Gustavo F. Padovan

    Johan Hedberg
     
  • When there is an existing connection l2cap_check_security needs to be
    called to ensure that the security level of the new socket is fulfilled.
    Normally l2cap_do_start takes care of this, but that function doesn't
    get called for SOCK_RAW type sockets. This patch adds the necessary
    l2cap_check_security call to the appropriate branch in l2cap_do_connect.

    Signed-off-by: Johan Hedberg
    Acked-by: Marcel Holtmann
    Signed-off-by: Gustavo F. Padovan

    Johan Hedberg
     
  • The logic for determining the needed auth_type for an L2CAP socket is
    rather complicated and has so far been duplicated in
    l2cap_check_security as well as l2cap_do_connect. Additionally the
    l2cap_check_security code was completely missing the handling of
    SOCK_RAW type sockets. This patch creates a unified function for the
    evaluation and makes l2cap_do_connect and l2cap_check_security use that
    function.

    Signed-off-by: Johan Hedberg
    Acked-by: Marcel Holtmann
    Signed-off-by: Gustavo F. Padovan

    Johan Hedberg
     
  • If an existing connection has a MITM protection requirement (the first
    bit of the auth_type) then that requirement should not be cleared by new
    sockets that reuse the ACL but don't have that requirement.

    Signed-off-by: Johan Hedberg
    Acked-by: Marcel Holtmann
    Signed-off-by: Gustavo F. Padovan

    Johan Hedberg
     
  • This reverts commit 045309820afe047920a50de25634dab46a1e851d. That
    commit is wrong for two reasons:

    - The conn->sec_level shouldn't be updated without performing
    authentication first (as it's supposed to represent the level of
    security that the existing connection has)

    - A higher auth_type value doesn't mean "more secure" like the commit
    seems to assume. E.g. dedicated bonding with MITM protection is 0x03
    whereas general bonding without MITM protection is 0x04. hci_conn_auth
    already takes care of updating conn->auth_type so hci_connect doesn't
    need to do it.

    Signed-off-by: Johan Hedberg
    Acked-by: Marcel Holtmann
    Signed-off-by: Gustavo F. Padovan

    Johan Hedberg
     
  • Fix a bug introduced in commit 9cf5b0ea3a7f1432c61029f7aaf4b8b338628884:
    function rfcomm_recv_ua calls rfcomm_session_put without checking that
    the session is not referenced by some DLC. If the session is freed, that
    DLC would refer to deallocated memory, causing an oops later, as shown
    in this bug report: https://bugzilla.kernel.org/show_bug.cgi?id=15994

    Signed-off-by: Lukas Turek
    Signed-off-by: Gustavo F. Padovan

    Lukáš Turek
     
  • The blacklist should be freed before the hci device gets unregistered.

    Signed-off-by: Johan Hedberg
    Signed-off-by: Gustavo F. Padovan

    Johan Hedberg
     
  • CC: Marcel Holtmann
    CC: "Gustavo F. Padovan"
    CC: João Paulo Rechi Vita
    Signed-off-by: David Sterba
    Signed-off-by: Gustavo F. Padovan

    David Sterba
     

05 Jan, 2011

1 commit


23 Dec, 2010

7 commits


16 Dec, 2010

1 commit


08 Dec, 2010

2 commits


07 Dec, 2010

3 commits


02 Dec, 2010

16 commits

  • Do not use assignment in IF condition, remove extra spaces,
    fixing typos, simplify code.

    Signed-off-by: Andrei Emeltchenko
    Signed-off-by: Gustavo F. Padovan

    Andrei Emeltchenko
     
  • Do not initialize static vars to zero, macros with complex values
    shall be enclosed with (), remove unneeded braces.

    Signed-off-by: Andrei Emeltchenko
    Signed-off-by: Gustavo F. Padovan

    Andrei Emeltchenko
     
  • Remove extra spaces, assignments in if statement, zeroing static
    variables, extra braces. Fix includes.

    Signed-off-by: Andrei Emeltchenko
    Signed-off-by: Gustavo F. Padovan

    Andrei Emeltchenko
     
  • Do not use assignments in IF condition, remove extra spaces

    Signed-off-by: Andrei Emeltchenko
    Signed-off-by: Gustavo F. Padovan

    Andrei Emeltchenko
     
  • create_singlethread_workqueue() may fail with errors such as -ENOMEM. If
    this happens, the return value is not set to a negative value and the
    module load will succeed. It will then crash on module unload because of
    a destroy_workqueue() call on a NULL pointer.

    Additionally, the _busy_wq workqueue is not being destroyed if any
    errors happen on l2cap_init().

    Signed-off-by: Anderson Lizardo
    Signed-off-by: Gustavo F. Padovan

    Anderson Lizardo
     
  • rfcomm_get_sock_by_channel() was the only user of this function, so I merged
    both into rfcomm_get_sock_by_channel(). The socket lock now should be hold
    outside of rfcomm_get_sock_by_channel() once we hold and release it inside the
    same function now.

    Signed-off-by: Gustavo F. Padovan

    Gustavo F. Padovan
     
  • l2cap_get_sock_by_psm() was the only user of this function, so I merged
    both into l2cap_get_sock_by_psm(). The socket lock now should be hold
    outside of l2cap_get_sock_by_psm() once we hold and release it inside the
    same function now.

    Signed-off-by: Gustavo F. Padovan

    Gustavo F. Padovan
     
  • Fix checkpatch errors like:
    "ERROR: do not use assignment in if condition"
    Simplify code and fix one long line.

    Signed-off-by: Andrei Emeltchenko
    Acked-by: Ville Tervo
    Signed-off-by: Gustavo F. Padovan

    Andrei Emeltchenko
     
  • In timer context we might delete l2cap channel used by krfcommd.
    The check makes sure that sk is not owned. If sk is owned we
    restart timer for HZ/5.

    Signed-off-by: Andrei Emeltchenko
    Acked-by: Marcel Holtmann
    Signed-off-by: Gustavo F. Padovan

    Andrei Emeltchenko
     
  • Check that socket sk is not locked in user process before removing
    l2cap connection handler.

    lock_sock and release_sock do not hold a normal spinlock directly but
    instead hold the owner field. This means bh_lock_sock can still execute
    even if the socket is "locked". More info can be found here:
    http://www.linuxfoundation.org/collaborate/workgroups/networking/socketlocks

    krfcommd kernel thread may be preempted with l2cap tasklet which remove
    l2cap_conn structure. If krfcommd is in process of sending of RFCOMM reply
    (like "RFCOMM UA" reply to "RFCOMM DISC") then kernel crash happens.

    ...
    [ 694.175933] Unable to handle kernel NULL pointer dereference at virtual address 00000000
    [ 694.184936] pgd = c0004000
    [ 694.187683] [00000000] *pgd=00000000
    [ 694.191711] Internal error: Oops: 5 [#1] PREEMPT
    [ 694.196350] last sysfs file: /sys/devices/platform/hci_h4p/firmware/hci_h4p/loading
    [ 694.260375] CPU: 0 Not tainted (2.6.32.10 #1)
    [ 694.265106] PC is at l2cap_sock_sendmsg+0x43c/0x73c [l2cap]
    [ 694.270721] LR is at 0xd7017303
    ...
    [ 694.525085] Backtrace:
    [ 694.527587] [] (l2cap_sock_sendmsg+0x0/0x73c [l2cap]) from [] (sock_sendmsg+0xb8/0xd8)
    [ 694.537292] [] (sock_sendmsg+0x0/0xd8) from [] (kernel_sendmsg+0x48/0x80)

    Signed-off-by: Andrei Emeltchenko
    Acked-by: Marcel Holtmann
    Signed-off-by: Gustavo F. Padovan

    Andrei Emeltchenko
     
  • Structure hidp_conninfo is copied to userland with version, product,
    vendor and name fields unitialized if both session->input and session->hid
    are NULL. It leads to leaking of contents of kernel stack memory.

    Signed-off-by: Vasiliy Kulikov
    Acked-by: Marcel Holtmann
    Signed-off-by: Gustavo F. Padovan

    Vasiliy Kulikov
     
  • Structure cmtp_conninfo is copied to userland with some padding fields
    unitialized. It leads to leaking of contents of kernel stack memory.

    Signed-off-by: Vasiliy Kulikov
    Acked-by: Marcel Holtmann
    Signed-off-by: Gustavo F. Padovan

    Vasiliy Kulikov
     
  • Structure bnep_conninfo is copied to userland with the field "device"
    that has the last elements unitialized. It leads to leaking of
    contents of kernel stack memory.

    Signed-off-by: Vasiliy Kulikov
    Acked-by: Marcel Holtmann
    Signed-off-by: Gustavo F. Padovan

    Vasiliy Kulikov
     
  • In Bluetooth there are no automatic updates of remote device names when
    they get changed on the remote side. Instead, it is a good idea to do a
    manual name request when a new connection gets created (for whatever
    reason) since at this point it is very cheap (no costly baseband
    connection creation needed just for the sake of the name request).

    So far userspace has been responsible for this extra name request but
    tighter control is needed in order not to flood Bluetooth controllers
    with two many commands during connection creation. It has been shown
    that some controllers simply fail to function correctly if they get too
    many (almost) simultaneous commands during connection creation. The
    simplest way to acheive better control of these commands is to move
    their sending completely to the kernel side.

    This patch inserts name requests into the sequence of events that the
    kernel performs during connection creation. It does this after the
    remote features have been successfully requested and before any pending
    authentication requests are performed. The code will work sub-optimally
    with userspace versions that still do the name requesting themselves (it
    shouldn't break anything though) so it is recommended to combine this
    with a userspace software version that doesn't have automated name
    requests.

    Signed-off-by: Johan Hedberg
    Signed-off-by: Gustavo F. Padovan

    Johan Hedberg
     
  • This patch adds a single function that's responsible for requesting
    authentication for outgoing connections. This is preparation for the
    next patch which will add automated name requests and thereby move the
    authentication requests to a different location.

    Signed-off-by: Johan Hedberg
    Signed-off-by: Gustavo F. Padovan

    Johan Hedberg
     
  • The current remote and remote extended features event callbacks logic
    can be made simpler by using a label and goto statements instead of the
    current multiple levels of nested if statements.

    Signed-off-by: Johan Hedberg
    Signed-off-by: Gustavo F. Padovan

    Johan Hedberg