[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZBCNY8NoNkrA2nyN@corigine.com>
Date: Tue, 14 Mar 2023 16:06:11 +0100
From: Simon Horman <simon.horman@...igine.com>
To: Zheng Hacker <hackerzheng666@...il.com>
Cc: Zheng Wang <zyytlz.wz@....com>, marcel@...tmann.org,
alex000young@...il.com, johan.hedberg@...il.com,
luiz.dentz@...il.com, davem@...emloft.net, edumazet@...gle.com,
kuba@...nel.org, pabeni@...hat.com,
linux-bluetooth@...r.kernel.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, pmenzel@...gen.mpg.de
Subject: Re: [PATCH v2] Bluetooth: hci_core: Fix poential Use-after-Free bug
in hci_remove_adv_monitor
On Mon, Mar 13, 2023 at 05:55:35PM +0800, Zheng Hacker wrote:
> friendly ping
>
> Zheng Wang <zyytlz.wz@....com> 于2023年2月17日周五 18:05写道:
> >
> > 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 removing the logging into msft_le_cancel_monitor_advertisement_cb
> > before calling hci_free_adv_monitor.
> >
> > Signed-off-by: Zheng Wang <zyytlz.wz@....com>
> > ---
> > v2:
> > - move the logging inside msft_remove_monitor suggested by Luiz
> > ---
> > net/bluetooth/hci_core.c | 2 --
> > net/bluetooth/msft.c | 2 ++
> > 2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> > index b65c3aabcd53..69b82c2907ff 100644
> > --- a/net/bluetooth/hci_core.c
> > +++ b/net/bluetooth/hci_core.c
> > @@ -1981,8 +1981,6 @@ static int hci_remove_adv_monitor(struct hci_dev *hdev,
> >
> > 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);
> > break;
I'm probably missing something obvious.
But from my perspective a simpler fix would be to
move the msft_remove_monitor() call to below the bt_dev_dbg() call.
> > }
> >
> > diff --git a/net/bluetooth/msft.c b/net/bluetooth/msft.c
> > index bee6a4c656be..4b35f0ed1360 100644
> > --- a/net/bluetooth/msft.c
> > +++ b/net/bluetooth/msft.c
> > @@ -286,6 +286,8 @@ static int msft_le_cancel_monitor_advertisement_cb(struct hci_dev *hdev,
> > * suspend. It will be re-monitored on resume.
> > */
> > if (!msft->suspending) {
> > + bt_dev_dbg(hdev, "%s remove monitor %d status %d", hdev->name,
> > + monitor->handle, status);
> > hci_free_adv_monitor(hdev, monitor);
> >
> > /* Clear any monitored devices by this Adv Monitor */
> > --
> > 2.25.1
> >
>
Powered by blists - more mailing lists