* [PATCH] Bluetooth: hci_core: Fix poential Use-after-Free bug in hci_remove_adv_monitor
@ 2023-02-10 4:10 Zheng Wang
2023-02-10 19:53 ` Luiz Augusto von Dentz
2023-02-13 8:19 ` Paul Menzel
0 siblings, 2 replies; 5+ messages in thread
From: Zheng Wang @ 2023-02-10 4:10 UTC (permalink / raw)
To: marcel
Cc: hackerzheng666, alex000young, johan.hedberg, luiz.dentz, davem,
edumazet, kuba, pabeni, linux-bluetooth, netdev, linux-kernel,
Zheng Wang
In hci_remove_adv_monitor, if it gets into HCI_ADV_MONITOR_EXT_MSFT case,
the function will free the monitor and print its handle after that.
Fix it by switch the order.
Fixes: 7cf5c2978f23 ("Bluetooth: hci_sync: Refactor remove Adv Monitor")
Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
---
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 b65c3aabcd53..db3352c60de6 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);
break;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] Bluetooth: hci_core: Fix poential Use-after-Free bug in hci_remove_adv_monitor
2023-02-10 4:10 [PATCH] Bluetooth: hci_core: Fix poential Use-after-Free bug in hci_remove_adv_monitor Zheng Wang
@ 2023-02-10 19:53 ` Luiz Augusto von Dentz
2023-02-13 3:02 ` Zheng Hacker
2023-02-13 8:19 ` Paul Menzel
1 sibling, 1 reply; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2023-02-10 19:53 UTC (permalink / raw)
To: Zheng Wang
Cc: marcel, hackerzheng666, alex000young, johan.hedberg, davem,
edumazet, kuba, pabeni, linux-bluetooth, netdev, linux-kernel
Hi Zheng,
On Thu, Feb 9, 2023 at 8:11 PM Zheng Wang <zyytlz.wz@163.com> wrote:
>
> In hci_remove_adv_monitor, if it gets into HCI_ADV_MONITOR_EXT_MSFT case,
> the function will free the monitor and print its handle after that.
>
> Fix it by switch the order.
>
> Fixes: 7cf5c2978f23 ("Bluetooth: hci_sync: Refactor remove Adv Monitor")
> Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
> ---
> 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 b65c3aabcd53..db3352c60de6 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);
I wonder if it is not a good idea to move the logging inside
msft_remove_monitor?
> break;
> }
>
> --
> 2.25.1
>
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Bluetooth: hci_core: Fix poential Use-after-Free bug in hci_remove_adv_monitor
2023-02-10 19:53 ` Luiz Augusto von Dentz
@ 2023-02-13 3:02 ` Zheng Hacker
0 siblings, 0 replies; 5+ messages in thread
From: Zheng Hacker @ 2023-02-13 3:02 UTC (permalink / raw)
To: Luiz Augusto von Dentz
Cc: Zheng Wang, marcel, alex000young, johan.hedberg, davem, edumazet,
kuba, pabeni, linux-bluetooth, netdev, linux-kernel
Luiz Augusto von Dentz <luiz.dentz@gmail.com> 于2023年2月11日周六 03:53写道:
>
> Hi Zheng,
>
> On Thu, Feb 9, 2023 at 8:11 PM Zheng Wang <zyytlz.wz@163.com> wrote:
> >
> > In hci_remove_adv_monitor, if it gets into HCI_ADV_MONITOR_EXT_MSFT case,
> > the function will free the monitor and print its handle after that.
> >
> > Fix it by switch the order.
> >
> > Fixes: 7cf5c2978f23 ("Bluetooth: hci_sync: Refactor remove Adv Monitor")
> > Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
> > ---
> > 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 b65c3aabcd53..db3352c60de6 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);
>
> I wonder if it is not a good idea to move the logging inside
> msft_remove_monitor?
>
> > break;
> > }
> >
Hello Luiz,
Thanks for your quick reply. I think moving it inside msft_remove_monitor
is a good idea. Because the variable status is returned by msft_remove_monitor.
The call chain is
msft_remove_monitor
->msft_remove_monitor_sync
->msft_le_cancel_monitor_advertisement_cb
->hci_free_adv_monitor
->kfree(monitor);
We could mov the bt_dev_dbg to the location before
hci_free_adv_monitor calling and delete the releated code in
hci_remove_adv_monitor.
If you agree with that, I'll make another patch.
Best regards,
Zheng Wang
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Bluetooth: hci_core: Fix poential Use-after-Free bug in hci_remove_adv_monitor
2023-02-10 4:10 [PATCH] Bluetooth: hci_core: Fix poential Use-after-Free bug in hci_remove_adv_monitor Zheng Wang
2023-02-10 19:53 ` Luiz Augusto von Dentz
@ 2023-02-13 8:19 ` Paul Menzel
2023-02-13 8:21 ` Zheng Hacker
1 sibling, 1 reply; 5+ messages in thread
From: Paul Menzel @ 2023-02-13 8:19 UTC (permalink / raw)
To: Zheng Wang
Cc: marcel, hackerzheng666, alex000young, johan.hedberg, luiz.dentz,
davem, edumazet, kuba, pabeni, linux-bluetooth, netdev,
linux-kernel
Dear Zheng,
Thank you for your patch.
Am 10.02.23 um 05:10 schrieb Zheng Wang:
> In hci_remove_adv_monitor, if it gets into HCI_ADV_MONITOR_EXT_MSFT case,
> the function will free the monitor and print its handle after that.
>
> Fix it by switch the order.
… by switch*ing* …
There is a small typo in the commit message summary/title: po*t*ential
> Fixes: 7cf5c2978f23 ("Bluetooth: hci_sync: Refactor remove Adv Monitor")
> Signed-off-by: Zheng Wang <zyytlz.wz@163.com>
> ---
> net/bluetooth/hci_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
[…]
Kind regards,
Paul
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Bluetooth: hci_core: Fix poential Use-after-Free bug in hci_remove_adv_monitor
2023-02-13 8:19 ` Paul Menzel
@ 2023-02-13 8:21 ` Zheng Hacker
0 siblings, 0 replies; 5+ messages in thread
From: Zheng Hacker @ 2023-02-13 8:21 UTC (permalink / raw)
To: Paul Menzel
Cc: Zheng Wang, marcel, alex000young, johan.hedberg, luiz.dentz,
davem, edumazet, kuba, pabeni, linux-bluetooth, netdev,
linux-kernel
Paul Menzel <pmenzel@molgen.mpg.de> 于2023年2月13日周一 16:19写道:
>
> Dear Zheng,
>
>
> Thank you for your patch.
>
> Am 10.02.23 um 05:10 schrieb Zheng Wang:
> > In hci_remove_adv_monitor, if it gets into HCI_ADV_MONITOR_EXT_MSFT case,
> > the function will free the monitor and print its handle after that.
> >
> > Fix it by switch the order.
>
> … by switch*ing* …
>
> There is a small typo in the commit message summary/title: po*t*ential
>
Hi Paul,
Thanks for pointing that out ^^. Will correct it in the next version of patch.
Best regards,
Zheng Wang
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-02-13 8:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-10 4:10 [PATCH] Bluetooth: hci_core: Fix poential Use-after-Free bug in hci_remove_adv_monitor Zheng Wang
2023-02-10 19:53 ` Luiz Augusto von Dentz
2023-02-13 3:02 ` Zheng Hacker
2023-02-13 8:19 ` Paul Menzel
2023-02-13 8:21 ` Zheng Hacker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).