From patchwork Thu Apr 30 21:30:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 215765 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2720FC4724C for ; Thu, 30 Apr 2020 21:32:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F059206D6 for ; Thu, 30 Apr 2020 21:32:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726960AbgD3VcE (ORCPT ); Thu, 30 Apr 2020 17:32:04 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:48833 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726336AbgD3VcD (ORCPT ); Thu, 30 Apr 2020 17:32:03 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MfHUx-1iwbf70Yfb-00gsjk; Thu, 30 Apr 2020 23:31:46 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Johannes Berg , Emmanuel Grumbach , Luca Coelho , Intel Linux Wireless , Kalle Valo , "David S. Miller" , Sara Sharon Cc: Arnd Bergmann , Andrei Otcheretianski , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 02/15] iwlwifi: mvm: fix gcc-10 zero-length-bounds warning Date: Thu, 30 Apr 2020 23:30:44 +0200 Message-Id: <20200430213101.135134-3-arnd@arndb.de> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200430213101.135134-1-arnd@arndb.de> References: <20200430213101.135134-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:lQP65S7LwC6OwI92N4uIJiItdidHEpOk62jho5rpr9MQGl0HjXZ 61U0AbdpViblUikFmv9NwFYuekR9P0SmnIQkiDlSXipkrAVHEO5BMq88MZI6NRnqryCssyS vpgpn5jAG/7xFSbqWmLBDyjm2Rlw6Bv246k8MEhF+J6vpqkjfjwPTx2w3YBFUamsfMxcbal HerQDt2KcBHgm1DPAhILQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:Eq+KYWUtplI=:bbiSluhmCo/PlA0yETxveN 90eKlGoZpYuNinQfPNl9y8guRXUHQPAj+0g31axpsZVcPGPQIAZVTwzWtyMUyfQxG6l3sH6h6 l3lVCvXlc76LzqgpQCmXlGm+fFopVRqu3WuTm9DXXYDGMAPEK0XXCtvVnYY/mzOiJDd6QS1Mt 3/u9JANIkGmRc9kBKOb9RnKa35mTZmvjltyFsRfK4y+VszQB4oXneTbrSoSpAGV6ET0t2F+n/ xzqdAnY3ZpsaMHUZUAfnTnJz1Pa0NTBV9PB93OlVwqB/HKqYkIHXfWXtjU8gguSyvsu+XtG7I QAoRk+tRpgQUcWqY881mD74t9NCG+LAGChcI9xsmnwUjDZjxxGY5xucUtVTmYS5TvC3Eh76fW 8Gv9ujukt+BBaiCFJIJ6Caq4IlVanpBQrP4CAxoIcz0Yuo61IGAqUETgJrl0QeEqpkwd7z3fl 8sr1HRCBJ4C1gqZ44zf/d9OOpaRHb9MstxDL5puR5lELpXXiC8kwmqB+sFmVL0C6+3J5uaUrD sMm1Yctdw1a+Ivu9IZfw9ml3xm87F9vvwJ2aIOFnlEBC4kAwQLpomxwb29vpAqGTtNpTrpod3 REeXd699bO6GkcXhnbbB6oXrEmf2M8Dyf3ZTM86BQpj0slz4AKvjTDzVSdhfT9kzwVjiDohLz tm6q5qBybVGwplf5fUHJNU/ITmwvRsnVSMUWlQI2RKmCbfmUfTpuanzVRYdtrJ9gfZZQYS9M1 2qrJRipmwEi5Nk/wjWFRbOpP0kyaUbQkm4tnAlas9Q9cH9IKjvHnf2OaBDyEbfbqNFzzlOZcv 5dfXRPv3v1jXC7lgTp20eNIXHMkuri0PCRNJaEX/W1NQ+48kDI= Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org gcc-10 complains when a zero-length array is accessed: drivers/net/wireless/intel/iwlwifi/mvm/tx.c: In function 'iwl_mvm_rx_ba_notif': drivers/net/wireless/intel/iwlwifi/mvm/tx.c:1929:17: warning: array subscript 9 is outside the bounds of an interior zero-length array 'struct iwl_mvm_compressed_ba_tfd[0]' [-Wzero-length-bounds] 1929 | &ba_res->tfd[i]; | ~~~~~~~~~~~^~~ In file included from drivers/net/wireless/intel/iwlwifi/mvm/../fw/api/tdls.h:68, from drivers/net/wireless/intel/iwlwifi/mvm/fw-api.h:68, from drivers/net/wireless/intel/iwlwifi/mvm/sta.h:73, from drivers/net/wireless/intel/iwlwifi/mvm/mvm.h:83, from drivers/net/wireless/intel/iwlwifi/mvm/tx.c:72: drivers/net/wireless/intel/iwlwifi/mvm/../fw/api/tx.h:769:35: note: while referencing 'tfd' 769 | struct iwl_mvm_compressed_ba_tfd tfd[0]; | ^~~ Change this structure to use a flexible-array member for 'tfd' instead, along with the various structures using an zero-length ieee80211_hdr array that do not show warnings today but might be affected by similar issues in the future. Fixes: 6f68cc367ab6 ("iwlwifi: api: annotate compressed BA notif array sizes") Fixes: c46e7724bfe9 ("iwlwifi: mvm: support new BA notification response") Signed-off-by: Arnd Bergmann --- drivers/net/wireless/intel/iwlwifi/fw/api/tx.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h b/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h index f1d1fe96fecc..82d59b5a5f8c 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/tx.h @@ -293,7 +293,7 @@ struct iwl_tx_cmd { __le16 pm_frame_timeout; __le16 reserved4; u8 payload[0]; - struct ieee80211_hdr hdr[0]; + struct ieee80211_hdr hdr[]; } __packed; /* TX_CMD_API_S_VER_6 */ struct iwl_dram_sec_info { @@ -319,7 +319,7 @@ struct iwl_tx_cmd_gen2 { __le32 flags; struct iwl_dram_sec_info dram_info; __le32 rate_n_flags; - struct ieee80211_hdr hdr[0]; + struct ieee80211_hdr hdr[]; } __packed; /* TX_CMD_API_S_VER_7 */ /** @@ -342,7 +342,7 @@ struct iwl_tx_cmd_gen3 { struct iwl_dram_sec_info dram_info; __le32 rate_n_flags; __le64 ttl; - struct ieee80211_hdr hdr[0]; + struct ieee80211_hdr hdr[]; } __packed; /* TX_CMD_API_S_VER_8 */ /* @@ -766,8 +766,8 @@ struct iwl_mvm_compressed_ba_notif { __le32 tx_rate; __le16 tfd_cnt; __le16 ra_tid_cnt; - struct iwl_mvm_compressed_ba_tfd tfd[0]; struct iwl_mvm_compressed_ba_ratid ra_tid[0]; + struct iwl_mvm_compressed_ba_tfd tfd[]; } __packed; /* COMPRESSED_BA_RES_API_S_VER_4 */ /** @@ -784,7 +784,7 @@ struct iwl_mac_beacon_cmd_v6 { __le32 template_id; __le32 tim_idx; __le32 tim_size; - struct ieee80211_hdr frame[0]; + struct ieee80211_hdr frame[]; } __packed; /* BEACON_TEMPLATE_CMD_API_S_VER_6 */ /** @@ -805,7 +805,7 @@ struct iwl_mac_beacon_cmd_v7 { __le32 tim_size; __le32 ecsa_offset; __le32 csa_offset; - struct ieee80211_hdr frame[0]; + struct ieee80211_hdr frame[]; } __packed; /* BEACON_TEMPLATE_CMD_API_S_VER_7 */ enum iwl_mac_beacon_flags { @@ -840,7 +840,7 @@ struct iwl_mac_beacon_cmd { __le32 tim_size; __le32 ecsa_offset; __le32 csa_offset; - struct ieee80211_hdr frame[0]; + struct ieee80211_hdr frame[]; } __packed; /* BEACON_TEMPLATE_CMD_API_S_VER_10 */ struct iwl_beacon_notif { From patchwork Thu Apr 30 21:30:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 215764 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A0D1C47257 for ; Thu, 30 Apr 2020 21:33:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2E490214D8 for ; Thu, 30 Apr 2020 21:33:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727947AbgD3VdN (ORCPT ); Thu, 30 Apr 2020 17:33:13 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:48395 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726909AbgD3VdM (ORCPT ); Thu, 30 Apr 2020 17:33:12 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MuDLZ-1jBNLy1S1d-00uY02; Thu, 30 Apr 2020 23:31:55 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Amitkumar Karwar , Ganapathi Bhat , Xinming Hu , Kalle Valo , "David S. Miller" , Bing Zhao , Marc Yang , Ramesh Radhakrishnan , Kiran Divekar Cc: Arnd Bergmann , Nishant Sarmukadam , Amitkumar Karwar , Yogesh Ashok Powar , Frank Huang , "John W. Linville" , Cathy Luo , James Cao , linux-wireless@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 03/15] mwifiex: avoid -Wstringop-overflow warning Date: Thu, 30 Apr 2020 23:30:45 +0200 Message-Id: <20200430213101.135134-4-arnd@arndb.de> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200430213101.135134-1-arnd@arndb.de> References: <20200430213101.135134-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:gMEl41YFbv5VNowjvujQX1bH3XU15sf/EJ9rXogJvBQnt/sHj7H O2p++mED5GY1IUjnTdzdot3eCWrYutWmEBT6VRsXYMSwBS1bLyz+ZqBzfcUkyYV6iWVaKHN HQmyPesu8JEWYaVUg8tyLxSGDw0wD6s4ynsVQCXKFRZFafVz836k1aQocTn3vvLcihzCsjU SGGI7RkzszWYg5Eg8IuxA== X-UI-Out-Filterresults: notjunk:1; V03:K0:Iefr0Y7FrDk=:3xVJsBu2lbVSWDdgd21qFQ pTfq+BIvkox+0xWPzM2TwfzqFKWqYhK9fvTojKD3U/6L2YQ/f+Sikwg4jXatAAWcye9lmRHnN FeVCZmiN1DbMh36QRHN4hi8jRE1amPmzr1AdNuZsesEm0LHaLZbe8K8Rte+SNPEIRFTr4vY1+ CKBI9X0VZhtYkBVU/eeSSSnp2S3cQs2g0Tav76BbohvAN6r4gbd58fKyDq5PokBNlzLy3RmXX RvjWvGefF94Zkb11Y5x2ODRYH2tfOhNRyVRwMWazUkwbXceJpKE81UzNLrXQRRDPWwDjOtjwR hpqh02Zb82qfUM9nvvFa9+SQGQLU/6NzUQhq+1y9c42a/zpQSVEVOeLbHkxiR4xoS/o6On2ep 3z3XQltx4vFbreny69BTpAZj72dwCCF4RI0LJikyl81VFlDIITjyjiMueRE6oDRdvypOw7zPG Ef9ooJgoNQ3S5dB+FWSKngRDgZs+KzHqxg4AHiLVly4hEVr7vLHUIEYVWm8IoO/p3UdAnmLxM n9uNxgELQx1Dy9CuMJrWYsyvXacGodE9+NoHFJHpizaiHGli/qfXRUNoloWhgga3pWGsx2YN0 fNpn//idri55nJKGbO+oYCa0VyQeEdKM8lV3UnrWRaDO55e6FXf/1MWW1raWro6piMqcOrgY+ sUymLvbiQaeMjMcdvKHv+eLH5d87rx+tKSo7Fy94VFb25ez9ejXHbCkCb4Zcw4QYNN8P4EMML 6JBedCIp0OpjaFdx93P+LMdHzwYQs5LDkVb32jWSx/MN/qW4BDHqINuqCUbuHjNSg870Nlwyv T3sDpnz3h+hvNfHI5FbroNjYE8pkjtxb8A9sZfaw6srZtxVjpI= Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org gcc-10 reports a warning for mwifiex_cmd_802_11_key_material_v1: drivers/net/wireless/marvell/mwifiex/sta_cmd.c: In function 'mwifiex_cmd_802_11_key_material_v1': cc1: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=] In file included from drivers/net/wireless/marvell/mwifiex/sta_cmd.c:23: drivers/net/wireless/marvell/mwifiex/fw.h:993:9: note: at offset 0 to object 'action' with size 2 declared here 993 | __le16 action; | ^~~~~~ As the warning makes no sense, I reported it as a bug for gcc. In the meantime using a temporary pointer for the key data makes the code easier to read and stops the warning. Fixes: 5e6e3a92b9a4 ("wireless: mwifiex: initial commit for Marvell mwifiex driver") Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94881 Signed-off-by: Arnd Bergmann --- .../net/wireless/marvell/mwifiex/sta_cmd.c | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c index 0bd93f26bd7f..8bd355d7974e 100644 --- a/drivers/net/wireless/marvell/mwifiex/sta_cmd.c +++ b/drivers/net/wireless/marvell/mwifiex/sta_cmd.c @@ -853,43 +853,36 @@ mwifiex_cmd_802_11_key_material_v1(struct mwifiex_private *priv, memset(&key_material->key_param_set, 0, sizeof(struct mwifiex_ie_type_key_param_set)); if (enc_key->is_wapi_key) { + struct mwifiex_ie_type_key_param_set *set; + mwifiex_dbg(priv->adapter, INFO, "info: Set WAPI Key\n"); - key_material->key_param_set.key_type_id = - cpu_to_le16(KEY_TYPE_ID_WAPI); + set = &key_material->key_param_set; + set->key_type_id = cpu_to_le16(KEY_TYPE_ID_WAPI); if (cmd_oid == KEY_INFO_ENABLED) - key_material->key_param_set.key_info = - cpu_to_le16(KEY_ENABLED); + set->key_info = cpu_to_le16(KEY_ENABLED); else - key_material->key_param_set.key_info = - cpu_to_le16(!KEY_ENABLED); + set->key_info = cpu_to_le16(!KEY_ENABLED); - key_material->key_param_set.key[0] = enc_key->key_index; + set->key[0] = enc_key->key_index; if (!priv->sec_info.wapi_key_on) - key_material->key_param_set.key[1] = 1; + set->key[1] = 1; else /* set 0 when re-key */ - key_material->key_param_set.key[1] = 0; + set->key[1] = 0; if (!is_broadcast_ether_addr(enc_key->mac_addr)) { /* WAPI pairwise key: unicast */ - key_material->key_param_set.key_info |= - cpu_to_le16(KEY_UNICAST); + set->key_info |= cpu_to_le16(KEY_UNICAST); } else { /* WAPI group key: multicast */ - key_material->key_param_set.key_info |= - cpu_to_le16(KEY_MCAST); + set->key_info |= cpu_to_le16(KEY_MCAST); priv->sec_info.wapi_key_on = true; } - key_material->key_param_set.type = - cpu_to_le16(TLV_TYPE_KEY_MATERIAL); - key_material->key_param_set.key_len = - cpu_to_le16(WAPI_KEY_LEN); - memcpy(&key_material->key_param_set.key[2], - enc_key->key_material, enc_key->key_len); - memcpy(&key_material->key_param_set.key[2 + enc_key->key_len], - enc_key->pn, PN_LEN); - key_material->key_param_set.length = - cpu_to_le16(WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN); + set->type = cpu_to_le16(TLV_TYPE_KEY_MATERIAL); + set->key_len = cpu_to_le16(WAPI_KEY_LEN); + memcpy(&set->key[2], enc_key->key_material, enc_key->key_len); + memcpy(&set->key[2 + enc_key->key_len], enc_key->pn, PN_LEN); + set->length = cpu_to_le16(WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN); key_param_len = (WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN) + sizeof(struct mwifiex_ie_types_header);