Linux bluetooth development
 help / color / mirror / Atom feed
From: Pauli Virtanen <pav@iki.fi>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v1 1/2] Bluetooth: SCO: require CAP_NET_BIND_SERVICE to bind
Date: Fri, 28 Aug 2026 19:02:46 +0300	[thread overview]
Message-ID: <78402f4521084b3f6d2cce7709cbba751d83836f.camel@iki.fi> (raw)
In-Reply-To: <CABBYNZ+qzL04d0cdKd==wFr_Gtz9gCa3_iNv0B9rE=R8pdpajg@mail.gmail.com>

Hi,

pe, 2026-08-28 kello 09:50 -0400, Luiz Augusto von Dentz kirjoitti:
> On Thu, Aug 27, 2026 at 7:41 PM Pauli Virtanen <pav@iki.fi> wrote:
> > to, 2026-08-27 kello 14:01 -0400, Luiz Augusto von Dentz kirjoitti:
> > > From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> > > 
> > > SCO sockets have no PSM or port namespace: binding one simply reserves
> > > the ability to accept any incoming eSCO/SCO connection on the adapter.
> > > That is equivalent to listening on a well-known service, which L2CAP
> > > already restricts to CAP_NET_BIND_SERVICE in
> > > l2cap_validate_bredr_psm()/l2cap_validate_le_psm().
> > 
> > In current Linux userspace, sound servers that do HFP listen on SCO
> > sockets, and I think often don't have CAP_NET_BIND_SERVICE.
> > 
> > Do they continue working with this change?
> 
> Good question, that said this is a part of security hardening
> otherwise any process could start listening to an SCO connection, and
> the sound server would stop working. Btw, does the sound server have
> any special capability to, let's say, open the sound card device so
> perhaps we can gate it on sound capability as well.

For ALSA, the sound hardware access is controlled by device file
permissions in /dev/snd/*  Not sure if that's usable here, or if
there's some other per-user controlled solution that could be used.

In most current distros sound server runs with user permissions without
special capabilities, and don't have CAP_NET_BIND_SERVICE, so I'd
expect this patch breaks userspace.

Giving this capability to them allows binding to low network ports, so
it probably makes the hardening issue worse and not better.

The next simplest is probably separate executable with setcap bit set,
which gives a SCO listen socket for those who can run it based on file
permissions.

For ISO bluetoothd manages this (so can be gated with DBus/selinux
policies), and it could make sense for it to be made to work like that
for SCO too.

> > > Apply the same restriction to sco_sock_bind() so unprivileged processes
> > > can no longer hijack incoming SCO links.
> > > 
> > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> > > Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> > > ---
> > >  net/bluetooth/sco.c | 7 +++++++
> > >  1 file changed, 7 insertions(+)
> > > 
> > > diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
> > > index 3d4362a09df4..e4c26551e513 100644
> > > --- a/net/bluetooth/sco.c
> > > +++ b/net/bluetooth/sco.c
> > > @@ -667,6 +667,13 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr_unsized *addr,
> > > 
> > >       BT_DBG("sk %p %pMR", sk, &sa->sco_bdaddr);
> > > 
> > > +     /* Binding a SCO socket reserves the ability to accept any incoming
> > > +      * eSCO/SCO connection on the adapter, so restrict it in the same way
> > > +      * L2CAP restricts well-known PSMs.
> > > +      */
> > > +     if (!capable(CAP_NET_BIND_SERVICE))
> > > +             return -EACCES;
> > > +
> > >       lock_sock(sk);
> > > 
> > >       if (sk->sk_state != BT_OPEN) {
> > 
> > --
> > Pauli Virtanen
> 
> 

  reply	other threads:[~2026-08-28 16:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27 18:01 [PATCH v1 1/2] Bluetooth: SCO: require CAP_NET_BIND_SERVICE to bind Luiz Augusto von Dentz
2026-08-27 18:01 ` [PATCH v1 2/2] Bluetooth: ISO: " Luiz Augusto von Dentz
2026-08-27 23:41 ` [PATCH v1 1/2] Bluetooth: SCO: " Pauli Virtanen
2026-08-28 13:50   ` Luiz Augusto von Dentz
2026-08-28 16:02     ` Pauli Virtanen [this message]
2026-08-28 16:46       ` Luiz Augusto von Dentz
2026-08-29  8:39         ` Pauli Virtanen
2026-08-28  1:10 ` [v1,1/2] " bluez.test.bot

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=78402f4521084b3f6d2cce7709cbba751d83836f.camel@iki.fi \
    --to=pav@iki.fi \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    /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