Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp410344lqp; Wed, 12 Jun 2024 05:38:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWkoKnM9WjNISLBIEKoBqVRAhmNmyg+bIi7yqaUU1p3iyIqz7kfmpTjQFfaBxKhFB8Ay7jNwyd4roUUIBI72eNDEj6GA0pIV2ZhMc4o5w== X-Google-Smtp-Source: AGHT+IG6R97KE5NSSc9yogP9ca5SR1nujQhbRLHjQwAiYpYxxizNNitZrYfa010OhVJWCPF1K5Hk X-Received: by 2002:a17:902:d507:b0:1f8:393e:8b9a with SMTP id d9443c01a7336-1f83b613520mr21092715ad.33.1718195912096; Wed, 12 Jun 2024 05:38:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718195912; cv=pass; d=google.com; s=arc-20160816; b=ONJBGIvjdIz6EUt+/p6de4/fw9GZQqtJe1kQphsueJIPKo58KXUICy/5I9YMhv1ffv A7CYsPWV+/XAAybN1j1pzMvnR6Q14sNrvtf4SwFzv6t/IVHBJP5U7DMAbku77AVaveRG anqIYNlgb9KIr7OQTzXs/DbDOMTe+K0kqSNL58MvVGOyLLeReyn/YVg3/CQqHgZagR1s 1Ljqi7EeQThpiSaciLPGDLkDCFq2iKxa0EOA2zG8fJbCvXY7TChbJmjqOd4QdBYlLQ+x LJT517fD+4YXzveg2eSu8PvTZb36r4lP3iaPK6JowrLornxzbhU8mvz9A0QkG8r9lo1B 3ZnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=tCgEKvw0cPmvBlFtaVhYIHHtQAEVyBLgpngYvIzz5yY=; fh=0ZKV22Mpi0Z+/zRlCC9GRUAKl0wLMxmYgR1nXO1NAEs=; b=YMPX09+jxwtWu0tjuw7EUVL5BDnWHULh7x3Bg3kdFXzSOP0RHsucP1jCck4Vbr4Dpf pYeo+VdaBd/G0iR2MeP6O+B8qmb67t0HpulMApl2o+tm03U4J5RZTfNJbBr+pr3gMQmN l/pGJ1xhdaJE1USgCd6g9qEW1mG5O+nZxyED+kfINxnc1jo91wd1UolzI3j5d8cfiAzc Gl8OXa4p8Gbo3YpNvTyYeBGYmIixv/SaKxIfx2CQeLARZLCXbeXdasEJGImobEaF/lGG FgP83omnKY8dLuaiOEHzOaPcdS2cYeot/68vgAd+5g8DcWgqwMmNEDjh3xAk3cpzGrWo EBww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=mRbM0o9I; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-8877-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8877-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d9443c01a7336-1f728a7511fsi36345955ad.195.2024.06.12.05.38.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 05:38:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-8877-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@sipsolutions.net header.s=mail header.b=mRbM0o9I; arc=pass (i=1 spf=pass spfdomain=sipsolutions.net dkim=pass dkdomain=sipsolutions.net dmarc=pass fromdomain=sipsolutions.net); spf=pass (google.com: domain of linux-wireless+bounces-8877-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-wireless+bounces-8877-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=sipsolutions.net Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B22C028276E for ; Wed, 12 Jun 2024 12:38:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 676B516F904; Wed, 12 Jun 2024 12:38:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b="mRbM0o9I" X-Original-To: linux-wireless@vger.kernel.org Received: from sipsolutions.net (s3.sipsolutions.net [168.119.38.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E557C16F29C for ; Wed, 12 Jun 2024 12:38:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=168.119.38.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718195896; cv=none; b=OLruJahHt4O8CpfBgiuLXZmYFT+PzjaFNCHo2UKegVePY0dfdXAGQvobMP5BSl0smCNKHUfH8ECZKhxKDJhbT88924qrg2iUZ1ALNzCqnxm/oFNek7mI594e4nSA/wy7M25GF7BB+clGT6LaQGTYqkXneX6+fSJ6kT7Ela5sBkE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718195896; c=relaxed/simple; bh=k7CFfyKRu5Cq53ohUFP3M+KVUJJJF7DzWumrspjwV+I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=VHhAbAIjmyocE68hYOjr5rxMgB91VmcCsz8+vFycuOhx6LAUposPfF6A16+/ttLTzKrV2BS59GrGVufrMRdNMhTGSZJVjmm0lUjqvT+PlDEwY1RayVxLDM3h592mNo+5upZ4JMOTEB7aLq3M8b4G9+GhsYQWpt4SxOfu2CdKNGc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net; spf=pass smtp.mailfrom=sipsolutions.net; dkim=pass (2048-bit key) header.d=sipsolutions.net header.i=@sipsolutions.net header.b=mRbM0o9I; arc=none smtp.client-ip=168.119.38.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sipsolutions.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sipsolutions.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-To:Resent-Cc: Resent-Message-ID:In-Reply-To:References; bh=tCgEKvw0cPmvBlFtaVhYIHHtQAEVyBLgpngYvIzz5yY=; t=1718195895; x=1719405495; b=mRbM0o9ICR2GWv5a82RgMG+vhO3TJmbRQ85Odz1m7gaticL6Umlt/KA5sImnwScw8HHRr/3Y8Yf OHFX/sSKGnNjTZ3Lzyo2xZWQmK0U8mCKwOp0aNYvFrp4BYd6LQY30qYiz3N/ujnrC/eAok68NmTFz C5SYG0KTH7pFpfHV0tvEfa6JjDDqH3atNeJr25s7LaSdMvG9ok/3KA7YPCTmevuIYUkfrz2tnf1eB AniyYqBXq8jMuhGEMVonHM3Qc0Gl0bwpuM6viGHyjRORFPxHvv1snD/t3EH/DYSflo/riP1CS3Oqo O2TYEbbH26CKNLoFR66qrZ2pVXeDt1NRTaQA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1sHNEy-0000000AH8F-0qts; Wed, 12 Jun 2024 14:38:12 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Miriam Rachel Korenblit Subject: [PATCH] wifi: mac80211: check SSID in beacon Date: Wed, 12 Jun 2024 14:38:10 +0200 Message-ID: <20240612143809.8b24a3d26a3d.I3e3ef31dbd2ec606be74d502a9d00dd9514c6885@changeid> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Johannes Berg Check that the SSID in beacons is correct, if it's not hidden and beacon protection is enabled (otherwise there's no value). If it doesn't match, disconnect. Reviewed-by: Miriam Rachel Korenblit Signed-off-by: Johannes Berg --- net/mac80211/mlme.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index ef3280fafbe9..df0978ce69de 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -6654,6 +6654,29 @@ ieee80211_mgd_check_cross_link_csa(struct ieee80211_sub_if_data *sdata, } } +static bool ieee80211_mgd_ssid_mismatch(struct ieee80211_sub_if_data *sdata, + const struct ieee802_11_elems *elems) +{ + struct ieee80211_vif_cfg *cfg = &sdata->vif.cfg; + static u8 zero_ssid[IEEE80211_MAX_SSID_LEN]; + + if (!elems->ssid) + return false; + + /* hidden SSID: zero length */ + if (elems->ssid_len == 0) + return false; + + if (elems->ssid_len != cfg->ssid_len) + return true; + + /* hidden SSID: zeroed out */ + if (memcmp(elems->ssid, zero_ssid, elems->ssid_len)) + return false; + + return memcmp(elems->ssid, cfg->ssid, cfg->ssid_len); +} + static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link, struct ieee80211_hdr *hdr, size_t len, struct ieee80211_rx_status *rx_status) @@ -6795,6 +6818,15 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link, elems = ieee802_11_parse_elems_full(&parse_params); if (!elems) return; + + if (rx_status->flag & RX_FLAG_DECRYPTED && + ieee80211_mgd_ssid_mismatch(sdata, elems)) { + sdata_info(sdata, "SSID mismatch for AP %pM, disconnect\n", + sdata->vif.cfg.ap_addr); + __ieee80211_disconnect(sdata); + return; + } + ncrc = elems->crc; if (ieee80211_hw_check(&local->hw, PS_NULLFUNC_STACK) && -- 2.45.2