28 Sep, 2013

1 commit


21 Sep, 2013

1 commit

  • When the dlc is closed, rfcomm_dev_state_change() tries to release the
    port in the case it cannot get a reference to the tty. However this is
    racy and not even needed.

    Infact as Peter Hurley points out:

    1. Only consider dlcs that are 'stolen' from a connected socket, ie.
    reused. Allocated dlcs cannot have been closed prior to port
    activate and so for these dlcs a tty reference will always be avail
    in rfcomm_dev_state_change() -- except for the conditions covered by
    #2b below.
    2. If a tty was at some point previously created for this rfcomm, then
    either
    (a) the tty reference is still avail, so rfcomm_dev_state_change()
    will perform a hangup. So nothing to do, or,
    (b) the tty reference is no longer avail, and the tty_port will be
    destroyed by the last tty_port_put() in rfcomm_tty_cleanup.
    Again, no action required.
    3. Prior to obtaining the dlc lock in rfcomm_dev_add(),
    rfcomm_dev_state_change() will not 'see' a rfcomm_dev so nothing to
    do here.
    4. After releasing the dlc lock in rfcomm_dev_add(),
    rfcomm_dev_state_change() will 'see' an incomplete rfcomm_dev if a
    tty reference could not be obtained. Again, the best thing to do here
    is nothing. Any future attempted open() will block on
    rfcomm_dev_carrier_raised(). The unconnected device will exist until
    released by ioctl(RFCOMMRELEASEDEV).

    The patch removes the aforementioned code and uses the
    tty_port_tty_hangup() helper to hangup the tty.

    Signed-off-by: Gianluca Anzolin
    Reviewed-by: Peter Hurley
    Signed-off-by: Gustavo Padovan

    Gianluca Anzolin
     

19 Sep, 2013

2 commits

  • We need to let the setup stage complete cleanly even when the HCI device
    is rfkilled. Otherwise the HCI device will stay in an undefined state
    and never get notified to user space through mgmt (even when it gets
    unblocked through rfkill).

    This patch makes sure that hci_dev_open() can be called in the HCI_SETUP
    stage, that blocking the device doesn't abort the setup stage, and that
    the device gets proper powered down as soon as the setup stage completes
    in case it was blocked meanwhile.

    The bug that this patch fixed can be very easily reproduced using e.g.
    the rfkill command line too. By running "rfkill block all" before
    inserting a Bluetooth dongle the resulting HCI device goes into a state
    where it is never announced over mgmt, not even when "rfkill unblock all"
    is run.

    Signed-off-by: Johan Hedberg
    Cc: stable@vger.kernel.org
    Acked-by: Marcel Holtmann
    Signed-off-by: Gustavo Padovan

    Johan Hedberg
     
  • This makes it more convenient to check for rfkill (no need to check for
    dev->rfkill before calling rfkill_blocked()) and also avoids potential
    races if the RFKILL state needs to be checked from within the rfkill
    callback.

    Signed-off-by: Johan Hedberg
    Cc: stable@vger.kernel.org
    Acked-by: Marcel Holtmann
    Signed-off-by: Gustavo Padovan

    Johan Hedberg
     

17 Sep, 2013

