From patchwork Tue Aug 2 11:41:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masashi Honma X-Patchwork-Id: 9256735 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 5543060754 for ; Tue, 2 Aug 2016 12:35:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 479AB28527 for ; Tue, 2 Aug 2016 12:35:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3ADD52852C; Tue, 2 Aug 2016 12:35: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 D10ED28527 for ; Tue, 2 Aug 2016 12:35:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934864AbcHBMey (ORCPT ); Tue, 2 Aug 2016 08:34:54 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:33675 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965004AbcHBMet (ORCPT ); Tue, 2 Aug 2016 08:34:49 -0400 Received: by mail-pa0-f65.google.com with SMTP id q2so11914021pap.0 for ; Tue, 02 Aug 2016 05:33:14 -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=4Tgd3BnOSPX7QSXFCQXG5NYO7OUQeQV9fSzUUiPZIe8=; b=OuwzYSdp5KUdwmyxe4+wsbJ3/EHN9unqjHLUqeQ+kf1nPDlWzhSTXEBtM9jbsKvPsf H4FB92eueDmhS55Z282Ib4z7swp9AlFsyjMuXeV6tcZEeuPQ8Z2n3zqAEsnbGhcNpmp1 C53dE7cklua5RvdKPMUjFQoX81Aq34s6A7iw7vYsMfUhlFjimhHPaG9A6arKq+hxJsVO mBNTKer0nt5cqqor9ZN9vr8FqVyEhf1Qgy8w+9ry/54YfKxn0PWzDONiXZYPsUQ+zBIv nGmmomYrevj1QTnZB9rX/29xofwXHCRsDdGHPbYJXH6tRcd8VonGh05llU2dbUOKgiXs cR/w== 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=4Tgd3BnOSPX7QSXFCQXG5NYO7OUQeQV9fSzUUiPZIe8=; b=QVYO/krxUrutRrs8VqmMUZQZ8UdpTxYqlzxY0AcMvAJSfKoCI7EDG6UsRQDjQ/SAhG ZB005Oz1vUF+WPN/PPtKw3E3BOBw/EXHo8me77ERiltuY5vlqp/Jqzb0eeYgsD2Ipsi6 ZdYdpzVOQZy7jT4PYYZI31+5jwRFJMxbZrf7hApMdwtiNMBreucyMRZ/hZ7FQ5ztfJcQ ud02sba9Deey2qO+X10UZtmVKvkRGtWresrW5bjTTbVMk8nZBJ7fRVFL2CMrJJ7EXGzO +Q1WTPxD3iiksYY9FQSNs2dFV2LEB3QJ5SpnihK8sUdAejKv52K/t2fteyP1PPScqWku aJpQ== X-Gm-Message-State: AEkoouugJGR8bMdbqTJ6ScibafalAs3PGUrC+MHCVJ0axK/r+ziZ1owvOourk7BwJbiXYw== X-Received: by 10.66.42.33 with SMTP id k1mr104781075pal.111.1470138108342; Tue, 02 Aug 2016 04:41:48 -0700 (PDT) Received: from localhost.localdomain (p0344e3.kngwnt01.ap.so-net.ne.jp. [121.3.68.227]) by smtp.gmail.com with ESMTPSA id i69sm4278598pfk.30.2016.08.02.04.41.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Aug 2016 04:41:47 -0700 (PDT) From: Masashi Honma To: honma@masap.sakura.ne.jp, johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, j@w1.fi, me@bobcopeland.com, Masashi Honma Subject: [PATCH v2] nl80211: Receive correct value for NL80211_MESHCONF_HT_OPMODE command Date: Tue, 2 Aug 2016 20:41:29 +0900 Message-Id: <1470138089-6864-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, 41 insertions(+), 1 deletion(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 46417f9..b2af600 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -5471,9 +5471,49 @@ 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, + FILL_IN_MESH_PARAM_IF_SET(tb, cfg, ht_opmode, 0, + IEEE80211_HT_OP_MODE_PROTECTION | + IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT | + IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT, mask, NL80211_MESHCONF_HT_OPMODE, nl80211_check_u16); + if (tb[NL80211_MESHCONF_HT_OPMODE]) { + /* + * Check HT operation mode based on IEEE 802.11 2012 8.4.2.59 + * HT Operation element. + */ + if (cfg->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 ((cfg->ht_opmode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) && + (cfg->ht_opmode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT)) + return -EINVAL; + + switch (cfg->ht_opmode & IEEE80211_HT_OP_MODE_PROTECTION) { + case IEEE80211_HT_OP_MODE_PROTECTION_NONE: + if (cfg->ht_opmode & + IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT) + return -EINVAL; + break; + case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER: + if (!(cfg->ht_opmode & + IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT)) + return -EINVAL; + break; + case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ: + if (cfg->ht_opmode & + IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT) + return -EINVAL; + break; + case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED: + if (!(cfg->ht_opmode & + IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT)) + return -EINVAL; + break; + } + } FILL_IN_MESH_PARAM_IF_SET(tb, cfg, dot11MeshHWMPactivePathToRootTimeout, 1, 65535, mask, NL80211_MESHCONF_HWMP_PATH_TO_ROOT_TIMEOUT,