mm81x_mac_check_fw_disabled_chans() allocates a response buffer sized for ARRAY_SIZE(mors_s1ghz_channels) (26) channel entries plus the fixed header, but then iterates the entries with the firmware-provided count alone: for (i = 0; i < le32_to_cpu(resp->n_channels); i++) { struct host_cmd_disabled_channel_entry *entry = &resp->channels[i]; n_channels is a __le32 filled by the firmware response and is not validated against the buffer size in any way. A firmware that reports more than 26 channels makes the loop read past the end of the kzalloc()ed buffer into adjacent heap memory and interpret it as channel entries. Bound the loop to the number of entries the buffer was actually allocated for. Fixes: b1906cea00b0 ("wifi: mm81x: add mm81x Wi-Fi HaLow driver") Signed-off-by: guohongyu --- Changes in v2: - Drop the Cc: stable tag. No code change. drivers/net/wireless/morsemicro/mm81x/mac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/morsemicro/mm81x/mac.c b/drivers/net/wireless/morsemicro/mm81x/mac.c index 0fa80b1488aa..953958bf1241 100644 --- a/drivers/net/wireless/morsemicro/mm81x/mac.c +++ b/drivers/net/wireless/morsemicro/mm81x/mac.c @@ -288,7 +288,8 @@ static void mm81x_mac_check_fw_disabled_chans(struct ieee80211_hw *hw) ch->flags &= ~IEEE80211_CHAN_S1G_NO_PRIMARY; } - for (i = 0; i < le32_to_cpu(resp->n_channels); i++) { + for (i = 0; i < le32_to_cpu(resp->n_channels) && + i < ARRAY_SIZE(mors_s1ghz_channels); i++) { struct ieee80211_channel *ch; struct host_cmd_disabled_channel_entry *entry = &resp->channels[i]; -- 2.43.0