3 commits

  • For certain devices (ex: HID mouse), support for authentication,
    pairing and bonding is optional. For such devices, the ACL alive
    for too long after the L2CAP disconnection.

    To avoid the ACL alive for too long after L2CAP disconnection, reset the
    ACL disconnect timeout back to HCI_DISCONN_TIMEOUT during L2CAP connect.

    While merging the commit id:a9ea3ed9b71cc3271dd59e76f65748adcaa76422
    this issue might have introduced.

    Hcidump info:
    sh-4.1# /opt/hcidump -Xt
    2013-08-05 16:49:00.894129 < ACL data: handle 12 flags 0x00 dlen 12
    L2CAP(s): Disconn req: dcid 0x004a scid 0x0041
    2013-08-05 16:49:00.894195 < HCI Command: Exit Sniff Mode (0x02|0x0004)
    plen 2
    handle 12
    2013-08-05 16:49:00.894269 < ACL data: handle 12 flags 0x00 dlen 12
    L2CAP(s): Disconn req: dcid 0x0049 scid 0x0040
    2013-08-05 16:49:00.895645 > HCI Event: Command Status (0x0f) plen 4
    Exit Sniff Mode (0x02|0x0004) status 0x00 ncmd 1
    2013-08-05 16:49:00.934391 > HCI Event: Mode Change (0x14) plen 6
    status 0x00 handle 12 mode 0x00 interval 0
    Mode: Active
    2013-08-05 16:49:00.936592 > HCI Event: Number of Completed Packets
    (0x13) plen 5
    handle 12 packets 2
    2013-08-05 16:49:00.951577 > ACL data: handle 12 flags 0x02 dlen 12
    L2CAP(s): Disconn rsp: dcid 0x004a scid 0x0041
    2013-08-05 16:49:00.952820 > ACL data: handle 12 flags 0x02 dlen 12
    L2CAP(s): Disconn rsp: dcid 0x0049 scid 0x0040
    2013-08-05 16:49:00.969165 > HCI Event: Mode Change (0x14) plen 6
    status 0x00 handle 12 mode 0x02 interval 50
    Mode: Sniff

    2013-08-05 16:49:48.175533 > HCI Event: Mode Change (0x14) plen 6
    status 0x00 handle 12 mode 0x00 interval 0
    Mode: Active
    2013-08-05 16:49:48.219045 > HCI Event: Mode Change (0x14) plen 6
    status 0x00 handle 12 mode 0x02 interval 108
    Mode: Sniff

    2013-08-05 16:51:00.968209 < HCI Command: Disconnect (0x01|0x0006) plen 3
    handle 12 reason 0x13
    Reason: Remote User Terminated Connection
    2013-08-05 16:51:00.969056 > HCI Event: Command Status (0x0f) plen 4
    Disconnect (0x01|0x0006) status 0x00 ncmd 1
    2013-08-05 16:51:01.013495 > HCI Event: Mode Change (0x14) plen 6
    status 0x00 handle 12 mode 0x00 interval 0
    Mode: Active
    2013-08-05 16:51:01.073777 > HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 12 reason 0x16
    Reason: Connection Terminated by Local Host

    ============================ After fix ================================

    2013-08-05 16:57:35.986648 < ACL data: handle 11 flags 0x00 dlen 12
    L2CAP(s): Disconn req: dcid 0x004c scid 0x0041
    2013-08-05 16:57:35.986713 < HCI Command: Exit Sniff Mode (0x02|0x0004)
    plen 2
    handle 11
    2013-08-05 16:57:35.986785 < ACL data: handle 11 flags 0x00 dlen 12
    L2CAP(s): Disconn req: dcid 0x004b scid 0x0040
    2013-08-05 16:57:35.988110 > HCI Event: Command Status (0x0f) plen 4
    Exit Sniff Mode (0x02|0x0004) status 0x00 ncmd 1
    2013-08-05 16:57:36.030714 > HCI Event: Mode Change (0x14) plen 6
    status 0x00 handle 11 mode 0x00 interval 0
    Mode: Active
    2013-08-05 16:57:36.032950 > HCI Event: Number of Completed Packets
    (0x13) plen 5
    handle 11 packets 2
    2013-08-05 16:57:36.047926 > ACL data: handle 11 flags 0x02 dlen 12
    L2CAP(s): Disconn rsp: dcid 0x004c scid 0x0041
    2013-08-05 16:57:36.049200 > ACL data: handle 11 flags 0x02 dlen 12
    L2CAP(s): Disconn rsp: dcid 0x004b scid 0x0040
    2013-08-05 16:57:36.065509 > HCI Event: Mode Change (0x14) plen 6
    status 0x00 handle 11 mode 0x02 interval 50
    Mode: Sniff

    2013-08-05 16:57:40.052006 < HCI Command: Disconnect (0x01|0x0006) plen 3
    handle 11 reason 0x13
    Reason: Remote User Terminated Connection
    2013-08-05 16:57:40.052869 > HCI Event: Command Status (0x0f) plen 4
    Disconnect (0x01|0x0006) status 0x00 ncmd 1
    2013-08-05 16:57:40.104731 > HCI Event: Mode Change (0x14) plen 6
    status 0x00 handle 11 mode 0x00 interval 0
    Mode: Active
    2013-08-05 16:57:40.146935 > HCI Event: Disconn Complete (0x05) plen 4
    status 0x00 handle 11 reason 0x16
    Reason: Connection Terminated by Local Host

    Signed-off-by: Sang-Ki Park
    Signed-off-by: Chan-yeol Park
    Signed-off-by: Jaganath Kanakkassery
    Signed-off-by: Szymon Janc
    Signed-off-by: Syam Sidhardhan
    Signed-off-by: Gustavo Padovan

    Syam Sidhardhan
     
  • This patch fixes the connection encryption key size information when
    the host is playing the peripheral role. We should set conn->enc_key_
    size in hci_le_ltk_request_evt, otherwise it is left uninitialized.

    Cc: Stable
    Signed-off-by: Andre Guedes
    Signed-off-by: Gustavo Padovan

    Andre Guedes
     
  • While playing the peripheral role, the host gets a LE Long Term Key
    Request Event from the controller when a connection is established
    with a bonded device. The host then informs the LTK which should be
    used for the connection. Once the link is encrypted, the host gets
    an Encryption Change Event.

    Therefore we should set conn->pending_sec_level instead of conn->
    sec_level in hci_le_ltk_request_evt. This way, conn->sec_level is
    properly updated in hci_encrypt_change_evt.

    Moreover, since we have a LTK associated to the device, we have at
    least BT_SECURITY_MEDIUM security level.

    Cc: Stable
    Signed-off-by: Andre Guedes
    Signed-off-by: Gustavo Padovan

    Andre Guedes
     

