瀏覽代碼

mac80211_hwsim: validate number of different channels

When creating a new radio on the fly, hwsim allows this
to be done with an arbitrary number of channels, but
cfg80211 only supports a limited number of simultaneous
channels, leading to a warning.

Fix this by validating the number - this requires moving
the define for the maximum out to a visible header file.

Reported-by: syzbot+8dd9051ff19940290931@syzkaller.appspotmail.com
Fixes: b59ec8dd4394 ("mac80211_hwsim: fix number of channels in interface combinations")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Johannes Berg 7 年之前
父節點
當前提交
51a1aaa631
共有 3 個文件被更改,包括 7 次插入2 次删除
  1. 5 0
      drivers/net/wireless/mac80211_hwsim.c
  2. 2 0
      include/net/cfg80211.h
  3. 0 2
      net/wireless/core.h

+ 5 - 0
drivers/net/wireless/mac80211_hwsim.c

@@ -3121,6 +3121,11 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)
 	if (info->attrs[HWSIM_ATTR_CHANNELS])
 	if (info->attrs[HWSIM_ATTR_CHANNELS])
 		param.channels = nla_get_u32(info->attrs[HWSIM_ATTR_CHANNELS]);
 		param.channels = nla_get_u32(info->attrs[HWSIM_ATTR_CHANNELS]);
 
 
+	if (param.channels > CFG80211_MAX_NUM_DIFFERENT_CHANNELS) {
+		GENL_SET_ERR_MSG(info, "too many channels specified");
+		return -EINVAL;
+	}
+
 	if (info->attrs[HWSIM_ATTR_NO_VIF])
 	if (info->attrs[HWSIM_ATTR_NO_VIF])
 		param.no_vif = true;
 		param.no_vif = true;
 
 

+ 2 - 0
include/net/cfg80211.h

@@ -815,6 +815,8 @@ struct cfg80211_csa_settings {
 	u8 count;
 	u8 count;
 };
 };
 
 
+#define CFG80211_MAX_NUM_DIFFERENT_CHANNELS 10
+
 /**
 /**
  * struct iface_combination_params - input parameters for interface combinations
  * struct iface_combination_params - input parameters for interface combinations
  *
  *

+ 0 - 2
net/wireless/core.h

@@ -507,8 +507,6 @@ void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev,
 void cfg80211_stop_nan(struct cfg80211_registered_device *rdev,
 void cfg80211_stop_nan(struct cfg80211_registered_device *rdev,
 		       struct wireless_dev *wdev);
 		       struct wireless_dev *wdev);
 
 
-#define CFG80211_MAX_NUM_DIFFERENT_CHANNELS 10
-
 #ifdef CONFIG_CFG80211_DEVELOPER_WARNINGS
 #ifdef CONFIG_CFG80211_DEVELOPER_WARNINGS
 #define CFG80211_DEV_WARN_ON(cond)	WARN_ON(cond)
 #define CFG80211_DEV_WARN_ON(cond)	WARN_ON(cond)
 #else
 #else