From: Lee Jones <lee@kernel.org>
To: Pauli Virtanen <pav@iki.fi>, stable@vger.kernel.org
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: SCO: hold sk properly in sco_conn_ready
Date: Mon, 13 Jul 2026 11:55:55 +0100 [thread overview]
Message-ID: <20260713105555.GA3649328@google.com> (raw)
In-Reply-To: <023e04a49d2002882eb5ea6bf27d1169261db875.1776525817.git.pav@iki.fi>
Stable Team,
On Sat, 18 Apr 2026, Pauli Virtanen wrote:
> sk deref in sco_conn_ready must be done either under conn->lock, or
> holding a refcount, to avoid concurrent close. conn->sk and parent sk is
> currently accessed without either, and without checking parent->sk_state:
>
> [Task 1] [Task 2]
> sco_sock_release
> sco_conn_ready
> sk = conn->sk
> lock_sock(sk)
> conn->sk = NULL
> lock_sock(sk)
> release_sock(sk)
> sco_sock_kill(sk)
> UAF on sk deref
>
> and similarly for access to sco_get_sock_listen() return value.
>
> Fix possible UAF by holding sk refcount in sco_conn_ready() and making
> sco_get_sock_listen() increase refcount. Also recheck after lock_sock
> that the socket is still valid. Adjust conn->sk locking so it's
> protected also by lock_sock() of the associated socket if any.
>
> Fixes: 27c24fda62b60 ("Bluetooth: switch to lock_sock in SCO")
> Signed-off-by: Pauli Virtanen <pav@iki.fi>
> ---
>
> Notes:
> There's still several known race conditions in sco.c, if you look at the
> sco_conn_put/free and hcon->sco_data access. A redesign could make these
> locking issues simpler:
>
> https://lore.kernel.org/all/5ac8c40b96052cb320c4ee1083d37818ac5d90cc.1776025103.git.pav@iki.fi/
>
> net/bluetooth/sco.c | 44 ++++++++++++++++++++++++++++++++------------
> 1 file changed, 32 insertions(+), 12 deletions(-)
Could we have this and its dependency in all Stable branches bar
linux-5.10.y please?
Dep:
b819db93d73f ("Bluetooth: SCO: fix sleeping under spinlock in sco_conn_ready")
Fix:
4e37f6452d58 ("Bluetooth: SCO: hold sk properly in sco_conn_ready")
Both patches apply cleanly and survive basic build testing on ARM,
ARM66, X86, PPC and MIPS.
--
Lee Jones
prev parent reply other threads:[~2026-07-13 10:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-18 15:41 [PATCH] Bluetooth: SCO: hold sk properly in sco_conn_ready Pauli Virtanen
2026-04-18 16:32 ` bluez.test.bot
2026-04-20 21:59 ` [PATCH] " patchwork-bot+bluetooth
2026-07-13 10:55 ` Lee Jones [this message]
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=20260713105555.GA3649328@google.com \
--to=lee@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=pav@iki.fi \
--cc=stable@vger.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 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.