07 Sep, 2013

1 commit

  • Pull HID updates from Jiri Kosina:
    "Highlights:

    - conversion of HID subsystem to use devm-based resource management,
    from Benjamin Tissoires

    - i2c-hid support for DT bindings, from Benjamin Tissoires

    - much improved support for Win8-multitouch devices, from Benjamin
    Tissoires

    - cleanup of core code using common hidinput_input_event(), from
    David Herrmann

    - fix for bug in implement() access to the bit stream (causing oops)
    that has been present in the code for ages, but devices that are
    able to trigger it have started to appear only now, from Jiri
    Kosina

    - fixes for CVE-2013-2899, CVE-2013-2898, CVE-2013-2896,
    CVE-2013-2892, CVE-2013-2888 (all triggerable only by specially
    crafted malicious HW devices plugged into the system), from Kees
    Cook

    - hidraw oops fix, from Manoj Chourasia

    - various smaller fixes here and there, support for a bunch of new
    devices by various contributors"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (53 commits)
    HID: MAINTAINERS: add roccat drivers
    HID: hid-sensor-hub: change kmalloc + memcpy by kmemdup
    HID: hid-sensor-hub: move to devm_kzalloc
    HID: hid-sensor-hub: fix indentation accross the code
    HID: move HID_REPORT_TYPES closer to the report-definitions
    HID: check for NULL field when setting values
    HID: picolcd_core: validate output report details
    HID: sensor-hub: validate feature report details
    HID: ntrig: validate feature report details
    HID: pantherlord: validate output report details
    HID: hid-wiimote: print small buffers via %*phC
    HID: uhid: improve uhid example client
    HID: Correct the USB IDs for the new Macbook Air 6
    HID: wiimote: add support for Guitar-Hero guitars
    HID: wiimote: add support for Guitar-Hero drums
    Input: introduce BTN/ABS bits for drums and guitars
    HID: battery: don't do DMA from stack
    HID: roccat: add support for KonePureOptical v2
    HID: picolcd: Prevent NULL pointer dereference on _remove()
    HID: usbhid: quirk for N-Trig DuoSense Touch Screen
    ...

    Linus Torvalds
     

06 Sep, 2013

