From patchwork Wed Aug 3 01:07:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masashi Honma X-Patchwork-Id: 9260537 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6952960754 for ; Wed, 3 Aug 2016 01:20:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5593A28536 for ; Wed, 3 Aug 2016 01:20:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 471062853D; Wed, 3 Aug 2016 01:20:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C7BE28536 for ; Wed, 3 Aug 2016 01:20:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754006AbcHCBUE (ORCPT ); Tue, 2 Aug 2016 21:20:04 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35690 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752978AbcHCBUB (ORCPT ); Tue, 2 Aug 2016 21:20:01 -0400 Received: by mail-pf0-f194.google.com with SMTP id h186so13486252pfg.2 for ; Tue, 02 Aug 2016 18:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CpYKFM11EzmOwKCD/1LEprKm4OWbD3Ut4BvwK7jKfLA=; b=07XmeGkO4FDpo2ZDWIutLl6beTaGQRugY5cn0HhhaxlDmbUtg6lhaC+QGUTK9wLjP3 Y5LJVcdFvPsfoHUKrSb0ADUCSSFQQG+vyLNRKLVk1W8ecvJeTySbECYUVypQdm0ep90o juTdhMtbjwq3sZV4fw/+0BmFGDonprw0TOTsGRhdO91ivFCRXOrLBFeq5hohdZOm7WB5 CNgjWHD4YNvLB+/nZ5BEVUfmxc0heSToLkTxX0mnKVwRvCsh6KimNuzflg2Q1C1I8OFc zmm+jXGZRUmOT1iqmGdEbGAEGMW4U0suygJUxAfvnFpswgKlIqrnphC4fnad3lx7HQ+J TMdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CpYKFM11EzmOwKCD/1LEprKm4OWbD3Ut4BvwK7jKfLA=; b=lK0fBduimohxx+UQbQs81WpxaNmgteWYoLJ3H6+96P4xz8+mmDL1DSN1KKMYaE8T9K br5WjxN2/c3YoCsBnciVSj30nh3dZEK6Pa1Qlvq0zgG7OP4V0siIvp4Sv6LVX13xyrBM PkNUbj36EoZ2x4tOCixhU6RIv+oGSLGZ2FV50jBllrLocJhUBNKP6z0ZNyL9G1IrV7VZ rU9Gkco7yDjl7myBi19jDLZFkKj+RJHb07V7LVZFnkFuocgqwvKd+fd7EcyB8wYsojSr 22B5jqh/sM1b9FALV/vDsjEuvQ8B5hbu+p/lxo9Wdg/Yod3KhXHPxIYC2fnHq9c9L9a7 H9ow== X-Gm-Message-State: AEkoouvOijL10v2b2mrVEQAQyZcrLRlDkq4RstjxnZ6COMSwD/7iwL6Hr6Gpr0JJzk11Ag== X-Received: by 10.98.216.199 with SMTP id e190mr111589216pfg.123.1470186485329; Tue, 02 Aug 2016 18:08:05 -0700 (PDT) Received: from localhost.localdomain (p4a0890.kngwnt01.ap.so-net.ne.jp. [120.74.8.144]) by smtp.gmail.com with ESMTPSA id z10sm7517666pff.95.2016.08.02.18.08.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Aug 2016 18:08:04 -0700 (PDT) From: Masashi Honma To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, j@w1.fi, me@bobcopeland.com, Masashi Honma Subject: [PATCH v3] nl80211: Receive correct value for NL80211_MESHCONF_HT_OPMODE command Date: Wed, 3 Aug 2016 10:07:44 +0900 Message-Id: <1470186464-4224-1-git-send-email-masashi.honma@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468927556-4703-1-git-send-email-masashi.honma@gmail.com> References: <1468927556-4703-1-git-send-email-masashi.honma@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Previously, NL80211_MESHCONF_HT_OPMODE rejected correct flag combination, ex) IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED | IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT. This was caused by simple comparison with value 16. This causes setting non-existent flag (like 0x08) and invalid flag combinations. So this commit implements some checks based on IEEE 802.11 2012 8.4.2.59 HT Operation element. Signed-off-by: Masashi Honma --- net/wireless/nl80211.c | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 46417f9..7b7530d 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -5380,6 +5380,7 @@ static int nl80211_parse_mesh_config(struct genl_info *info, { struct nlattr *tb[NL80211_MESHCONF_ATTR_MAX + 1]; u32 mask = 0; + u16 ht_opmode; #define FILL_IN_MESH_PARAM_IF_SET(tb, cfg, param, min, max, mask, attr, fn) \ do { \ @@ -5471,9 +5472,44 @@ do { \ FILL_IN_MESH_PARAM_IF_SET(tb, cfg, rssi_threshold, -255, 0, mask, NL80211_MESHCONF_RSSI_THRESHOLD, nl80211_check_s32); - FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0, 16, - mask, NL80211_MESHCONF_HT_OPMODE, - nl80211_check_u16); + /* + * Check HT operation mode based on + * IEEE 802.11 2012 8.4.2.59 HT Operation element. + */ + if (tb[NL80211_MESHCONF_HT_OPMODE]) { + ht_opmode = nla_get_u16(tb[NL80211_MESHCONF_HT_OPMODE]); + + if (ht_opmode & (~(IEEE80211_HT_OP_MODE_PROTECTION | + IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT | + IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT))) + return -EINVAL; + + if ((ht_opmode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) && + (ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT)) + return -EINVAL; + + switch (ht_opmode & IEEE80211_HT_OP_MODE_PROTECTION) { + case IEEE80211_HT_OP_MODE_PROTECTION_NONE: + if (ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT) + return -EINVAL; + break; + case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER: + if (!(ht_opmode & + IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT)) + return -EINVAL; + break; + case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ: + if (ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT) + return -EINVAL; + break; + case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED: + if (!(ht_opmode & + IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT)) + return -EINVAL; + break; + } + cfg->ht_opmode = ht_opmode; + } FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathToRootTimeout, 1, 65535, mask, NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT,