linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Kemnade <andreas@kemnade.info>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: csonsino <csonsino@gmail.com>,
	Johan Hedberg <johan.hedberg@gmail.com>,
	linux-bluetooth@vger.kernel.org, Sasha Levin <sashal@kernel.org>
Subject: Re: [PATCH 1/1] bluetooth: validate BLE connection interval updates
Date: Thu, 15 Aug 2019 10:44:19 +0200	[thread overview]
Message-ID: <20190815104419.161177fa@kemnade.info> (raw)
In-Reply-To: <138296C5-49FA-475D-9618-FC8D241B8823@holtmann.org>

[-- Attachment #1: Type: text/plain, Size: 3624 bytes --]

On Sat, 6 Jul 2019 15:34:34 +0200
Marcel Holtmann <marcel@holtmann.org> wrote:

> Hi Carey,
> 
> > Problem: The Linux bluetooth stack yields complete control over the BLE
> > connection interval to the remote device.
> > 
> > The Linux bluetooth stack provides access to the BLE connection interval
> > min and max values through /sys/kernel/debug/bluetooth/hci0/
> > conn_min_interval and /sys/kernel/debug/bluetooth/hci0/conn_max_interval.
> > These values are used for initial BLE connections, but the remote device
> > has the ability to request a connection parameter update. In the event
> > that the remote side requests to change the connection interval, the Linux
> > kernel currently only validates that the desired value is within the
> > acceptable range in the bluetooth specification (6 - 3200, corresponding to
> > 7.5ms - 4000ms). There is currently no validation that the desired value
> > requested by the remote device is within the min/max limits specified in
> > the conn_min_interval/conn_max_interval configurations. This essentially
> > leads to Linux yielding complete control over the connection interval to
> > the remote device.
> > 
> > The proposed patch adds a verification step to the connection parameter
> > update mechanism, ensuring that the desired value is within the min/max
> > bounds of the current connection. If the desired value is outside of the
> > current connection min/max values, then the connection parameter update
> > request is rejected and the negative response is returned to the remote
> > device. Recall that the initial connection is established using the local
> > conn_min_interval/conn_max_interval values, so this allows the Linux
> > administrator to retain control over the BLE connection interval.
> > 
> > The one downside that I see is that the current default Linux values for
> > conn_min_interval and conn_max_interval typically correspond to 30ms and
> > 50ms respectively. If this change were accepted, then it is feasible that
> > some devices would no longer be able to negotiate to their desired
> > connection interval values. This might be remedied by setting the default
> > Linux conn_min_interval and conn_max_interval values to the widest
> > supported range (6 - 3200 / 7.5ms - 4000ms). This could lead to the same
> > behavior as the current implementation, where the remote device could
> > request to change the connection interval value to any value that is
> > permitted by the bluetooth specification, and Linux would accept the
> > desired value.
> > 
> > Signed-off-by: Carey Sonsino <csonsino@gmail.com>  
> 
> patch has been applied to bluetooth-next tree.
> 
There are devices which require low connection intervals for usable operation,
e.g. BLE smartcard readers. having 30ms instead of 7.5ms means speed four times
lower.

Other devices might want to set the connection interval  to high values to save
power.

So if the device is not allowed to set the connection interval to such values,
how should the driver sitting on top of the gatt dbus interface of bluetoothd
set such things?

The debugfs nodes are not necessarily available in distro kernels. Anything
sitting on top of gatt dbus interface does not have access to the connection handle
and cannot call hci_le_conn_update() to set things to nice values.

Using l2cap sockets instead of the dbus gatt interface is also not a viable altenative
because it interferes with bluetoothd.

So IMHO this patch causes regressions and should be reverted.

Sorry for stepping out this late.

Regards,
Andreas

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-08-19  5:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-12 21:00 [PATCH 1/1] bluetooth: validate BLE connection interval updates csonsino
2019-07-06 13:34 ` Marcel Holtmann
2019-08-15  8:44   ` Andreas Kemnade [this message]
2019-08-19 13:58     ` Carey Sonsino
2019-08-19 16:08       ` Andreas Kemnade
2019-08-19 17:10         ` Carey Sonsino
2019-08-20  6:45           ` Jamie Mccrae
2019-08-20 13:23             ` Carey Sonsino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190815104419.161177fa@kemnade.info \
    --to=andreas@kemnade.info \
    --cc=csonsino@gmail.com \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=sashal@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).