[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABXGCsPF6MbSOpfUBbT77Hnfc450kutsc8Fzr1O_O9bgtQ5PAw@mail.gmail.com>
Date: Fri, 12 Jan 2024 12:31:07 +0500
From: Mikhail Gavrilov <mikhail.v.gavrilov@...il.com>
To: Deren Wu (武德仁) <Deren.Wu@...iatek.com>
Cc: "linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>, "nbd@....name" <nbd@....name>,
"angelogioacchino.delregno@...labora.com" <angelogioacchino.delregno@...labora.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [BUG] Unloading mt7921e module cause use-after-free
On Fri, Jan 12, 2024 at 10:34 AM Deren Wu (武德仁) <Deren.Wu@...iatek.com> wrote:
>
> Hi Mikhail,
>
> I can reproduce a similar problem when CONFI_DEBUG_SHIRQ is enabled.
>
> Pleaese try this patch in mainline kernel (6.7+)
> ---
> --- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
> @@ -387,6 +387,7 @@ static void mt7921_pci_remove(struct pci_dev *pdev)
> struct mt792x_dev *dev = container_of(mdev, struct mt792x_dev,
> mt76);
>
> mt7921e_unregister_device(dev);
> + set_bit(MT76_REMOVED, &mdev->phy.state);
> devm_free_irq(&pdev->dev, pdev->irq, dev);
> mt76_free_device(&dev->mt76);
> pci_free_irq_vectors(pdev);
> diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_dma.c
> b/drivers/net/wireless/mediatek/mt76/mt792x_dma.c
> index 488326ce5ed4..3893dbe866fe 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt792x_dma.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt792x_dma.c
> @@ -12,6 +12,8 @@ irqreturn_t mt792x_irq_handler(int irq, void
> *dev_instance)
> {
> struct mt792x_dev *dev = dev_instance;
>
> + if (test_bit(MT76_REMOVED, &dev->mt76.phy.state))
> + return IRQ_NONE;
> mt76_wr(dev, dev->irq_map->host_irq_enable, 0);
>
> if (!test_bit(MT76_STATE_INITIALIZED, &dev->mphy.state))
>
>
Thanks, this patch looks good to me.
Demonstration: https://youtu.be/nKnA2ftVoXw
Tested-by: Mikhail Gavrilov <mikhail.v.gavrilov@...il.com>
--
Best Regards,
Mike Gavrilov.
Powered by blists - more mailing lists