From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bl2nam02on0139.outbound.protection.outlook.com ([104.47.38.139]:31232 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730217AbeIXUwV (ORCPT ); Mon, 24 Sep 2018 16:52:21 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Johannes Berg , Sasha Levin Subject: [PATCH AUTOSEL 4.14 02/36] mac80211_hwsim: require at least one channel Date: Mon, 24 Sep 2018 14:48:55 +0000 Message-ID: <20180924144851.164533-2-alexander.levin@microsoft.com> References: <20180924144851.164533-1-alexander.levin@microsoft.com> In-Reply-To: <20180924144851.164533-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Johannes Berg [ Upstream commit 484004339d4514fde425f6e8a9f6a6cc979bb0c3 ] Syzbot continues to try to create mac80211_hwsim radios, and manages to pass parameters that are later checked with WARN_ON in cfg80211 - catch another one in hwsim directly. Reported-by: syzbot+2a12f11c306afe871c1f@syzkaller.appspotmail.com Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- drivers/net/wireless/mac80211_hwsim.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/m= ac80211_hwsim.c index d686ba10fecc..62fcf57e2299 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -3124,6 +3124,11 @@ static int hwsim_new_radio_nl(struct sk_buff *msg, s= truct genl_info *info) if (info->attrs[HWSIM_ATTR_CHANNELS]) param.channels =3D nla_get_u32(info->attrs[HWSIM_ATTR_CHANNELS]); =20 + if (param.channels < 1) { + GENL_SET_ERR_MSG(info, "must have at least one channel"); + return -EINVAL; + } + if (param.channels > CFG80211_MAX_NUM_DIFFERENT_CHANNELS) { GENL_SET_ERR_MSG(info, "too many channels specified"); return -EINVAL; --=20 2.17.1