linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] wifi: mac80211: Don't finalize CSA in IBSS mode if state is disconnected
@ 2022-08-14 15:15 Siddh Raman Pant via Linux-kernel-mentees
  2022-08-15  7:00 ` Greg KH
  2022-08-24 20:11 ` Siddh Raman Pant via Linux-kernel-mentees
  0 siblings, 2 replies; 4+ messages in thread
From: Siddh Raman Pant via Linux-kernel-mentees @ 2022-08-14 15:15 UTC (permalink / raw)
  To: Johannes Berg, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: netdev, linux-wireless, linux-kernel, stable,
	linux-kernel-mentees, syzbot+b6c9fe29aefe68e4ad34

When we are not connected to a channel, sending channel "switch"
announcement doesn't make any sense.

The BSS list is empty in that case. This causes the for loop in
cfg80211_get_bss() to be bypassed, so the function returns NULL
(check line 1424 of net/wireless/scan.c), causing the WARN_ON()
in ieee80211_ibss_csa_beacon() to get triggered (check line 500
of net/mac80211/ibss.c), which was consequently reported on the
syzkaller dashboard.

Thus, check if we have an existing connection before generating
the CSA beacon in ieee80211_ibss_finish_csa().

Fixes: cd7760e62c2a ("mac80211: add support for CSA in IBSS mode")
Bug report: https://syzkaller.appspot.com/bug?id=05603ef4ae8926761b678d2939a3b2ad28ab9ca6
Reported-by: syzbot+b6c9fe29aefe68e4ad34@syzkaller.appspotmail.com
Cc: stable@vger.kernel.org

Signed-off-by: Siddh Raman Pant <code@siddh.me>
---
The fixes commit is old, and syzkaller shows the problem exists for
4.19 and 4.14 as well, so CC'd stable list.

 net/mac80211/ibss.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index d56890e3fabb..9b283bbc7bb4 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -530,6 +530,10 @@ int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata)
 
 	sdata_assert_lock(sdata);
 
