Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nl80211: validate S1G channel width

Validate the S1G channel width input by user to ensure it matches
that of the requested channel

Signed-off-by: Kieran Frewen <kieran.frewen@morsemicro.com>
Signed-off-by: Bassem Dawood <bassem@morsemicro.com>
Link: https://lore.kernel.org/r/20220420041321.3788789-2-kieran.frewen@morsemicro.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Kieran Frewen and committed by
Johannes Berg
5d087aa7 5e469ed9

+9
+9
net/wireless/nl80211.c
··· 3173 3173 } else if (attrs[NL80211_ATTR_CHANNEL_WIDTH]) { 3174 3174 chandef->width = 3175 3175 nla_get_u32(attrs[NL80211_ATTR_CHANNEL_WIDTH]); 3176 + if (chandef->chan->band == NL80211_BAND_S1GHZ) { 3177 + /* User input error for channel width doesn't match channel */ 3178 + if (chandef->width != ieee80211_s1g_channel_width(chandef->chan)) { 3179 + NL_SET_ERR_MSG_ATTR(extack, 3180 + attrs[NL80211_ATTR_CHANNEL_WIDTH], 3181 + "bad channel width"); 3182 + return -EINVAL; 3183 + } 3184 + } 3176 3185 if (attrs[NL80211_ATTR_CENTER_FREQ1]) { 3177 3186 chandef->center_freq1 = 3178 3187 nla_get_u32(attrs[NL80211_ATTR_CENTER_FREQ1]);