All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: "linux-bluetooth@vger.kernel.org" <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH] Bluetooth: hci_sync: Set Privacy Mode when updating the resolving list
Date: Tue, 2 Nov 2021 14:02:34 -0700	[thread overview]
Message-ID: <CABBYNZLbU=qUa91Nj45B2nD=GHbAu6j=mCWP+ZkA23a733rfww@mail.gmail.com> (raw)
In-Reply-To: <6313C3AD-AEA9-4E4E-98C4-3F1C62DE04CA@holtmann.org>

Hi Marcel,

On Tue, Nov 2, 2021 at 12:18 AM Marcel Holtmann <marcel@holtmann.org> wrote:
>
> Hi Luiz,
>
> > This adds support for Set Privacy Mode when updating the resolving list
> > when HCI_LIMITED_PRIVACY so the controller shall use Device Mode for
> > devices programmed in the resolving list, Device Mode is actually
> > required when the remote device are not able to use RPA as otherwise the
> > default mode is Network Privacy Mode in which only RPA are allowed thus
> > the controller would filter out advertisement using the identity address
> > for which there is an IRK.
> >
> > Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> > ---
> > include/net/bluetooth/hci.h |  7 ++++++
> > net/bluetooth/hci_sync.c    | 48 ++++++++++++++++++++++++++++++++-----
> > 2 files changed, 49 insertions(+), 6 deletions(-)
> >
> > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> > index 63065bc01b76..aa856dfd5b9f 100644
> > --- a/include/net/bluetooth/hci.h
> > +++ b/include/net/bluetooth/hci.h
> > @@ -1930,6 +1930,13 @@ struct hci_rp_le_read_transmit_power {
> >       __s8  max_le_tx_power;
> > } __packed;
> >
> > +#define HCI_OP_LE_SET_PRIVACY_MODE   0x204e
> > +struct hci_cp_le_set_privacy_mode {
> > +     __u8  bdaddr_type;
> > +     bdaddr_t  bdaddr;
> > +     __u8  mode;
> > +} __packed;
> > +
> > #define HCI_OP_LE_READ_BUFFER_SIZE_V2 0x2060
> > struct hci_rp_le_read_buffer_size_v2 {
> >       __u8    status;
> > diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
> > index b794605dc882..43173d645436 100644
> > --- a/net/bluetooth/hci_sync.c
> > +++ b/net/bluetooth/hci_sync.c
> > @@ -1580,8 +1580,37 @@ static int hci_le_add_resolve_list_sync(struct hci_dev *hdev,
> >                                    sizeof(cp), &cp, HCI_CMD_TIMEOUT);
> > }
> >
> > +/* Set Device Privacy Mode. */
> > +static int hci_le_set_privacy_mode_sync(struct hci_dev *hdev,
> > +                                     struct hci_conn_params *params)
> > +{
> > +     struct hci_cp_le_set_privacy_mode cp;
> > +     struct smp_irk *irk;
> > +
> > +     /* Set Privacy Mode requires the use of resolving list (aka. LL Privacy)
> > +      * by default Network Mode is used so only really send the command if
> > +      * Device Mode is required (HCI_LIMITED_PRIVACY).
> > +      */
> > +     if (!use_ll_privacy(hdev) ||
> > +         !hci_dev_test_flag(hdev, HCI_LIMITED_PRIVACY))
> > +             return 0;
> > +
> > +     irk = hci_find_irk_by_addr(hdev, &params->addr, params->addr_type);
> > +     if (!irk)
> > +             return 0;
> > +
> > +     memset(&cp, 0, sizeof(cp));
> > +     cp.bdaddr_type = irk->addr_type;
> > +     bacpy(&cp.bdaddr, &irk->bdaddr);
> > +     cp.mode = 0x01;
> > +
>
> you need to check if this command is actually supported.

The spec suggests it is mandatory if LL Privacy is supported:

'C9: Mandatory if LE Feature (LL Privacy) is supported, otherwise excluded.'

> I think the best option is to add it to Set Device Flags and let bluetoothd set it on a per device basis like it does with the wakeup flag.

Got it, I guess

> Trying to tie it to the Limited Privacy mode seems weird. Since that is for discoverability and this is for outgoing connections.

Hmm, I'm afraid this wouldn't follow the spec to the letter then since
it doesn't actually split Incoming/advertising and Outgoing/scanning
privacy, it does seems to be global so if we go with different
settings to control each direction separately we may end up with a
custom mode e.g: limited discoverability for advertising vs network
privacy mode for scanning, for instance limited discoverability does
blast the public address while discoverable and bondable but both
privacy modes seems to require the use of RPA, anyway it would
probably be a good idea to document the interactions, also main.conf
seem to have gone with privacy from the specification so we may either
need add more modes:

Privacy:
"on"/"network": Apply Network Privacy Mode both for advertising and scanning
"limited-network": Apply Limited Discoverable Mode to advertising and
Network Privacy Mode for scanning
"device": Apply Device Privacy Mode both for advertising and scanning
"limited-device": Apply Limited Discoverable Mode to advertising and
Device Privacy Mode for scanning

-- 
Luiz Augusto von Dentz

  reply	other threads:[~2021-11-02 21:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-02  5:51 [PATCH] Bluetooth: hci_sync: Set Privacy Mode when updating the resolving list Luiz Augusto von Dentz
2021-11-02  7:18 ` Marcel Holtmann
2021-11-02 21:02   ` Luiz Augusto von Dentz [this message]
2021-11-03  8:28     ` Marcel Holtmann
2021-11-03 20:32       ` Luiz Augusto von Dentz

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='CABBYNZLbU=qUa91Nj45B2nD=GHbAu6j=mCWP+ZkA23a733rfww@mail.gmail.com' \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=marcel@holtmann.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.