From patchwork Thu Oct 13 17:53:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2236 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp412721wrs; Thu, 13 Oct 2022 11:11:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7WeXuhE4nECubRjQ8Dpe3dpTpga2DkY5HUif1ws5kJaRzr7AGzAKsJeRP01NdTGzRSMGwZ X-Received: by 2002:a65:48cc:0:b0:45f:795:c374 with SMTP id o12-20020a6548cc000000b0045f0795c374mr963852pgs.107.1665684687178; Thu, 13 Oct 2022 11:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684687; cv=none; d=google.com; s=arc-20160816; b=yEZUTdCVFeShWTsrPU13ixa1KLoGzO21n2Rft7d5FjkbQEb/XSEliZP34I1L/8Ghl/ Kp8hx1tyezoUYQn0I13xYwYME9z2IOXevk67Z/Donm3QrjraAzs+cPGtG7+PiWutlgSG A3bnhy9tuX1C3+xMuU2djcCKDIq9m82jwYh/wx5Cf0DhM79A1wd0fhy0sbrL4/RNjntm ZjeVQ1QFNwNbFXL9Nd/7NvgTh0LVFJA//K4Zug4wAxnIQ/ibxMrjJvHXEL/5BeD2PF54 TtmFwrI0hedp/8YRGXhf2f2b5wvw7w9SHhVN68GeZYEr8ufS4eXgUPH7alH4rL3ydFv7 tepg== 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=YJIg0gTZNVbopiUkXpogYfFM7xDZJVVqzq5UKrp2Cko=; b=QmjYOxWEkL1QnUZjBpWsdc/SVcuzM4HCU9o1nalAxi741rxk5w/u6aaFkieOhu+IOo eyjPx5aD4ThCRwtnyVXwSyncpK5cPmDLN9PBYukxM1PxNiBy3ePyoG6b4Q902VaMa6QC fxPYPEqqvt4REOyClU5OvHXaNgxIUsbKWMrT02eBK+f1lNa8ARqZeTv/nHXtIVEGlrkW SbpMHWZ2q9MF4I2Uk2DqscnhXNk8UZ8M9PcDg5FSIs/ls5axIHOaWSr+/LB7dBq2Z0m4 F2ds8N/hrXtdMT6zXJybTET5kqwkqNB37IGGmqSydV0rCOLA6y3xXji9cxw19t7XzchG vuEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HD1CrisC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id na12-20020a17090b4c0c00b001fdd6d07d39si7062117pjb.8.2022.10.13.11.11.13; Thu, 13 Oct 2022 11:11:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=HD1CrisC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231362AbiJMSKr (ORCPT + 99 others); Thu, 13 Oct 2022 14:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231443AbiJMSKJ (ORCPT ); Thu, 13 Oct 2022 14:10:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F4E4175795; Thu, 13 Oct 2022 11:07:34 -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 B7B5E61A47; Thu, 13 Oct 2022 18:01:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A56BCC433D6; Thu, 13 Oct 2022 18:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684093; bh=ABVtqPRgxmZIFlVSQtFaRqnHz1dauK3i7uCum+wmrFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HD1CrisClRoFpKLiQMJhtk58tAiwL+ZkZsQsG9RLGZjHYm+uKuT/fJw8kJ6js4kdc EUFnz8pGznCEmlvZUzQ/1pM/UGBkNJg6AxFXW1BE8C3Z8npcPaCIsaWx0WoY1Xor1j Mj0aGm8JCt+BaKazkAOZHxqRnniW0/Fy/TbP9OIw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kees Cook , Johannes Berg Subject: [PATCH 6.0 22/34] wifi: cfg80211/mac80211: reject bad MBSSID elements Date: Thu, 13 Oct 2022 19:53:00 +0200 Message-Id: <20221013175147.094790325@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746596986199291072?= X-GMAIL-MSGID: =?utf-8?q?1746596986199291072?= From: Johannes Berg commit 8f033d2becc24aa6bfd2a5c104407963560caabc upstream. Per spec, the maximum value for the MaxBSSID ('n') indicator is 8, and the minimum is 1 since a multiple BSSID set with just one BSSID doesn't make sense (the # of BSSIDs is limited by 2^n). Limit this in the parsing in both cfg80211 and mac80211, rejecting any elements with an invalid value. This fixes potentially bad shifts in the processing of these inside the cfg80211_gen_new_bssid() function later. I found this during the investigation of CVE-2022-41674 fixed by the previous patch. Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Fixes: 78ac51f81532 ("mac80211: support multi-bssid") Reviewed-by: Kees Cook Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/mac80211/util.c | 2 ++ net/wireless/scan.c | 2 ++ 2 files changed, 4 insertions(+) --- a/net/mac80211/util.c +++ b/net/mac80211/util.c @@ -1442,6 +1442,8 @@ static size_t ieee802_11_find_bssid_prof for_each_element_id(elem, WLAN_EID_MULTIPLE_BSSID, start, len) { if (elem->datalen < 2) continue; + if (elem->data[0] < 1 || elem->data[0] > 8) + continue; for_each_element(sub, elem->data + 1, elem->datalen - 1) { u8 new_bssid[ETH_ALEN]; --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -2143,6 +2143,8 @@ static void cfg80211_parse_mbssid_data(s for_each_element_id(elem, WLAN_EID_MULTIPLE_BSSID, ie, ielen) { if (elem->datalen < 4) continue; + if (elem->data[0] < 1 || (int)elem->data[0] > 8) + continue; for_each_element(sub, elem->data + 1, elem->datalen - 1) { u8 profile_len;