From: Hillf Danton <hdanton@sina.com>
To: kawada <youjingxiaogao2@gmail.com>
Cc: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com,
marcel@holtmann.org, johan.hedberg@gmail.com,
linux-kernel@vger.kernel.org,
syzbot+3609b9b48e68e1fe47fd@syzkaller.appspotmail.com
Subject: Re: [PATCH] Bluetooth: fix use-after-free in hci_conn_drop
Date: Tue, 10 Feb 2026 18:08:59 +0800 [thread overview]
Message-ID: <20260210100901.2769-1-hdanton@sina.com> (raw)
In-Reply-To: <CAKZCeSVJQAsYVSDBHOmUyBMbQqBA1D7ZP4KK-azWUjb+p-vpJg@mail.gmail.com>
[ hm... top reply looks no good ]
On Tue, 10 Feb 2026 15:08:12 +0900 Masahiro Kawada wrote:
> > but the race still exists after this patch.
>
> I agree that the TOCTOU issue remains. I looked into all the functions
> that can be called as entry->destroy in hci_cmd_sync_work where the
> second argument (data) is used as hci_conn*. I found five such
> functions across two files:
>
> In hci_sync.c:
> - create_le_conn_complete
> - create_pa_complete
> - create_big_complete
> - le_read_features_complete
>
> In hci_conn.c:
> - create_big_complete (separate static function)
>
> Of these, create_le_conn_complete and create_pa_complete already use
> hci_dev_lock, which effectively prevents this TOCTOU issue.
>
> The remaining three are vulnerable:
> - create_big_complete in hci_sync.c calls hci_conn_valid without
> holding hci_dev_lock (TOCTOU)
> - le_read_features_complete calls hci_conn_drop with no validity
> check at all
> - create_big_complete in hci_conn.c calls hci_connect_cfm and
> hci_conn_del with no validity check at all
>
> Given this, I believe the following set of patches would be
> appropriate:
>
> 1. Reorder hci_cmd_sync_dequeue before hci_conn_cleanup in
> hci_conn_del
> 2. Wrap all three vulnerable callbacks with hci_dev_lock and
> hci_conn_valid, following the same pattern used by
> create_le_conn_complete and create_pa_complete
>
> If this approach sounds reasonable, I will prepare updated patches.
>
Better not before spotting the reason why conn->refcnt failed to make the
entry->destroy callback safe, given the complexity of the race.
next prev parent reply other threads:[~2026-02-10 10:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-09 10:02 [PATCH] Bluetooth: fix use-after-free in hci_conn_drop Masahiro Kawada
2026-02-09 11:16 ` bluez.test.bot
2026-02-09 13:25 ` [PATCH] " Hillf Danton
2026-02-10 6:08 ` kawada
2026-02-10 10:08 ` Hillf Danton [this message]
2026-02-10 14:50 ` kawada
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=20260210100901.2769-1-hdanton@sina.com \
--to=hdanton@sina.com \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=syzbot+3609b9b48e68e1fe47fd@syzkaller.appspotmail.com \
--cc=youjingxiaogao2@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