Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6389443rwd; Mon, 19 Jun 2023 06:42:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5/KqdwH4P9D25v/wc2he6EOWMX3PA+IchDqWn90bUw/HdXToyMOAJzh6vmtwUo8UzpzWKc X-Received: by 2002:a05:6a20:12d1:b0:10c:6b27:6415 with SMTP id v17-20020a056a2012d100b0010c6b276415mr930371pzg.8.1687182133440; Mon, 19 Jun 2023 06:42:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687182133; cv=none; d=google.com; s=arc-20160816; b=B+E6/NqyETSb5NfXOoGNOiQX9tmXUOcSIYY9uXHL1C8ElnbGJxB1ZSVCg4ND09CsKZ OtM8GWQ9KEqUqnPNOrkTyMjLBOERnrohKJISFh2My1Fs8wQUhf1yr/Ih/jfNC5juSeUW ijOn4Yimv5CRbrnCMVRXKeeP9VNv57jBuVLM8XUMZYnX+IqPbNOe81XfxqX++VoW3R62 NjETR2DI+NdIYk+HIgkP19eoWnG6rr1g1KrT8ZYpmNCrseZmWVK7BRZsPwltpFWyXmV4 3zNn2pKh/ksw+AjMNqVsRD3ocL84w/tJvVedZ6M/MCemVaX4sZapYKtEfqO0fOrMENE4 uc5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OOXyAQj9jy1cuO0rcnEktD1vThGTkPsOp75KU/erNm8=; b=vJab4LX4rQjbHFN0AdPEN8wNOKIsBRQGh5XvmLWZRHrxvZoaDwculhNqaUBJ04J8Ds OCbpruW7Sf+IQEINwkJPj2Mxoy3g9+1WqDLqy21T9rrvt+g+0d8jHEPVrH4uCSuqoMDT Hc6UpClpMiuSJ+xcPKbiT7nUngjgOcrWsmYmeyr/xzwwgijAv1JdHkRH7wndh3DrVAns UGpbk0Yq0SW0AsxUV+N3DBbPBptwYnOUoTJS0Lc6yDFfubar6nOAr9U5sNV1aps/QdAO JXnzHlVuba/D8SJySMyUGO3Vjghmu6SPfT8+pYlhhhBbrYNLvpc8LsCCVyQJtA8WYNCp EtFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EriHw3Jv; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l21-20020a637015000000b0055013415f30si9023985pgc.689.2023.06.19.06.42.05; Mon, 19 Jun 2023 06:42:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=EriHw3Jv; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231923AbjFSN1X (ORCPT + 61 others); Mon, 19 Jun 2023 09:27:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231925AbjFSN1W (ORCPT ); Mon, 19 Jun 2023 09:27:22 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86487123 for ; Mon, 19 Jun 2023 06:27:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687181240; x=1718717240; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KvWguZGglO0ZdEe0RJp7kVkK9S+rNoeulT0oL8e2odU=; b=EriHw3JvaWm2fsdoWqdyns3i5EpM7vJYddtzH396BMcwc277xueHMXd8 uxkW8rnSuo12c1q1CVjrRg53kO0QQj/K8ToMQ54ztLQry+8JQHXWs3XBm cGe8rSfrjPGGvaMq6E37mH8VEGEJZU8/LGWnoVpsBYkB0/cKD+x7fBbjY XkiZ5zJ9OgtJbV1wxgf7BrxT15CQoSTcNUuUqqFFHBmb2JK6CjhZeYSFn DwYqXUA8kzXndUG0yK5aiR7a6qe6W8bzIAW04QOWcw5mcojw8DMvChk2r Uj1hyZmwXaq4/gVRNlGl0HRYdywjEorGCsPmDpXV/UeNS1ZVYFidCeO4N Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="339240698" X-IronPort-AV: E=Sophos;i="6.00,254,1681196400"; d="scan'208";a="339240698" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2023 06:27:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="716871753" X-IronPort-AV: E=Sophos;i="6.00,254,1681196400"; d="scan'208";a="716871753" Received: from aadawii-mobl2.ger.corp.intel.com (HELO ggreenma-mobl2.lan) ([10.214.201.44]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2023 06:27:18 -0700 From: gregory.greenman@intel.com To: johannes@sipsolutions.net Cc: linux-wireless@vger.kernel.org, Johannes Berg , Gregory Greenman Subject: [PATCH 7/9] wifi: mac80211: fix CRC calculation for extended elems Date: Mon, 19 Jun 2023 16:26:51 +0300 Message-Id: <20230619161906.93235d5c8651.I6615cb3c1244bc9618066baa2bdad7982e9abd1f@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230619132653.902084-1-gregory.greenman@intel.com> References: <20230619132653.902084-1-gregory.greenman@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg For extended elements, we currently only calculate the CRC for some of them, but really we should do it also for the rest that we care about, such as EHT operation and multi- link. Also, while at it, it seems we should do it even if they aren't well-formed, so we notice if that changes. Signed-off-by: Johannes Berg Signed-off-by: Gregory Greenman --- net/mac80211/util.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 35701316dccf..516e68a39b7d 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -918,6 +918,7 @@ ieee80211_parse_extension_element(u32 *crc, struct ieee80211_elems_parse_params *params) { const void *data = elem->data + 1; + bool calc_crc = false; u8 len; if (!elem->datalen) @@ -927,12 +928,9 @@ ieee80211_parse_extension_element(u32 *crc, switch (elem->data[0]) { case WLAN_EID_EXT_HE_MU_EDCA: - if (len >= sizeof(*elems->mu_edca_param_set)) { + calc_crc = true; + if (len >= sizeof(*elems->mu_edca_param_set)) elems->mu_edca_param_set = data; - if (crc) - *crc = crc32_be(*crc, (void *)elem, - elem->datalen + 2); - } break; case WLAN_EID_EXT_HE_CAPABILITY: if (ieee80211_he_capa_size_ok(data, len)) { @@ -941,13 +939,10 @@ ieee80211_parse_extension_element(u32 *crc, } break; case WLAN_EID_EXT_HE_OPERATION: + calc_crc = true; if (len >= sizeof(*elems->he_operation) && - len >= ieee80211_he_oper_size(data) - 1) { - if (crc) - *crc = crc32_be(*crc, (void *)elem, - elem->datalen + 2); + len >= ieee80211_he_oper_size(data) - 1) elems->he_operation = data; - } break; case WLAN_EID_EXT_UORA: if (len >= 1) @@ -981,16 +976,15 @@ ieee80211_parse_extension_element(u32 *crc, case WLAN_EID_EXT_EHT_OPERATION: if (ieee80211_eht_oper_size_ok(data, len)) elems->eht_operation = data; + calc_crc = true; break; case WLAN_EID_EXT_EHT_MULTI_LINK: + calc_crc = true; + if (ieee80211_mle_size_ok(data, len)) { const struct ieee80211_multi_link_elem *mle = (void *)data; - if (crc) - *crc = crc32_be(*crc, (void *)elem, - elem->datalen + 2); - switch (le16_get_bits(mle->control, IEEE80211_ML_CONTROL_TYPE)) { case IEEE80211_ML_CONTROL_TYPE_BASIC: @@ -1009,6 +1003,9 @@ ieee80211_parse_extension_element(u32 *crc, } break; } + + if (crc && calc_crc) + *crc = crc32_be(*crc, (void *)elem, elem->datalen + 2); } static u32 -- 2.38.1