]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: nl80211: reject oversized EMA RNR lists
authorYuqi Xu <xuyuqiabc@gmail.com>
Fri, 29 May 2026 15:25:37 +0000 (23:25 +0800)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 2 Jun 2026 11:25:19 +0000 (13:25 +0200)
nl80211_parse_rnr_elems() stores the parsed element count in a
u8-backed cfg80211_rnr_elems::cnt field and uses that count to size
the flexible array allocation.

Reject nested NL80211_ATTR_EMA_RNR_ELEMS input once the count reaches
255, before incrementing it again. This keeps the parser aligned with
the data structure it fills and matches the existing bound check used
by nl80211_parse_mbssid_elems().

Fixes: dbbb27e183b1 ("cfg80211: support RNR for EMA AP")
Cc: stable@kernel.org
Reported-by: Yuan Tan <yuantan098@gmail.com>
Reported-by: Zhengchuan Liang <zcliangcn@gmail.com>
Reported-by: Xin Liu <bird@lzu.edu.cn>
Assisted-by: Codex:gpt-5.4
Signed-off-by: Yuqi Xu <xuyuqiabc@gmail.com>
Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
Link: https://patch.msgid.link/20260529152542.1412734-1-n05ec@lzu.edu.cn
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/nl80211.c

index 7db9cd4338011ac92653c25b8c35357f1cdbb15c..dac2e8643c495279a8c82fe31f088b9f88e416de 100644 (file)
@@ -6366,6 +6366,9 @@ nl80211_parse_rnr_elems(struct wiphy *wiphy, struct nlattr *attrs,
                if (ret)
                        return ERR_PTR(ret);
 
+               if (num_elems >= 255)
+                       return ERR_PTR(-EINVAL);
+
                num_elems++;
        }