+	/* When not connected/joined, sending CSA doesn't make sense. */
+	if (ifibss->state != IEEE80211_IBSS_MLME_JOINED)
+		return -ENOLINK;
+
 	/* update cfg80211 bss information with the new channel */
 	if (!is_zero_ether_addr(ifibss->bssid)) {
 		cbss = cfg80211_get_bss(sdata->local->hw.wiphy,
-- 
2.35.1


_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [PATCH] wifi: mac80211: Don't finalize CSA in IBSS mode if state is disconnected
  2022-08-14 15:15 [PATCH] wifi: mac80211: Don't finalize CSA in IBSS mode if state is disconnected Siddh Raman Pant via Linux-kernel-mentees
@ 2022-08-15  7:00 ` Greg KH
  2022-08-15  7:24   ` Siddh Raman Pant via Linux-kernel-mentees
  2022-08-24 20:11 ` Siddh Raman Pant via Linux-kernel-mentees
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2022-08-15  7:00 UTC (permalink / raw)
  To: Siddh Raman Pant
  Cc: netdev, linux-wireless, linux-kernel, stable, Eric Dumazet,
	Jakub Kicinski, Johannes Berg, Paolo Abeni, linux-kernel-mentees,
	David S. Miller, syzbot+b6c9fe29aefe68e4ad34

On Sun, Aug 14, 2022 at 08:45:12PM +0530, Siddh Raman Pant via Linux-kernel-mentees wrote:
> When we are not connected to a channel, sending channel "switch"
> announcement doesn't make any sense.
> 
> The BSS list is empty in that case. This causes the for loop in
> cfg80211_get_bss() to be bypassed, so the function returns NULL
> (check line 1424 of net/wireless/scan.c), causing the WARN_ON()
> in ieee80211_ibss_csa_beacon() to get triggered (check line 500
> of net/mac80211/ibss.c), which was consequently reported on the
> syzkaller dashboard.
> 
> Thus, check if we have an existing connection before generating
> the CSA beacon in ieee80211_ibss_finish_csa().
> 
> Fixes: cd7760e62c2a ("mac80211: add support for CSA in IBSS mode")
> Bug report: https://syzkaller.appspot.com/bug?id=05603ef4ae8926761b678d2939a3b2ad28ab9ca6
> Reported-by: syzbot+b6c9fe29aefe68e4ad34@syzkaller.appspotmail.com
> Cc: stable@vger.kernel.org
> 
> Signed-off-by: Siddh Raman Pant <code@siddh.me>

Please no blank line before your signed-off-by line or the tools will
not like it.

And did sysbot verify that this change solved the problem?

thanks,

greg k-h
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [PATCH] wifi: mac80211: Don't finalize CSA in IBSS mode if state is disconnected
  2022-08-15  7:00 ` Greg KH
@ 2022-08-15  7:24   ` Siddh Raman Pant via Linux-kernel-mentees
  0 siblings, 0 replies; 4+ messages in thread
From: Siddh Raman Pant via Linux-kernel-mentees @ 2022-08-15  7:24 UTC (permalink / raw)
  To: Greg KH
  Cc: netdev, linux-wireless, linux-kernel, stable, eric dumazet,
	jakub kicinski, johannes berg, paolo abeni, linux-kernel-mentees,
	david s. miller, syzbot+b6c9fe29aefe68e4ad34

On Mon, 15 Aug 2022 12:30:13 +0530  Greg KH  wrote:
> Please no blank line before your signed-off-by line or the tools will
> not like it.

Oh okay, noted.

> And did sysbot verify that this change solved the problem?

Syzbot was failing to boot for reasons unrelated to the patch.
I tried testing three times, and every time the boot was failing.
It was taking more than 5 hours for syzbot to pick up the patch
from pending state every time, so I now posted it.

You can look at the syzkaller group page here:
https://groups.google.com/g/syzkaller-bugs/c/bGZwWS4Q3ek/m/dQ3pdAVSAAAJ
(Pardon the atrocious HTML email at the end, I used a mobile app
to email and forgot it doesn't send in plaintext.)

I have locally tested this with the reproducer syzbot gave.

Thanks,
Siddh
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

* Re: [PATCH] wifi: mac80211: Don't finalize CSA in IBSS mode if state is disconnected
  2022-08-14 15:15 [PATCH] wifi: mac80211: Don't finalize CSA in IBSS mode if state is disconnected Siddh Raman Pant via Linux-kernel-mentees
  2022-08-15  7:00 ` Greg KH
@ 2022-08-24 20:11 ` Siddh Raman Pant via Linux-kernel-mentees
  1 sibling, 0 replies; 4+ messages in thread
From: Siddh Raman Pant via Linux-kernel-mentees @ 2022-08-24 20:11 UTC (permalink / raw)
  To: Siddh Raman Pant
  Cc: linux-wireless, linux-kernel, Eric Dumazet, netdev,
	Jakub Kicinski, Johannes Berg, Paolo Abeni, linux-kernel-mentees,
	David S. Miller, syzbot+b6c9fe29aefe68e4ad34

On Sun, 14 Aug 2022 20:45:12 +0530  Siddh Raman Pant  wrote:
> When we are not connected to a channel, sending channel "switch"
> announcement doesn't make any sense.
> 
> The BSS list is empty in that case. This causes the for loop in
> cfg80211_get_bss() to be bypassed, so the function returns NULL
> (check line 1424 of net/wireless/scan.c), causing the WARN_ON()
> in ieee80211_ibss_csa_beacon() to get triggered (check line 500
> of net/mac80211/ibss.c), which was consequently reported on the
> syzkaller dashboard.
> 
> Thus, check if we have an existing connection before generating
> the CSA beacon in ieee80211_ibss_finish_csa().
> 
> Fixes: cd7760e62c2a ("mac80211: add support for CSA in IBSS mode")
> Bug report: https://syzkaller.appspot.com/bug?id=05603ef4ae8926761b678d2939a3b2ad28ab9ca6
> Reported-by: syzbot+b6c9fe29aefe68e4ad34@syzkaller.appspotmail.com
> Cc: stable@vger.kernel.org

Tested-by: syzbot+b6c9fe29aefe68e4ad34@syzkaller.appspotmail.com

Syzbot is now booting properly and the test ran successfully.

Thanks,
Siddh

> Signed-off-by: Siddh Raman Pant <code@siddh.me>
> ---
> The fixes commit is old, and syzkaller shows the problem exists for
> 4.19 and 4.14 as well, so CC'd stable list.
> 
>  net/mac80211/ibss.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
> index d56890e3fabb..9b283bbc7bb4 100644
> --- a/net/mac80211/ibss.c
> +++ b/net/mac80211/ibss.c
> @@ -530,6 +530,10 @@ int ieee80211_ibss_finish_csa(struct ieee80211_sub_if_data *sdata)
>  
>  	sdata_assert_lock(sdata);
>  
> +	/* When not connected/joined, sending CSA doesn't make sense. */
> +	if (ifibss->state != IEEE80211_IBSS_MLME_JOINED)
> +		return -ENOLINK;
> +
>  	/* update cfg80211 bss information with the new channel */
>  	if (!is_zero_ether_addr(ifibss->bssid)) {
>  		cbss = cfg80211_get_bss(sdata->local->hw.wiphy,
> -- 
> 2.35.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

end of thread, other threads:[~2022-08-24 20:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-14 15:15 [PATCH] wifi: mac80211: Don't finalize CSA in IBSS mode if state is disconnected Siddh Raman Pant via Linux-kernel-mentees
2022-08-15  7:00 ` Greg KH
2022-08-15  7:24   ` Siddh Raman Pant via Linux-kernel-mentees
2022-08-24 20:11 ` Siddh Raman Pant via Linux-kernel-mentees

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).