From patchwork Fri Nov 25 11:36:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 13055790 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DE0EC4332F for ; Fri, 25 Nov 2022 11:37:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229840AbiKYLhI (ORCPT ); Fri, 25 Nov 2022 06:37:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbiKYLhI (ORCPT ); Fri, 25 Nov 2022 06:37:08 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6561D1B9F3 for ; Fri, 25 Nov 2022 03:37:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-To:Resent-Cc: Resent-Message-ID:In-Reply-To:References; bh=ObEfr3YFJGLp+iu0VZx4A2Vp2Hs0y1gxqaaC/z/LPFY=; t=1669376227; x=1670585827; b=EqZCF8VydxQSpvmmRTUEVEdqNQRqscTZGUbD7QH7nAPsgWhQrnV1bqQ905HsISYStzhhKHAGTr0 YpWAGkg+aqCZaWUtERDTkuFvW7NYREhB+a3nsI+/QtdJSj33oWH66RfGctZj7E8/ctj8pifgpzmvB faiV7CLoFxzk3lPF+1WVzngixDYe+BS9Vtr5nblETArVb5SWqkuZcgmvB96k6GndUaYcLR2FzcGh5 35KzlZwQHmdbLL6iTTiEb25Jj2KNYo7WMka2OFP4izEdh4AKp3OhYPy7lxnRsklZgPUZqiIH13b7+ k1oFeLpngLEGAxe00C20fUt8bhlFCPcfapgQ==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1oyX0w-008pvO-0m; Fri, 25 Nov 2022 12:37:02 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , =?utf-8?q?S=C3=B6nke_Huster?= Subject: [PATCH 1/2] wifi: cfg80211: fix buffer overflow in elem comparison Date: Fri, 25 Nov 2022 12:36:57 +0100 Message-Id: <20221125123657.44ab63af8fc7.Ib449c5f95120320db924edf5935133467eedc3d2@changeid> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-malware-bazaar: not-scanned Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg For vendor elements, the code here assumes that 5 octets are present without checking. Since the element itself is already checked to fit, we only need to check the length. Reported-and-tested-by: Sönke Huster Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning") Signed-off-by: Johannes Berg --- net/wireless/scan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/wireless/scan.c b/net/wireless/scan.c index da752b0cc752..4d217798890a 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -330,7 +330,8 @@ static size_t cfg80211_gen_new_ie(const u8 *ie, size_t ielen, * determine if they are the same ie. */ if (tmp_old[0] == WLAN_EID_VENDOR_SPECIFIC) { - if (!memcmp(tmp_old + 2, tmp + 2, 5)) { + if (tmp_old[1] >= 5 && tmp[1] >= 5 && + !memcmp(tmp_old + 2, tmp + 2, 5)) { /* same vendor ie, copy from * subelement */ From patchwork Fri Nov 25 11:36:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 13055791 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2320C4167B for ; Fri, 25 Nov 2022 11:37:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229862AbiKYLhJ (ORCPT ); Fri, 25 Nov 2022 06:37:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbiKYLhI (ORCPT ); Fri, 25 Nov 2022 06:37:08 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6CBF1BE8A for ; Fri, 25 Nov 2022 03:37:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-To: Resent-Cc:Resent-Message-ID; bh=LKzLSJoPZvWxv6KRKP5lI0j5R2+f7wf4lYjKNr+wSa8=; t=1669376228; x=1670585828; b=bf17S1pAcuoZixpPvzkuYkMWHIn8CGZ/80606gFpwQjwmap 69zAYKRbgySL3pioJcr+XVj3ATPyUUefUp7u3EFT4mYwdtx9ZspaR2AaIRwJApjfSyn9eHoDTrQFV eL5Ripueeuz0bmi/9qkvJ6xPWuazBkfUZ/xIEBYqP90nulqNbDztuGA+xahIx0JcRZcwcz186ewPx HyxJowINDKhBVaPMzpPBKFyg6SSiQ7vx5XhT58f9IjWB5uf6ko44krhkTiLCgEw0epls/N6a4qYr/ vy/cw8LM8/b3C6ZxvY3ftbUqIFhxi6oaPT5JiHexAYE3Uyrd5mdTxh/ND3Ei/+hg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1oyX0w-008pvO-2u; Fri, 25 Nov 2022 12:37:04 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , =?utf-8?q?S=C3=B6nke_Huster?= Subject: [PATCH 2/2] wifi: cfg80211: don't allow multi-BSSID in S1G Date: Fri, 25 Nov 2022 12:36:58 +0100 Message-Id: <20221125123657.9275cf55a8d5.I1d453a442edfe92bec33e38cc1c79da5faa9505d@changeid> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221125123657.44ab63af8fc7.Ib449c5f95120320db924edf5935133467eedc3d2@changeid> References: <20221125123657.44ab63af8fc7.Ib449c5f95120320db924edf5935133467eedc3d2@changeid> MIME-Version: 1.0 X-malware-bazaar: not-scanned Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg In S1G beacon frames there shouldn't be multi-BSSID elements since that's not supported, remove that to avoid a potential integer underflow and/or misparsing the frames due to the different length of the fixed part of the frame. While at it, initialize non_tx_data so we don't send garbage values to the user (even if it doesn't seem to matter now.) Reported-and-tested-by: Sönke Huster Fixes: 9eaffe5078ca ("cfg80211: convert S1G beacon to scan results") Signed-off-by: Johannes Berg --- net/wireless/scan.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 4d217798890a..3d86482e83f5 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -2527,10 +2527,15 @@ cfg80211_inform_bss_frame_data(struct wiphy *wiphy, const struct cfg80211_bss_ies *ies1, *ies2; size_t ielen = len - offsetof(struct ieee80211_mgmt, u.probe_resp.variable); - struct cfg80211_non_tx_bss non_tx_data; + struct cfg80211_non_tx_bss non_tx_data = {}; res = cfg80211_inform_single_bss_frame_data(wiphy, data, mgmt, len, gfp); + + /* don't do any further MBSSID handling for S1G */ + if (ieee80211_is_s1g_beacon(mgmt->frame_control)) + return res; + if (!res || !wiphy->support_mbssid || !cfg80211_find_elem(WLAN_EID_MULTIPLE_BSSID, ie, ielen)) return res;