Return-Path: Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35261 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932298AbeB1QRk (ORCPT ); Wed, 28 Feb 2018 11:17:40 -0500 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Johannes Berg" , syzbot+8dd9051ff19940290931@syzkaller.appspotmail.com Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: Subject: [PATCH 3.16 206/254] mac80211_hwsim: validate number of different channels In-Reply-To: Sender: stable-owner@vger.kernel.org List-ID: 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Johannes Berg commit 51a1aaa631c90223888d8beac4d649dc11d2ca55 upstream. 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 [bwh: Backported to 3.16: - Test chans intead of param.channels - GENL_SET_ERR_MSG() is not available - Adjust context] Signed-off-by: Ben Hutchings --- --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -2439,6 +2439,9 @@ static int hwsim_create_radio_nl(struct if (info->attrs[HWSIM_ATTR_CHANNELS]) chans = nla_get_u32(info->attrs[HWSIM_ATTR_CHANNELS]); + if (chans > CFG80211_MAX_NUM_DIFFERENT_CHANNELS) + return -EINVAL; + if (info->attrs[HWSIM_ATTR_USE_CHANCTX]) use_chanctx = true; else --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -716,6 +716,8 @@ struct cfg80211_csa_settings { u8 count; }; +#define CFG80211_MAX_NUM_DIFFERENT_CHANNELS 10 + /** * enum station_parameters_apply_mask - station parameter values to apply * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, max_sp) --- a/net/wireless/core.h +++ b/net/wireless/core.h @@ -456,8 +456,6 @@ void cfg80211_leave(struct cfg80211_regi void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev, struct wireless_dev *wdev); -#define CFG80211_MAX_NUM_DIFFERENT_CHANNELS 10 - #ifdef CONFIG_CFG80211_DEVELOPER_WARNINGS #define CFG80211_DEV_WARN_ON(cond) WARN_ON(cond) #else