All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ziyang Xuan (William)" <william.xuanziyang@huawei.com>
To: Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	Pauli Virtanen <pav@iki.fi>
Cc: linux-bluetooth <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH v2] Bluetooth: Fix UAF for hci_chan
Date: Wed, 11 Oct 2023 17:31:07 +0800	[thread overview]
Message-ID: <8ccca432-912e-1f89-802f-addde3652e31@huawei.com> (raw)
In-Reply-To: <CABBYNZKiXwGWR296TU7_4wVMsemzY=mV2CUo-DDMYvSAWX5RwQ@mail.gmail.com>

> Hi Pauli,
> 
> On Tue, Oct 10, 2023 at 11:32 AM Pauli Virtanen <pav@iki.fi> wrote:
>>
>> Hi,
>>
>> ti, 2023-10-10 kello 20:49 +0800, Ziyang Xuan (William)
>> kirjoitti:[clip]
>>>>>
>>>>> - if (atomic_dec_and_test(&conn->refcnt)) {
>>>>> + if (atomic_dec_and_test(&conn->refcnt) &&
>>>>> +     !test_bit(HCI_CONN_DISC, &conn->flags)) {
>>>>>           unsigned long timeo;
>>>>
>>>> hci_abort_conn already checks if conn->abort_reason was already set, to
>>>> avoid queuing abort for the same conn again. Does this flag not try to
>>>> do the same thing?
>>>
>>> That is not enough. hci_conn occur UAF in hci_proto_disconn_ind() before enter
>>> hci_abort_conn().
>>
>> Thanks, this was not clear to me from the patch.
>>
>> So the problem is that the cancel_delayed_work_sync(&conn->disc_work)
>> in hci_conn_del doesn't help in a few cases:
>>
>> 1. [task A] hci_conn_del(conn) entered
>> 2. [A] cancel_delayed_work_sync(conn->disc_work)
>> 3. [B] concurrent hci_conn_drop(conn) queues disc_work again
>> 4. [A] hci_conn_del finishes
>> 5. UAF when disc_work runs
>>
>> or without needing concurrency
>>
>> 1. hci_conn_del(conn) entered and finishes
>> 2. hci_conn_drop(conn); hci_conn_put(conn); as done in several places
>>
>> ?
> 
> Either way Im not sure what the IDA logic has to with it, that said I
> think using ida function is actually a much better solution then the
> lookup one so I would be happy to apply it if someone split the
> changes related to it and send a patch.

I will send a patch just with handle ida modification. The remaining UAF issues
continue to be tracked.

> 
>> The hci_conn_del here is not necessarily from hci_abort_conn. Should
>> the atomic flag be set in hci_conn_del before
>> cancel_delayed_work_sync(&conn->disc_work) to catch possible other
>> cases?
>>

  reply	other threads:[~2023-10-11  9:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09 12:30 [PATCH v2] Bluetooth: Fix UAF for hci_chan Ziyang Xuan
2023-10-09 13:19 ` [v2] " bluez.test.bot
2023-10-09 17:31 ` [PATCH v2] " Luiz Augusto von Dentz
2023-10-10 12:31   ` Ziyang Xuan (William)
2023-10-09 20:37 ` Pauli Virtanen
2023-10-10 12:49   ` Ziyang Xuan (William)
2023-10-10 18:32     ` Pauli Virtanen
2023-10-10 18:51       ` Luiz Augusto von Dentz
2023-10-11  9:31         ` Ziyang Xuan (William) [this message]
2023-10-11 19:33         ` Pauli Virtanen

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=8ccca432-912e-1f89-802f-addde3652e31@huawei.com \
    --to=william.xuanziyang@huawei.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=pav@iki.fi \
    /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.