All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wifi: carl9170: do not ping device which has failed to load firmware
@ 2025-06-10 10:02 Dmitry Antipov
  2025-06-11 20:36 ` Christian Lamparter
  0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Antipov @ 2025-06-10 10:02 UTC (permalink / raw)
  To: Christian Lamparter; +Cc: linux-wireless, Dmitry Antipov

Syzkaller reports [1, 2] crashes caused by an attempts to ping
the device which has failed to load firmware. Since such a device
doesn't pass 'ieee80211_register_hw()', an internal workqueue
managed by 'ieee80211_queue_work()' is not yet created and an
attempt to queue work on it causes null-ptr-deref.

[1] https://syzkaller.appspot.com/bug?extid=9a4aec827829942045ff
[2] https://syzkaller.appspot.com/bug?extid=0d8afba53e8fb2633217
Fixes: e4a668c59080 ("carl9170: fix spurious restart due to high latency")
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/net/wireless/ath/carl9170/usb.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/carl9170/usb.c b/drivers/net/wireless/ath/carl9170/usb.c
index a3e03580cd9f..a0bfa0c477ee 100644
--- a/drivers/net/wireless/ath/carl9170/usb.c
+++ b/drivers/net/wireless/ath/carl9170/usb.c
@@ -438,13 +438,18 @@ static void carl9170_usb_rx_complete(struct urb *urb)
 
 		if (atomic_read(&ar->rx_anch_urbs) == 0) {
 			/*
-			 * The system is too slow to cope with
-			 * the enormous workload. We have simply
-			 * run out of active rx urbs and this
-			 * unfortunately leads to an unpredictable
-			 * device.
+			 * At this point, either the system is too slow to
+			 * cope with the enormous workload (so we have simply
+			 * run out of active rx urbs and this unfortunately
+			 * leads to an unpredictable device), or the device
+			 * is not fully functional after an unsuccessful
+			 * firmware loading attempts (so it doesn't pass
+			 * ieee80211_register_hw() and there is no internal
+			 * workqueue at all).
 			 */
 
+			if (WARN_ON_ONCE(!ar->registered))
+				return;
 			ieee80211_queue_work(ar->hw, &ar->ping_work);
 		}
 	} else {
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread
* Re: [PATCH] wifi: carl9170: do not ping device which has failed to load firmware
@ 2025-06-13 20:19 Fedor Pchelkin
  2025-06-14 16:33 ` Christian Lamparter
  0 siblings, 1 reply; 10+ messages in thread
From: Fedor Pchelkin @ 2025-06-13 20:19 UTC (permalink / raw)
  To: Dmitry Antipov; +Cc: Christian Lamparter, linux-wireless

Hi Dmitry,

Dmitry Antipov wrote:
> Syzkaller reports [1, 2] crashes caused by an attempts to ping
> the device which has failed to load firmware. Since such a device
> doesn't pass 'ieee80211_register_hw()', an internal workqueue
> managed by 'ieee80211_queue_work()' is not yet created and an
> attempt to queue work on it causes null-ptr-deref.
> 
> [1] https://syzkaller.appspot.com/bug?extid=9a4aec827829942045ff
> [2] https://syzkaller.appspot.com/bug?extid=0d8afba53e8fb2633217
> Fixes: e4a668c59080 ("carl9170: fix spurious restart due to high latency")
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
>  drivers/net/wireless/ath/carl9170/usb.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/carl9170/usb.c b/drivers/net/wireless/ath/carl9170/usb.c
> index a3e03580cd9f..a0bfa0c477ee 100644
> --- a/drivers/net/wireless/ath/carl9170/usb.c
> +++ b/drivers/net/wireless/ath/carl9170/usb.c
> @@ -438,13 +438,18 @@ static void carl9170_usb_rx_complete(struct urb *urb)
>  
>  		if (atomic_read(&ar->rx_anch_urbs) == 0) {
>  			/*
> -			 * The system is too slow to cope with
> -			 * the enormous workload. We have simply
> -			 * run out of active rx urbs and this
> -			 * unfortunately leads to an unpredictable
> -			 * device.
> +			 * At this point, either the system is too slow to
> +			 * cope with the enormous workload (so we have simply
> +			 * run out of active rx urbs and this unfortunately
> +			 * leads to an unpredictable device), or the device
> +			 * is not fully functional after an unsuccessful
> +			 * firmware loading attempts (so it doesn't pass
> +			 * ieee80211_register_hw() and there is no internal
> +			 * workqueue at all).
>  			 */
>  
> +			if (WARN_ON_ONCE(!ar->registered))
> +				return;

Is WARN justifiable here if it concerns handling a predefined error
condition?

I mean, yeah, it avoids a crash in the completion handler but kernels
with panic_on_warn - the ones which Syzkaller runs - will still stumble
here for no reason.

>  			ieee80211_queue_work(ar->hw, &ar->ping_work);
>  		}
>  	} else {
> -- 
> 2.49.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-06-17 23:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-10 10:02 [PATCH] wifi: carl9170: do not ping device which has failed to load firmware Dmitry Antipov
2025-06-11 20:36 ` Christian Lamparter
2025-06-15 19:54   ` Fedor Pchelkin
2025-06-16 10:01     ` Dmitry Antipov
2025-06-16 16:55       ` Christian Lamparter
2025-06-16 18:12         ` [PATCH v2] " Dmitry Antipov
2025-06-17  6:18           ` Christian Lamparter
2025-06-17 23:32           ` Jeff Johnson
  -- strict thread matches above, loose matches on Subject: below --
2025-06-13 20:19 [PATCH] " Fedor Pchelkin
2025-06-14 16:33 ` Christian Lamparter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.