From: Deepakkumar Karn <dkarn@redhat.com>
To: johannes@sipsolutions.net
Cc: dkarn@redhat.com, linux-kernel@vger.kernel.org,
linux-wireless@vger.kernel.org, shaul.triebitz@intel.com,
syzbot+5bb5f06f99924ea0cf86@syzkaller.appspotmail.com
Subject: Re: [PATCH] mac80211_hwsim: fix divide error in mac80211_hwsim_link_info_changed
Date: Sat, 6 Dec 2025 23:03:45 +0530 [thread overview]
Message-ID: <20251206173345.356068-1-dkarn@redhat.com> (raw)
In-Reply-To: <6cc422bb9525be529c6b0d2d25f9869ca41ec77d.camel@sipsolutions.net>
> On Sat, 2025-12-06 at 04:33 +0530, Deepakkumar Karn wrote:
> > On Fri, 05 Dec 2025 18:39:49 +0100, Johannes Berg wrote:
> > > Seems like we should not let userspace do that, to protect all other
> > > drivers too, not just hwsim.
> >
> > As suggested, we should provide a zero-value division check for other
> > drivers as well. I will investigate other places where divide errors can
> > occur due to edge cases.
> What, no no.
> > Please let me know if you meant something different. In the meantime,
> > I will analyze other drivers for similar cases.
> I did. My point is we shouldn't _have_ to check any drivers for this at
> all, it's nonsense and higher layers (here cfg80211) should reject it.
Thank you for your response Johannes. cfg80211 already have validation
in cfg80211_validate_beacon_int(). The problem seems to occur in
case of interface shutdown which calls ieee80211_do_stop() that makes
beacon_int = 0 or set_tsf which causes divides by zero.
What if we:
1. Handle off-channel operation:
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
index ae82533e3c02..14a103d320e3 100644
--- a/net/mac80211/offchannel.c
+++ b/net/mac80211/offchannel.c
@@ -156,10 +156,12 @@ void ieee80211_offchannel_return(struct ieee80211_local *local)
if (test_and_clear_bit(SDATA_STATE_OFFCHANNEL_BEACON_STOPPED,
&sdata->state)) {
- sdata->vif.bss_conf.enable_beacon = true;
- ieee80211_link_info_change_notify(
- sdata, &sdata->deflink,
- BSS_CHANGED_BEACON_ENABLED);
+ if (sdata->vif.bss_conf.beacon_int) {
+ sdata->vif.bss_conf.enable_beacon = true;
+ ieee80211_link_info_change_notify(
+ sdata, &sdata->deflink,
+ BSS_CHANGED_BEACON_ENABLED);
+ }
}
}
2. Handle case where debugfs is written after shutdown or any race condition during disable beaconing:
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c b/drivers/net/wireless/virtual/mac80211_hwsim.c
index 551f5eb4e747..8363cdd17a97 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim.c
@@ -1242,7 +1242,7 @@ static void mac80211_hwsim_set_tsf(struct ieee80211_hw *hw,
struct ieee80211_bss_conf *conf;
conf = link_conf_dereference_protected(vif, data->link_data[0].link_id);
- if (conf && !conf->enable_beacon)
+ if ((conf && !conf->enable_beacon) || !bcn_int)
return;
/* adjust after beaconing with new timestamp at old TBTT */
3. As other drivers already have beacon_int 0 value validation, consider
earlier patch along with above 2 points?
next prev parent reply other threads:[~2025-12-06 17:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-05 15:35 [PATCH] mac80211_hwsim: fix divide error in mac80211_hwsim_link_info_changed Deepakkumar Karn
2025-12-05 17:39 ` Johannes Berg
2025-12-05 23:03 ` Deepakkumar Karn
2025-12-06 14:56 ` Johannes Berg
2025-12-06 17:33 ` Deepakkumar Karn [this message]
2025-12-08 8:29 ` Johannes Berg
2025-12-10 18:56 ` Deepak Karn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251206173345.356068-1-dkarn@redhat.com \
--to=dkarn@redhat.com \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=shaul.triebitz@intel.com \
--cc=syzbot+5bb5f06f99924ea0cf86@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox