Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2105968iof; Tue, 7 Jun 2022 19:57:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCCnIWbhJHqFeMf8PyEd1SKQN5MEkIryhumE8ueMObvKhOLIvvSvuYPoCJLX1kuLuOt+LM X-Received: by 2002:a17:90b:17c7:b0:1e8:5136:c32a with SMTP id me7-20020a17090b17c700b001e85136c32amr23419486pjb.43.1654657028648; Tue, 07 Jun 2022 19:57:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654657028; cv=none; d=google.com; s=arc-20160816; b=DlcqySL10UktrPot16fDVRZtH/ZW9AoTo4E6HpEPTZ6zGiCHT8sObRO2R535W2rNbM 48icgQdee2LON+Nmba31e7cdUBN4WFUtjd+cG7t96qcvUsNxy9mqoliQTFU76sFYC11j bz9wj32GVgZh7InC05dRoa1M3Q3MiPlIYKOfQR3r6v+0ymLDalhOmIZg67PLK3capQTu eVfBq+2j10rQopwg5dI0WVxZnEw/pPvED82HIO7a6TzPlhet2HoqyzpeMWP16OdJTI4h gAHCOQsA86jXZSm6A23ZbjU6DSjYHx0tjCTOZ7Lug4nqeJLFxQ9LRhRJZ7eckRobus3b T19w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=X7TU3NGuFRIPa701qNbdCRHgNyl495kn1QZu0Tctiak=; b=Xj3TC/oSxzbH+EgIfCQfEU5Wlx/X02yY3m9oObz9LYBrCZNbKqh030Wdl4y0pqyk2i vvRto/VdLKLdkjsuigLXHvD/2YZ3DWWm6F/cfwrhKJwBYtuvvPur6WTR/c12WzHDWpdE 91PXLFGwNq7vkzYWFi9sN8OpCb+j7GkIGOHE9/CQI77UvcmLpvUhH7+dqbVLdnImweEX bNQas5gmPRAjyQI8f8XV4HtE6NOZDIj55h1sVoAoIREfqVHnvqwW26mqjfzm2JZAeB1m LApVJz8319TsOptYMtJ+tG+nQtL2oRXg/i5HA2vh1cM/s3Pci0kXSyEk2+YvKMWFGR0D gSuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P0yoEwur; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id p18-20020a635b12000000b003fbb432d3c0si26873396pgb.643.2022.06.07.19.57.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 19:57:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P0yoEwur; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A708D32E76E; Tue, 7 Jun 2022 18:47:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385859AbiFGWrO (ORCPT + 99 others); Tue, 7 Jun 2022 18:47:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380824AbiFGViP (ORCPT ); Tue, 7 Jun 2022 17:38:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B9A4E8B97; Tue, 7 Jun 2022 12:05:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 159BB6184D; Tue, 7 Jun 2022 19:05:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C33DC385A2; Tue, 7 Jun 2022 19:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628717; bh=EvHff7RLEks0ueha8CxQImz90j4dNeG3LekJ1DQmmow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P0yoEwurDzUL8X8Y7rd3ppTiNrhZjhoTg7tybB/hf2l3Sn9kFSoicun15qFg+LZPK w8VyODJt/5y7yNVi4fMJPoQptRShhDWhRCU3zpxEQCxgrAjAIKA9wPVakqPirSL5C8 8dSPnwIK87nRjGWAzg/Bf3b2skI7VV5pmt8/ipng= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenzo Bianconi , Felix Fietkau , Sasha Levin Subject: [PATCH 5.18 431/879] mt76: mt7915: fix unbounded shift in mt7915_mcu_beacon_mbss Date: Tue, 7 Jun 2022 18:59:09 +0200 Message-Id: <20220607165015.379960149@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-kernel@vger.kernel.org From: Lorenzo Bianconi [ Upstream commit aa796f12091aa4758366f5171fd9cba2ff574ba3 ] Fix the following smatch static checker warning: drivers/net/wireless/mediatek/mt76/mt7915/mcu.c:1872 mt7915_mcu_beacon_mbss() error: undefined (user controlled) shift '(((1))) << (data[2])' Rely on mac80211 definitions for ieee80211_bssid_index subelement. Fixes: 6b7f9aff7c67 ("mt76: mt7915: introduce 802.11ax multi-bss support") Signed-off-by: Lorenzo Bianconi Signed-off-by: Felix Fietkau Signed-off-by: Sasha Levin --- .../net/wireless/mediatek/mt76/mt7915/mcu.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c index e7a6f80e7755..736c9c342baa 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7915/mcu.c @@ -1854,7 +1854,8 @@ mt7915_mcu_beacon_mbss(struct sk_buff *rskb, struct sk_buff *skb, continue; for_each_element(sub_elem, elem->data + 1, elem->datalen - 1) { - const u8 *data; + const struct ieee80211_bssid_index *idx; + const u8 *idx_ie; if (sub_elem->id || sub_elem->datalen < 4) continue; /* not a valid BSS profile */ @@ -1862,14 +1863,19 @@ mt7915_mcu_beacon_mbss(struct sk_buff *rskb, struct sk_buff *skb, /* Find WLAN_EID_MULTI_BSSID_IDX * in the merged nontransmitted profile */ - data = cfg80211_find_ie(WLAN_EID_MULTI_BSSID_IDX, - sub_elem->data, - sub_elem->datalen); - if (!data || data[1] < 1 || !data[2]) + idx_ie = cfg80211_find_ie(WLAN_EID_MULTI_BSSID_IDX, + sub_elem->data, + sub_elem->datalen); + if (!idx_ie || idx_ie[1] < sizeof(*idx)) continue; - mbss->offset[data[2]] = cpu_to_le16(data - skb->data); - mbss->bitmap |= cpu_to_le32(BIT(data[2])); + idx = (void *)(idx_ie + 2); + if (!idx->bssid_index || idx->bssid_index > 31) + continue; + + mbss->offset[idx->bssid_index] = + cpu_to_le16(idx_ie - skb->data); + mbss->bitmap |= cpu_to_le32(BIT(idx->bssid_index)); } } } -- 2.35.1