1 commit

  • Pull networking changes from David Miller:
    "Noteworthy changes this time around:

    1) Multicast rejoin support for team driver, from Jiri Pirko.

    2) Centralize and simplify TCP RTT measurement handling in order to
    reduce the impact of bad RTO seeding from SYN/ACKs. Also, when
    both timestamps and local RTT measurements are available prefer
    the later because there are broken middleware devices which
    scramble the timestamp.

    From Yuchung Cheng.

    3) Add TCP_NOTSENT_LOWAT socket option to limit the amount of kernel
    memory consumed to queue up unsend user data. From Eric Dumazet.

    4) Add a "physical port ID" abstraction for network devices, from
    Jiri Pirko.

    5) Add a "suppress" operation to influence fib_rules lookups, from
    Stefan Tomanek.

    6) Add a networking development FAQ, from Paul Gortmaker.

    7) Extend the information provided by tcp_probe and add ipv6 support,
    from Daniel Borkmann.

    8) Use RCU locking more extensively in openvswitch data paths, from
    Pravin B Shelar.

    9) Add SCTP support to openvswitch, from Joe Stringer.

    10) Add EF10 chip support to SFC driver, from Ben Hutchings.

    11) Add new SYNPROXY netfilter target, from Patrick McHardy.

    12) Compute a rate approximation for sending in TCP sockets, and use
    this to more intelligently coalesce TSO frames. Furthermore, add
    a new packet scheduler which takes advantage of this estimate when
    available. From Eric Dumazet.

    13) Allow AF_PACKET fanouts with random selection, from Daniel
    Borkmann.

    14) Add ipv6 support to vxlan driver, from Cong Wang"

    Resolved conflicts as per discussion.

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1218 commits)
    openvswitch: Fix alignment of struct sw_flow_key.
    netfilter: Fix build errors with xt_socket.c
    tcp: Add missing braces to do_tcp_setsockopt
    caif: Add missing braces to multiline if in cfctrl_linkup_request
    bnx2x: Add missing braces in bnx2x:bnx2x_link_initialize
    vxlan: Fix kernel panic on device delete.
    net: mvneta: implement ->ndo_do_ioctl() to support PHY ioctls
    net: mvneta: properly disable HW PHY polling and ensure adjust_link() works
    icplus: Use netif_running to determine device state
    ethernet/arc/arc_emac: Fix huge delays in large file copies
    tuntap: orphan frags before trying to set tx timestamp
    tuntap: purge socket error queue on detach
    qlcnic: use standard NAPI weights
    ipv6:introduce function to find route for redirect
    bnx2x: VF RSS support - VF side
    bnx2x: VF RSS support - PF side
    vxlan: Notify drivers for listening UDP port changes
    net: usbnet: update addr_assign_type if appropriate
    driver/net: enic: update enic maintainers and driver
    driver/net: enic: Exposing symbols for Cisco's low latency driver
    ...

    Linus Torvalds
     

05 Sep, 2013

1 commit

  • Pull PTR_RET() removal patches from Rusty Russell:
    "PTR_RET() is a weird name, and led to some confusing usage. We ended
    up with PTR_ERR_OR_ZERO(), and replacing or fixing all the usages.

    This has been sitting in linux-next for a whole cycle"

    [ There are still some PTR_RET users scattered about, with some of them
    possibly being new, but most of them existing in Rusty's tree too. We
    have that

    #define PTR_RET(p) PTR_ERR_OR_ZERO(p)

    thing in , so they continue to work for now - Linus ]

    * tag 'PTR_RET-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    GFS2: Replace PTR_RET with PTR_ERR_OR_ZERO
    Btrfs: volume: Replace PTR_RET with PTR_ERR_OR_ZERO
    drm/cma: Replace PTR_RET with PTR_ERR_OR_ZERO
    sh_veu: Replace PTR_RET with PTR_ERR_OR_ZERO
    dma-buf: Replace PTR_RET with PTR_ERR_OR_ZERO
    drivers/rtc: Replace PTR_RET with PTR_ERR_OR_ZERO
    mm/oom_kill: remove weird use of ERR_PTR()/PTR_ERR().
    staging/zcache: don't use PTR_RET().
    remoteproc: don't use PTR_RET().
    pinctrl: don't use PTR_RET().
    acpi: Replace weird use of PTR_RET.
    s390: Replace weird use of PTR_RET.
    PTR_RET is now PTR_ERR_OR_ZERO(): Replace most.
    PTR_RET is now PTR_ERR_OR_ZERO

    Linus Torvalds
     

04 Sep, 2013

1 commit


23 Aug, 2013

1 commit


21 Aug, 2013

