* [PATCH] ath9k: hif_usb: fix memory leak in ath9k_hif_usb_firmware_cb
@ 2021-07-09 8:43 Dongliang Mu
2021-07-23 10:12 ` Dongliang Mu
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Dongliang Mu @ 2021-07-09 8:43 UTC (permalink / raw)
To: ath9k-devel, Kalle Valo, David S. Miller, Jakub Kicinski, Brooke Basile
Cc: Dongliang Mu, syzbot+6692c72009680f7c4eb2, linux-wireless,
netdev, linux-kernel
The commit 03fb92a432ea ("ath9k: hif_usb: fix race condition between
usb_get_urb() and usb_kill_anchored_urbs()") adds three usb_get_urb
in ath9k_hif_usb_dealloc_tx_urbs and usb_free_urb.
Fix this bug by adding corresponding usb_free_urb in
ath9k_hif_usb_dealloc_tx_urbs other and hif_usb_stop.
Reported-by: syzbot+6692c72009680f7c4eb2@syzkaller.appspotmail.com
Fixes: 03fb92a432ea ("ath9k: hif_usb: fix race condition between usb_get_urb() and usb_kill_anchored_urbs()")
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
---
drivers/net/wireless/ath/ath9k/hif_usb.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 860da13bfb6a..bda91ff3289b 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -457,6 +457,7 @@ static void hif_usb_stop(void *hif_handle)
usb_kill_urb(tx_buf->urb);
list_del(&tx_buf->list);
usb_free_urb(tx_buf->urb);
+ usb_free_urb(tx_buf->urb);
kfree(tx_buf->buf);
kfree(tx_buf);
spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
@@ -779,6 +780,7 @@ static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev)
usb_kill_urb(tx_buf->urb);
list_del(&tx_buf->list);
usb_free_urb(tx_buf->urb);
+ usb_free_urb(tx_buf->urb);
kfree(tx_buf->buf);
kfree(tx_buf);
spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
@@ -797,6 +799,7 @@ static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev)
usb_kill_urb(tx_buf->urb);
list_del(&tx_buf->list);
usb_free_urb(tx_buf->urb);
+ usb_free_urb(tx_buf->urb);
kfree(tx_buf->buf);
kfree(tx_buf);
spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ath9k: hif_usb: fix memory leak in ath9k_hif_usb_firmware_cb
2021-07-09 8:43 [PATCH] ath9k: hif_usb: fix memory leak in ath9k_hif_usb_firmware_cb Dongliang Mu
@ 2021-07-23 10:12 ` Dongliang Mu
2021-07-27 6:02 ` Kalle Valo
2021-07-27 7:24 ` Julian Calaby
2 siblings, 0 replies; 5+ messages in thread
From: Dongliang Mu @ 2021-07-23 10:12 UTC (permalink / raw)
To: ath9k-devel, Kalle Valo, David S. Miller, Jakub Kicinski, Brooke Basile
Cc: syzbot+6692c72009680f7c4eb2, linux-wireless,
open list:NETWORKING [GENERAL],
linux-kernel
On Fri, Jul 9, 2021 at 4:44 PM Dongliang Mu <mudongliangabcd@gmail.com> wrote:
>
> The commit 03fb92a432ea ("ath9k: hif_usb: fix race condition between
> usb_get_urb() and usb_kill_anchored_urbs()") adds three usb_get_urb
> in ath9k_hif_usb_dealloc_tx_urbs and usb_free_urb.
>
> Fix this bug by adding corresponding usb_free_urb in
> ath9k_hif_usb_dealloc_tx_urbs other and hif_usb_stop.
>
Any idea about this patch?
> Reported-by: syzbot+6692c72009680f7c4eb2@syzkaller.appspotmail.com
> Fixes: 03fb92a432ea ("ath9k: hif_usb: fix race condition between usb_get_urb() and usb_kill_anchored_urbs()")
> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> ---
> drivers/net/wireless/ath/ath9k/hif_usb.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
> index 860da13bfb6a..bda91ff3289b 100644
> --- a/drivers/net/wireless/ath/ath9k/hif_usb.c
> +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
> @@ -457,6 +457,7 @@ static void hif_usb_stop(void *hif_handle)
> usb_kill_urb(tx_buf->urb);
> list_del(&tx_buf->list);
> usb_free_urb(tx_buf->urb);
> + usb_free_urb(tx_buf->urb);
> kfree(tx_buf->buf);
> kfree(tx_buf);
> spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
> @@ -779,6 +780,7 @@ static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev)
> usb_kill_urb(tx_buf->urb);
> list_del(&tx_buf->list);
> usb_free_urb(tx_buf->urb);
> + usb_free_urb(tx_buf->urb);
> kfree(tx_buf->buf);
> kfree(tx_buf);
> spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
> @@ -797,6 +799,7 @@ static void ath9k_hif_usb_dealloc_tx_urbs(struct hif_device_usb *hif_dev)
> usb_kill_urb(tx_buf->urb);
> list_del(&tx_buf->list);
> usb_free_urb(tx_buf->urb);
> + usb_free_urb(tx_buf->urb);
> kfree(tx_buf->buf);
> kfree(tx_buf);
> spin_lock_irqsave(&hif_dev->tx.tx_lock, flags);
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ath9k: hif_usb: fix memory leak in ath9k_hif_usb_firmware_cb
2021-07-09 8:43 [PATCH] ath9k: hif_usb: fix memory leak in ath9k_hif_usb_firmware_cb Dongliang Mu
2021-07-23 10:12 ` Dongliang Mu
@ 2021-07-27 6:02 ` Kalle Valo
2021-07-27 7:24 ` Julian Calaby
2 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2021-07-27 6:02 UTC (permalink / raw)
To: Dongliang Mu
Cc: ath9k-devel, David S. Miller, Jakub Kicinski, Brooke Basile,
syzbot+6692c72009680f7c4eb2, linux-wireless, netdev,
linux-kernel
Dongliang Mu <mudongliangabcd@gmail.com> writes:
> The commit 03fb92a432ea ("ath9k: hif_usb: fix race condition between
> usb_get_urb() and usb_kill_anchored_urbs()") adds three usb_get_urb
> in ath9k_hif_usb_dealloc_tx_urbs and usb_free_urb.
>
> Fix this bug by adding corresponding usb_free_urb in
> ath9k_hif_usb_dealloc_tx_urbs other and hif_usb_stop.
>
> Reported-by: syzbot+6692c72009680f7c4eb2@syzkaller.appspotmail.com
> Fixes: 03fb92a432ea ("ath9k: hif_usb: fix race condition between usb_get_urb() and usb_kill_anchored_urbs()")
> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
In the past there have been so many problems with ath9k syzbot fixes
that I have now a hard time trusting them. Can someone review this in
detail, please?
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ath9k: hif_usb: fix memory leak in ath9k_hif_usb_firmware_cb
2021-07-09 8:43 [PATCH] ath9k: hif_usb: fix memory leak in ath9k_hif_usb_firmware_cb Dongliang Mu
2021-07-23 10:12 ` Dongliang Mu
2021-07-27 6:02 ` Kalle Valo
@ 2021-07-27 7:24 ` Julian Calaby
2021-07-27 12:26 ` Kalle Valo
2 siblings, 1 reply; 5+ messages in thread
From: Julian Calaby @ 2021-07-27 7:24 UTC (permalink / raw)
To: Dongliang Mu
Cc: QCA ath9k Development, Kalle Valo, David S. Miller,
Jakub Kicinski, Brooke Basile, syzbot+6692c72009680f7c4eb2,
linux-wireless, netdev, LKML
Hi Dongliang,
(Drive-by review, I know almost nothing about the code in question)
On Fri, Jul 9, 2021 at 6:47 PM Dongliang Mu <mudongliangabcd@gmail.com> wrote:
>
> The commit 03fb92a432ea ("ath9k: hif_usb: fix race condition between
> usb_get_urb() and usb_kill_anchored_urbs()") adds three usb_get_urb
> in ath9k_hif_usb_dealloc_tx_urbs and usb_free_urb.
>
> Fix this bug by adding corresponding usb_free_urb in
> ath9k_hif_usb_dealloc_tx_urbs other and hif_usb_stop.
>
> Reported-by: syzbot+6692c72009680f7c4eb2@syzkaller.appspotmail.com
> Fixes: 03fb92a432ea ("ath9k: hif_usb: fix race condition between usb_get_urb() and usb_kill_anchored_urbs()")
> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> ---
> drivers/net/wireless/ath/ath9k/hif_usb.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
> index 860da13bfb6a..bda91ff3289b 100644
> --- a/drivers/net/wireless/ath/ath9k/hif_usb.c
> +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
> @@ -457,6 +457,7 @@ static void hif_usb_stop(void *hif_handle)
> usb_kill_urb(tx_buf->urb);
> list_del(&tx_buf->list);
> usb_free_urb(tx_buf->urb);
> + usb_free_urb(tx_buf->urb);
Ok, so if I'm reading this correctly, before the first usb_free_urb()
call, we have two references to the urb at tx_buf->urb.
Why?
Isn't the better fix here to detangle why there's more than one
reference to it and resolve it that way? This looks like a hack to fix
something much more fundamentally broken.
Thanks,
--
Julian Calaby
Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ath9k: hif_usb: fix memory leak in ath9k_hif_usb_firmware_cb
2021-07-27 7:24 ` Julian Calaby
@ 2021-07-27 12:26 ` Kalle Valo
0 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2021-07-27 12:26 UTC (permalink / raw)
To: Julian Calaby
Cc: Dongliang Mu, QCA ath9k Development, David S. Miller,
Jakub Kicinski, Brooke Basile, syzbot+6692c72009680f7c4eb2,
linux-wireless, netdev, LKML
Julian Calaby <julian.calaby@gmail.com> writes:
> Hi Dongliang,
>
> (Drive-by review, I know almost nothing about the code in question)
>
> On Fri, Jul 9, 2021 at 6:47 PM Dongliang Mu <mudongliangabcd@gmail.com> wrote:
>>
>> The commit 03fb92a432ea ("ath9k: hif_usb: fix race condition between
>> usb_get_urb() and usb_kill_anchored_urbs()") adds three usb_get_urb
>> in ath9k_hif_usb_dealloc_tx_urbs and usb_free_urb.
>>
>> Fix this bug by adding corresponding usb_free_urb in
>> ath9k_hif_usb_dealloc_tx_urbs other and hif_usb_stop.
>>
>> Reported-by: syzbot+6692c72009680f7c4eb2@syzkaller.appspotmail.com
>> Fixes: 03fb92a432ea ("ath9k: hif_usb: fix race condition between usb_get_urb() and usb_kill_anchored_urbs()")
>> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
>> ---
>> drivers/net/wireless/ath/ath9k/hif_usb.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
>> index 860da13bfb6a..bda91ff3289b 100644
>> --- a/drivers/net/wireless/ath/ath9k/hif_usb.c
>> +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
>> @@ -457,6 +457,7 @@ static void hif_usb_stop(void *hif_handle)
>> usb_kill_urb(tx_buf->urb);
>> list_del(&tx_buf->list);
>> usb_free_urb(tx_buf->urb);
>> + usb_free_urb(tx_buf->urb);
>
> Ok, so if I'm reading this correctly, before the first usb_free_urb()
> call, we have two references to the urb at tx_buf->urb.
>
> Why?
>
> Isn't the better fix here to detangle why there's more than one
> reference to it and resolve it that way? This looks like a hack to fix
> something much more fundamentally broken.
Yeah, this looks very suspicious.
One more thing: also the patch should be tested with real hardware. I'm
worried that people are just trying to fix a syzbot warning and not
really considering how it works in real life. That's why I'm extra
careful with syzbot patches for wireless drivers.
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-07-27 12:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-09 8:43 [PATCH] ath9k: hif_usb: fix memory leak in ath9k_hif_usb_firmware_cb Dongliang Mu
2021-07-23 10:12 ` Dongliang Mu
2021-07-27 6:02 ` Kalle Valo
2021-07-27 7:24 ` Julian Calaby
2021-07-27 12:26 ` Kalle Valo
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).