lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Fri, 30 Jun 2023 15:25:00 -0700
From:   Doug Anderson <dianders@...omium.org>
To:     Manish Mandlik <mmandlik@...gle.com>
Cc:     Marcel Holtmann <marcel@...tmann.org>,
        Johan Hedberg <johan.hedberg@...il.com>,
        Luiz Augusto von Dentz <luiz.dentz@...il.com>,
        Stephen Boyd <swboyd@...omium.org>,
        Miao-chen Chou <mcchou@...gle.com>,
        linux-bluetooth@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/2] Bluetooth: hci_sync: Avoid use-after-free in dbg
 for hci_remove_adv_monitor()

Hi,

On Fri, Jun 30, 2023 at 3:20 PM Manish Mandlik <mmandlik@...gle.com> wrote:
>
> Hi Douglas,
>
>
>
> On Fri, Jun 30, 2023 at 3:10 PM Douglas Anderson <dianders@...omium.org> wrote:
>>
>> KASAN reports that there's a use-after-free in
>> hci_remove_adv_monitor(). Trawling through the disassembly, you can
>> see that the complaint is from the access in bt_dev_dbg() under the
>> HCI_ADV_MONITOR_EXT_MSFT case. The problem case happens because
>> msft_remove_monitor() can end up freeing the monitor
>> structure. Specifically:
>>   hci_remove_adv_monitor() ->
>>   msft_remove_monitor() ->
>>   msft_remove_monitor_sync() ->
>>   msft_le_cancel_monitor_advertisement_cb() ->
>>   hci_free_adv_monitor()
>>
>> Moving the printout to before the memory is freed.
>>
>> Fixes: 7cf5c2978f23 ("Bluetooth: hci_sync: Refactor remove Adv Monitor")
>> Signed-off-by: Douglas Anderson <dianders@...omium.org>
>> ---
>>
>> Changes in v2:
>> - Move the print, don't stash handle in a local.
>>
>>  net/bluetooth/hci_core.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
>> index 48917c68358d..7e2ecf8a55d8 100644
>> --- a/net/bluetooth/hci_core.c
>> +++ b/net/bluetooth/hci_core.c
>> @@ -1980,9 +1980,9 @@ static int hci_remove_adv_monitor(struct hci_dev *hdev,
>>                 goto free_monitor;
>>
>>         case HCI_ADV_MONITOR_EXT_MSFT:
>> -               status = msft_remove_monitor(hdev, monitor);
>>                 bt_dev_dbg(hdev, "%s remove monitor %d msft status %d",
>>                            hdev->name, monitor->handle, status);
>> +               status = msft_remove_monitor(hdev, monitor);
>
> Thanks for catching this. But that log also prints the value of "status". So, moving "status = msft_remove_monitor(hdev, monitor);" after the print will print an incorrect value of "status".

Ah crud, you're right. :(

OK, I'll send v3 which will be back to v1 for the first patch.

-Doug

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