16 commits

  • When initiating a transparent eSCO connection, make use of T2 settings
    at first try. T2 is the recommended settings from HFP 1.6 WideBand
    Speech. Upon connection failure, try T1 settings.

    When CVSD is requested and eSCO is supported, try to establish eSCO
    connection using S3 settings. If it fails, fallback in sequence to S2,
    S1, D1, D0 settings.

    To know which setting should be used, conn->attempt is used. It
    indicates the currently ongoing SCO connection attempt and can be used
    as the index for the fallback settings table.

    These setting and the fallback order are described in Bluetooth HFP 1.6
    specification p. 101.

    Signed-off-by: Frédéric Dalleau
    Signed-off-by: Johan Hedberg
    Signed-off-by: Gustavo Padovan

    Frédéric Dalleau
     
  • Synchronous Connection Complete event can return error "Connection
    Rejected due to Limited resources (0x10)".
    Handling this error is required for SCO connection fallback. This error
    happens when the server tried to accept the connection but failed to
    negotiate settings.
    This error code has been verified experimentally by sending a T2 request
    to a T1 only SCO listener.

    Client dump follows :

    < HCI Command (0x01|0x0028) plen 17 [hci0] 3.696064
    Handle: 12
    Transmit bandwidth: 8000
    Receive bandwidth: 8000
    Max latency: 13
    Setting: 0x0003
    Retransmission effort: Optimize for link quality (0x02)
    Packet type: 0x0380
    > HCI Event (0x0f) plen 4 [hci0] 3.697034
    Setup Synchronous Connection (0x01|0x0028) ncmd 1
    Status: Success (0x00)
    > HCI Event (0x2c) plen 17 [hci0] 3.736059
    Status: Connection Rejected due to Limited Resources (0x0d)
    Handle: 0
    Address: xx:xx:xx:xx:xx:AB (OUI 70-F3-95)
    Link type: eSCO (0x02)
    Transmission interval: 0x0c
    Retransmission window: 0x06
    RX packet length: 60
    TX packet length: 60
    Air mode: Transparent (0x03)

    Server dump follows :

    > HCI Event (0x04) plen 10 [hci0] 4.741513
    Address: xx:xx:xx:xx:xx:D9 (OUI 20-68-9D)
    Class: 0x620100
    Major class: Computer (desktop, notebook, PDA, organizers)
    Minor class: Uncategorized, code for device not assigned
    Networking (LAN, Ad hoc)
    Audio (Speaker, Microphone, Headset)
    Telephony (Cordless telephony, Modem, Headset)
    Link type: eSCO (0x02)
    < HCI Command (0x01|0x0029) plen 21 [hci0] 4.743269
    Address: xx:xx:xx:xx:xx:D9 (OUI 20-68-9D)
    Transmit bandwidth: 8000
    Receive bandwidth: 8000
    Max latency: 13
    Setting: 0x0003
    Retransmission effort: Optimize for link quality (0x02)
    Packet type: 0x03c1
    > HCI Event (0x0f) plen 4 [hci0] 4.745517
    Accept Synchronous Connection (0x01|0x0029) ncmd 1
    Status: Success (0x00)
    > HCI Event (0x2c) plen 17 [hci0] 4.749508
    Status: Connection Rejected due to Limited Resources (0x0d)
    Handle: 0
    Address: xx:xx:xx:xx:xx:D9 (OUI 20-68-9D)
    Link type: eSCO (0x02)
    Transmission interval: 0x0c
    Retransmission window: 0x06
    RX packet length: 60
    TX packet length: 60
    Air mode: Transparent (0x03)

    Signed-off-by: Frédéric Dalleau
    Acked-by: Marcel Holtmann
    Signed-off-by: Gustavo Padovan

    Frédéric Dalleau
     
  • Older Bluetooth devices may not support Setup Synchronous Connection or
    SCO transparent data. This is indicated by the corresponding LMP feature
    bits. It is not possible to know if the adapter support these features
    before setting BT_VOICE option since the socket is not bound to an
    adapter. An adapter can also be added after the socket is created. The
    socket can be bound to an address before adapter is plugged in.

    Thus, on a such adapters, if user request BT_VOICE_TRANSPARENT, outgoing
    connections fail on connect() and returns -EOPNOTSUPP. Incoming
    connections do not fail. However, they should only be allowed depending
    on what was specified in Write_Voice_Settings command.

    EOPNOTSUPP is choosen because connect() system call is failing after
    selecting route but before any connection attempt.

    Signed-off-by: Frédéric Dalleau
    Signed-off-by: Johan Hedberg
    Acked-by: Marcel Holtmann
    Signed-off-by: Gustavo Padovan

    Frédéric Dalleau
     
  • In order to establish a transparent SCO connection, the correct settings
    must be specified in the Setup Synchronous Connection request. For that,
    a setting field is added to ACL connection data to set up the desired
    parameters. The patch also removes usage of hdev->voice_setting in CVSD
    connection and makes use of T2 parameters for transparent data.

    Signed-off-by: Frédéric Dalleau
    Signed-off-by: Johan Hedberg
    Acked-by: Marcel Holtmann
    Signed-off-by: Gustavo Padovan

    Frédéric Dalleau
     
  • When an incoming eSCO connection is requested, check the selected voice
    setting and reply appropriately. Voice setting should have been
    negotiated previously. For example, in case of HFP, the codec is
    negotiated using AT commands on the RFCOMM channel. This patch only
    changes replies for socket with deferred setup enabled.

    Signed-off-by: Frédéric Dalleau
    Signed-off-by: Johan Hedberg
    Acked-by: Marcel Holtmann
    Signed-off-by: Gustavo Padovan

    Frédéric Dalleau
     
  • This patch extends the current Bluetooth socket options with BT_VOICE.
    This is intended to choose voice data type at runtime. It only applies
    to SCO sockets. Incoming connections shall be setup during deferred
    setup. Outgoing connections shall be setup before connect(). The desired
    setting is stored in the SCO socket info. This patch declares needed
    members, modifies getsockopt() and setsockopt().

    Signed-off-by: Frédéric Dalleau
    Acked-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg
    Signed-off-by: Gustavo Padovan

    Frédéric Dalleau
     
  • From Bluetooth Core v4.0 specification, 7.1.8 Accept Connection Request
    Command "When accepting synchronous connection request, the Role
    parameter is not used and will be ignored by the BR/EDR Controller."

    Signed-off-by: Frédéric Dalleau
    Acked-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg
    Signed-off-by: Gustavo Padovan

    Frédéric Dalleau
     
  • hci_connect is a super function for connecting hci protocols. But the
    voice_setting parameter (introduced in subsequent patches) is only
    needed by SCO and security requirements are not needed for SCO channels.
    Thus, it makes sense to have a separate function for SCO.

    Signed-off-by: Frédéric Dalleau
    Acked-by: Marcel Holtmann
    Signed-off-by: Johan Hedberg
    Signed-off-by: Gustavo Padovan

    Frédéric Dalleau
     
  • In rfcomm_tty_cleanup we purge the dlc->tx_queue which may contain
    socket buffers referencing the tty_port and thus preventing the tty_port
    destruction.

    Signed-off-by: Gianluca Anzolin
    Reviewed-by: Peter Hurley
    Signed-off-by: Gustavo Padovan

    Gianluca Anzolin
     
  • The tty_port can be released in two cases: when we get a HUP in the
    functions rfcomm_tty_hangup() and rfcomm_dev_state_change(). Or when the
    user releases the device in rfcomm_release_dev().

    In these cases we set the flag RFCOMM_TTY_RELEASED so that no other
    function can get a reference to the tty_port.
    The use of !test_and_set_bit(RFCOMM_TTY_RELEASED) ensures that the
    'initial' tty_port reference is only dropped once.

    The rfcomm_dev_del function is removed becase it isn't used anymore.

    Signed-off-by: Gianluca Anzolin
    Reviewed-by: Peter Hurley
    Signed-off-by: Gustavo Padovan

    Gianluca Anzolin
     
  • Implement .activate, .shutdown and .carrier_raised methods of tty_port
    to manage the dlc, moving the code from rfcomm_tty_install() and
    rfcomm_tty_cleanup() functions.

    At the same time the tty .open()/.close() and .hangup() methods are
    changed to use the tty_port helpers that properly call the
    aforementioned tty_port methods.

    Signed-off-by: Gianluca Anzolin
    Reviewed-by: Peter Hurley
    Signed-off-by: Gustavo Padovan

    Gianluca Anzolin
     
  • Move the tty_struct initialization from rfcomm_tty_open() to
    rfcomm_tty_install() and do the same for the cleanup moving the code from
    rfcomm_tty_close() to rfcomm_tty_cleanup().

    Add also extra error handling in rfcomm_tty_install() because, unlike
    .open()/.close(), .cleanup() is not called if .install() fails.

    Signed-off-by: Gianluca Anzolin
    Reviewed-by: Peter Hurley
    Signed-off-by: Gustavo Padovan

    Gianluca Anzolin
     
  • The current code removes the device from the device list in several
    places. Do it only in the destructor instead and in the error path of
    rfcomm_add_dev() if the device couldn't be initialized.

    Signed-off-by: Gianluca Anzolin
    Reviewed-by: Peter Hurley
    Signed-off-by: Gustavo Padovan

    Gianluca Anzolin
     
  • In net/bluetooth/rfcomm/tty.c the struct tty_struct is used without
    taking references. This may lead to a use-after-free of the rfcomm tty.

    Fix this by taking references properly, using the tty_port_* helpers
    when possible.

    The raw assignments of dev->port.tty in rfcomm_tty_open/close are
    addressed in the later commit 'rfcomm: Implement .activate, .shutdown
    and .carrier_raised methods'.

    Signed-off-by: Gianluca Anzolin
    Reviewed-by: Peter Hurley
    Signed-off-by: Gustavo Padovan

    Gianluca Anzolin
     
  • In case of a Low Energy only controller it makes no sense to configure
    the full BR/EDR event mask. It will just enable events that can not be
    send anyway and there is no guarantee that such a controller will accept
    this value.

    Use event mask 0x90 0xe8 0x04 0x02 0x00 0x80 0x00 0x20 for LE-only
    controllers which enables the following events:

    Disconnection Complete
    Encryption Change
    Read Remote Version Information Complete
    Command Complete
    Command Status
    Hardware Error
    Number of Completed Packets
    Data Buffer Overflow
    Encryption Key Refresh Complete
    LE Meta

    This is according to Core Specification, Part E, Section 3.

    Signed-off-by: Marcel Holtmann
    Signed-off-by: Gustavo Padovan

    Marcel Holtmann
     
  • When a socket is in deferred state there does actually exist an
    underlying connection even though the connection state is not yet
    BT_CONNECTED. In the deferred state it should therefore be allowed to
    get socket options that usually depend on a connection, such as
    SCO_OPTIONS and SCO_CONNINFO.

    This patch fixes the behavior of some user space code that behaves as
    follows without it:

    $ sudo tools/btiotest -i 00:1B:DC:xx:xx:xx -d -s
    accept=2 reject=-1 discon=-1 defer=1 sec=0 update_sec=0 prio=0 voice=0x0000
    Listening for SCO connections
    bt_io_get(OPT_DEST): getsockopt(SCO_OPTIONS): Transport endpoint is not connected (107)
    Accepting connection
    Successfully connected to 60:D8:19:xx:xx:xx. handle=43, class=000000

    The conditions that the patch updates the if-statements to is taken from
    similar code in l2cap_sock.c which correctly handles the deferred state.

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

    Johan Hedberg
     

