From: Deepakkumar Karn <dkarn@redhat.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: Shaul Triebitz <shaul.triebitz@intel.com>,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
Deepakkumar Karn <dkarn@redhat.com>,
syzbot+5bb5f06f99924ea0cf86@syzkaller.appspotmail.com
Subject: [PATCH] mac80211_hwsim: fix divide error in mac80211_hwsim_link_info_changed
Date: Fri, 5 Dec 2025 21:05:02 +0530 [thread overview]
Message-ID: <20251205153502.273426-1-dkarn@redhat.com> (raw)
Prevent a division by zero crash when userspace provides a zero beacon
interval value. The crash occurs in the beacon timer setup code path when
info->beacon_int is 0, causing bcn_int to be 0 and triggering a divide
error in the do_div() macro.The issue can be triggered from userspace via
nl80211/cfg80211 when configuring a virtual interface in AP mode with an
invalid beacon interval.
Fixes: e57f8a489c29 ("wifi: mac80211_hwsim: send a beacon per link")
Reported-by: syzbot+5bb5f06f99924ea0cf86@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=5bb5f06f99924ea0cf86
Signed-off-by: Deepakkumar Karn <dkarn@redhat.com>
---
drivers/net/wireless/virtual/mac80211_hwsim.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c b/drivers/net/wireless/virtual/mac80211_hwsim.c
index 5903d82e1ab1..e67e2c989ea6 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim.c
@@ -2595,11 +2595,14 @@ static void mac80211_hwsim_link_info_changed(struct ieee80211_hw *hw,
link_data->beacon_int = info->beacon_int * 1024;
tsf = mac80211_hwsim_get_tsf(hw, vif);
bcn_int = link_data->beacon_int;
- until_tbtt = bcn_int - do_div(tsf, bcn_int);
+ /* Proceed only when bcn_int != 0 */
+ if (bcn_int) {
+ until_tbtt = bcn_int - do_div(tsf, bcn_int);
- hrtimer_start(&link_data->beacon_timer,
- ns_to_ktime(until_tbtt * NSEC_PER_USEC),
- HRTIMER_MODE_REL_SOFT);
+ hrtimer_start(&link_data->beacon_timer,
+ ns_to_ktime(until_tbtt * NSEC_PER_USEC),
+ HRTIMER_MODE_REL_SOFT);
+ }
} else if (!info->enable_beacon) {
unsigned int count = 0;
ieee80211_iterate_active_interfaces_atomic(
--
2.51.1
next reply other threads:[~2025-12-05 15:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-05 15:35 Deepakkumar Karn [this message]
2025-12-05 17:39 ` [PATCH] mac80211_hwsim: fix divide error in mac80211_hwsim_link_info_changed Johannes Berg
2025-12-05 23:03 ` Deepakkumar Karn
2025-12-06 14:56 ` Johannes Berg
2025-12-06 17:33 ` Deepakkumar Karn
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=20251205153502.273426-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