Skip to content

Commit 03b7386

Browse files
committed
mac80211: fix CSA beacon allocation size
If the FTM responder settings are changed simultaneously with the CSA beacon, the buffer size allocated isn't sufficient and we'll have a heap overrun. Fix this. While at it, also clean up the ftm_responder assignment, doing it only if ftm_responder is non-zero is valid as it's 0 to start with, but not really useful to understand the code. Fixes: bc84797 ("mac80211: support FTM responder configuration/statistics") Signed-off-by: Johannes Berg <[email protected]>
1 parent c177db2 commit 03b7386

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

net/mac80211/cfg.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2891,7 +2891,7 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
28912891

28922892
len = beacon->head_len + beacon->tail_len + beacon->beacon_ies_len +
28932893
beacon->proberesp_ies_len + beacon->assocresp_ies_len +
2894-
beacon->probe_resp_len;
2894+
beacon->probe_resp_len + beacon->lci_len + beacon->civicloc_len;
28952895

28962896
new_beacon = kzalloc(sizeof(*new_beacon) + len, GFP_KERNEL);
28972897
if (!new_beacon)
@@ -2934,8 +2934,9 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
29342934
memcpy(pos, beacon->probe_resp, beacon->probe_resp_len);
29352935
pos += beacon->probe_resp_len;
29362936
}
2937-
if (beacon->ftm_responder)
2938-
new_beacon->ftm_responder = beacon->ftm_responder;
2937+
2938+
/* might copy -1, meaning no changes requested */
2939+
new_beacon->ftm_responder = beacon->ftm_responder;
29392940
if (beacon->lci) {
29402941
new_beacon->lci_len = beacon->lci_len;
29412942
new_beacon->lci = pos;

0 commit comments

Comments
 (0)