Linux wireless drivers development
 help / color / mirror / Atom feed
From: "Jiacheng Xu" <stitch@zju.edu.cn>
To: "Johannes Berg" <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net] wifi: cfg80211: reject invalid bss_entries_limit
Date: Sat, 22 Aug 2026 10:22:21 +0800 (GMT+08:00)	[thread overview]
Message-ID: <718c70a4.17a06.1a02746bac2.Coremail.stitch@zju.edu.cn> (raw)

The writable cfg80211.bss_entries_limit module parameter is currently
parsed by the generic integer parameter setter, which accepts zero and
negative values.

When bss_entries_limit is set to zero, the first new BSS entry satisfies:

    rdev->bss_entries >= bss_entries_limit

This causes __cfg80211_bss_update() to call
cfg80211_bss_expire_oldest() while the BSS list has no eligible entry.
The resulting NULL oldest entry triggers WARN_ON(!oldest).

Add a custom parameter setter that preserves normal integer parsing but
rejects values below one. Register it with module_param_call(), while
preserving the original getter, permissions, compile-time type checking,
and module parameter type metadata.

Update the parameter description to document the minimum value.

Fixes: 9853a55ef1bb ("cfg80211: limit scan results cache size")
Cc: stable@vger.kernel.org
Signed-off-by: Jiacheng Xu <stitch@zju.edu.cn>
---
net/wireless/scan.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)


diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 071083cc3367..a14acc699dc4 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -71,9 +71,27 @@
* entries in total, so overhead is bigger.)
*/
static int bss_entries_limit = 1000;
-module_param(bss_entries_limit, int, 0644);
+
+static int bss_entries_limit_set(const char *val,
+                              const struct kernel_param *kp)
+{
+     int limit, ret;
+
+     ret = kstrtoint(val, 0, &limit);
+     if (ret)
+             return ret;
+     if (limit < 1)
+             return -EINVAL;
+
+     return param_set_int(val, kp);
+}
+
+param_check_int(bss_entries_limit, &bss_entries_limit);
+module_param_call(bss_entries_limit, bss_entries_limit_set,
+               param_get_int, &bss_entries_limit, 0644);
+__MODULE_PARM_TYPE(bss_entries_limit, "int");
MODULE_PARM_DESC(bss_entries_limit,
-                 "limit to number of scan BSS entries (per wiphy, default
1000)");
+              "limit to number of scan BSS entries (per wiphy, default 1000, minimum 1)");


#define IEEE80211_SCAN_RESULT_EXPIRE (30 * HZ)

                 reply	other threads:[~2026-08-22  2:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=718c70a4.17a06.1a02746bac2.Coremail.stitch@zju.edu.cn \
    --to=stitch@zju.edu.cn \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    /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