01 Aug, 2013

1 commit


29 Jul, 2013

2 commits

  • In certain circumstances, such as an HCI driver using __hci_cmd_sync_ev
    with HCI_EV_CMD_COMPLETE as the expected completion event there is the
    chance that hci_event_packet will call hci_req_cmd_complete twice (once
    for the explicitly looked after event and another time in the actual
    handler of cmd_complete).

    In the case of __hci_cmd_sync_ev this introduces a race where the first
    call wakes up the blocking __hci_cmd_sync_ev and lets it complete.
    However, by the time that a second __hci_cmd_sync_ev call is already in
    progress the second hci_req_cmd_complete call (from the previous
    operation) will wake up the blocking function prematurely and cause it
    to fail, as witnessed by the following log:

    [ 639.232195] hci_rx_work: hci0 Event packet
    [ 639.232201] hci_req_cmd_complete: opcode 0xfc8e status 0x00
    [ 639.232205] hci_sent_cmd_data: hci0 opcode 0xfc8e
    [ 639.232210] hci_req_sync_complete: hci0 result 0x00
    [ 639.232220] hci_cmd_complete_evt: hci0 opcode 0xfc8e
    [ 639.232225] hci_req_cmd_complete: opcode 0xfc8e status 0x00
    [ 639.232228] __hci_cmd_sync_ev: hci0 end: err 0
    [ 639.232234] __hci_cmd_sync_ev: hci0
    [ 639.232238] hci_req_add_ev: hci0 opcode 0xfc8e plen 250
    [ 639.232242] hci_prepare_cmd: skb len 253
    [ 639.232246] hci_req_run: length 1
    [ 639.232250] hci_sent_cmd_data: hci0 opcode 0xfc8e
    [ 639.232255] hci_req_sync_complete: hci0 result 0x00
    [ 639.232266] hci_cmd_work: hci0 cmd_cnt 1 cmd queued 1
    [ 639.232271] __hci_cmd_sync_ev: hci0 end: err 0
    [ 639.232276] Bluetooth: hci0 sending Intel patch command (0xfc8e) failed (-61)

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

    Johan Hedberg
     
  • None of the BlueFRITZ! devices with manufacurer ID 31 (AVM Berlin)
    support HCI_Read_Local_Supported_Commands. It is safe to use the
    manufacturer ID (instead of e.g. a USB ID specific quirk) because the
    company never created any newer controllers.

    < HCI Command: Read Local Supported Comm.. (0x04|0x0002) plen 0 [hci0] 0.210014
    > HCI Event: Command Status (0x0f) plen 4 [hci0] 0.217361
    Read Local Supported Commands (0x04|0x0002) ncmd 1
    Status: Unknown HCI Command (0x01)

    Reported-by: Jörg Esser
    Signed-off-by: Johan Hedberg
    Tested-by: Jörg Esser
    Signed-off-by: Gustavo Padovan

    Johan Hedberg
     

26 Jul, 2013

2 commits

  • If hci_dev_open() is called after hci_register_dev() added the device to
    the hci_dev_list but before the workqueue are created we could run into a
    NULL pointer dereference (see below).

    This bug is very unlikely to happen, systems using bluetoothd to
    manage their bluetooth devices will never see this happen.

    BUG: unable to handle kernel NULL pointer dereference
    0100
    IP: [] __queue_work+0x32/0x3d0
    (...)
    Call Trace:
    [] queue_work_on+0x45/0x50
    [] hci_req_run+0xbf/0xf0 [bluetooth]
    [] ? hci_init2_req+0x720/0x720 [bluetooth]
    [] __hci_req_sync+0xd6/0x1c0 [bluetooth]
    [] ? try_to_wake_up+0x2b0/0x2b0
    [] ? usb_autopm_put_interface+0x30/0x40
    [] hci_dev_open+0x275/0x2e0 [bluetooth]
    [] hci_sock_ioctl+0x1f2/0x3f0 [bluetooth]
    [] sock_do_ioctl+0x30/0x70
    [] sock_ioctl+0x79/0x2f0
    [] do_vfs_ioctl+0x96/0x560
    [] SyS_ioctl+0x91/0xb0
    [] system_call_fastpath+0x1a/0x1f

    Reported-by: Sedat Dilek
    Signed-off-by: Gustavo Padovan

    Gustavo Padovan
     
  • The length check is invalid since the length varies with type of
    info response.

    This was introduced by the commit cb3b3152b2f5939d67005cff841a1ca748b19888

    Because of this, l2cap info rsp is not handled and command reject is sent.

    > ACL data: handle 11 flags 0x02 dlen 16
    L2CAP(s): Info rsp: type 2 result 0
    Extended feature mask 0x00b8
    Enhanced Retransmission mode
    Streaming mode
    FCS Option
    Fixed Channels
    < ACL data: handle 11 flags 0x00 dlen 10
    L2CAP(s): Command rej: reason 0
    Command not understood

    Cc: stable@vger.kernel.org
    Signed-off-by: Jaganath Kanakkassery
    Signed-off-by: Chan-Yeol Park
    Acked-by: Johan Hedberg
    Signed-off-by: Gustavo Padovan

    Jaganath Kanakkassery
     

25 Jul, 2013

6 commits


22 Jul, 2013

1 commit

  • 27ce4050 ("HID: fix data access in implement()") by mistake removed
    a setting of buffer size in hidp. Fix that by putting it back.

    Reported-by: kbuild test robot
    Signed-off-by: Jiri Kosina

    Jiri Kosina