From nobody Sun Jul 3 21:36:48 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6AA9C8A256D; Sun, 3 Jul 2022 21:36:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Lbj1r4n2Cz3sRF; Sun, 3 Jul 2022 21:36:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656884208; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WJdDXl9L/aNDsO2rdHsBrReGsthoBk9kQppNzocX3ZI=; b=VNtBBtDVCsRjHy2N0vwf32KPK7xP7ZJV1iV3wFy7F9hI8/W/YCsYQp/zy01R9rpJSqjw2W Qf+YaUgRLNwDF1eQkj1KbALAUqb8FyIGUCgPUWguqMp875e9Wt6Qq5g+4rSrO5VPTkyUug 5okluFEOpPN5yGg91TEIFLPkvitPG/rugYJwNEV95uGAVBUmj86d406JjqjxVA2Ky0bMKS sK7sgLNni9Gjvrpb/jPR+bT6ewyPXenJhSPPZASRjIsYTw9CzHtRO/zABWtUAopg4uOJzL 8EwFHjFXQuPP/zduG05a8rZCaBFEGJrb5L/CkMIKEEgYZesSEQzTgSaqaBxHkg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 64E852C381; Sun, 3 Jul 2022 21:36:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 263LamuJ095441; Sun, 3 Jul 2022 21:36:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 263LamjD095440; Sun, 3 Jul 2022 21:36:48 GMT (envelope-from git) Date: Sun, 3 Jul 2022 21:36:48 GMT Message-Id: <202207032136.263LamjD095440@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Cy Schubert Subject: git: 775611ea11db - main - wpa_supplicant: Resolve secondary VAP association issue List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cy X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 775611ea11db0973fd8b7aef0f5eb527308efd05 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656884208; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=WJdDXl9L/aNDsO2rdHsBrReGsthoBk9kQppNzocX3ZI=; b=XqHHoIXU9jCTZecPon9kuzdyjMbjGIiOS47gPtslQLV43hAVZBlRT/O9SoEgurGAPz0q8y hvZU1bgBxyKoPQqh3bLAsmzAydAIF6O22DeNxIomcj40hZY1AJRGBK8CevwMvx4fo4KB/K 9w4uiiEKX8t4u0ORB0/Otwpzvq9kF+LvspobB3Hn5XoQvNLBsw4RLm36yxsn6BaK8RRWth bsMc7tnJGkafIimc3wNcqo02M4zzNQ69rmC2gkjGiP8GJ2p9E21+AVeQjQMnTxYUC31Js/ rdNJCNNH70pHIjVMP8tUF+zKiIavHJ6IYOXVAOjSsZrjgeZ9ZQJ1CIW4gJwC+g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656884208; a=rsa-sha256; cv=none; b=F+0FIiO7/Fka0aj2xm9NSSOArJtq9a19GkSthLhKBM6/SwMyFKWESsSnSrk16VfGZ1HJ0l tpFEkKHr8jTKlIIdHNp4vnUH2Fne5Gv3mOEFSdpbr8PcSIKO+PWmobXk18q2CS7B2vdAM2 e1rCTQ7s+PVDHiGcWad8pv20l+8WbwawEXeltoc5ZnchThqTvcqtlRyMTZEMyGl7m5GZ7L 0W+N9eEcpvH+uv4sAFVbOsa/pf1a578E3/WexQlrJWKVzuY85q0fuxzMLbMgh35dKCUkjM Zme1MsUfUVsfOK/IYpbBcTVZ7lgwaMps7eYeFSf2Vti5IM71J+r/vApYiUx+jA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=775611ea11db0973fd8b7aef0f5eb527308efd05 commit 775611ea11db0973fd8b7aef0f5eb527308efd05 Author: J.R. Oldroyd AuthorDate: 2022-07-02 18:15:31 +0000 Commit: Cy Schubert CommitDate: 2022-07-03 21:19:38 +0000 wpa_supplicant: Resolve secondary VAP association issue Association will fail on a secondary open unprotected VAP when the primary VAP is configured for WPA. Examples of secondary VAPs are, hotels, universities, and commodity routers' guest networks. A broadly similar bug was discussed on Red Hat's bugzilla affecting association to a D-Link DIR-842. This suggests that as IEs were added to the 802.11 protocol the old code was increasingly inadaquate to handle the additional IEs, not only a secondary VAP. PR: 264238 Reported by: Jaskie "J.R. Oldroyd" Submitted by: "J.R. Oldroyd" MFC after: 3 days --- contrib/wpa/src/drivers/driver_bsd.c | 65 ++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/contrib/wpa/src/drivers/driver_bsd.c b/contrib/wpa/src/drivers/driver_bsd.c index c455bc931036..345bbb892ecf 100644 --- a/contrib/wpa/src/drivers/driver_bsd.c +++ b/contrib/wpa/src/drivers/driver_bsd.c @@ -14,6 +14,7 @@ #include "driver.h" #include "eloop.h" #include "common/ieee802_11_defs.h" +#include "common/ieee802_11_common.h" #include "common/wpa_common.h" #include @@ -1200,14 +1201,42 @@ handle_read(void *ctx, const u8 *src_addr, const u8 *buf, size_t len) drv_event_eapol_rx(drv->ctx, src_addr, buf, len); } +static int +wpa_driver_bsd_set_rsn_wpa_ie(struct bsd_driver_data * drv, + struct wpa_driver_associate_params *params, const u8 *ie) +{ + int privacy; + size_t ie_len = ie[1] ? ie[1] + 2 : 0; + + /* XXX error handling is wrong but unclear what to do... */ + if (wpa_driver_bsd_set_wpa_ie(drv, ie, ie_len) < 0) + return -1; + + privacy = !(params->pairwise_suite == WPA_CIPHER_NONE && + params->group_suite == WPA_CIPHER_NONE && + params->key_mgmt_suite == WPA_KEY_MGMT_NONE); + wpa_printf(MSG_DEBUG, "%s: set PRIVACY %u", __func__, + privacy); + + if (set80211param(drv, IEEE80211_IOC_PRIVACY, privacy) < 0) + return -1; + + if (ie_len && + set80211param(drv, IEEE80211_IOC_WPA, + ie[0] == WLAN_EID_RSN ? 2 : 1) < 0) + return -1; + + return 0; +} + static int wpa_driver_bsd_associate(void *priv, struct wpa_driver_associate_params *params) { struct bsd_driver_data *drv = priv; struct ieee80211req_mlme mlme; u32 mode; - int privacy; int ret = 0; + const u8 *wpa_ie, *rsn_ie; wpa_printf(MSG_DEBUG, "%s: ssid '%.*s' wpa ie len %u pairwise %u group %u key mgmt %u" @@ -1256,23 +1285,25 @@ wpa_driver_bsd_associate(void *priv, struct wpa_driver_associate_params *params) ret = -1; if (wpa_driver_bsd_set_auth_alg(drv, params->auth_alg) < 0) ret = -1; - /* XXX error handling is wrong but unclear what to do... */ - if (wpa_driver_bsd_set_wpa_ie(drv, params->wpa_ie, params->wpa_ie_len) < 0) - return -1; - privacy = !(params->pairwise_suite == WPA_CIPHER_NONE && - params->group_suite == WPA_CIPHER_NONE && - params->key_mgmt_suite == WPA_KEY_MGMT_NONE && - params->wpa_ie_len == 0); - wpa_printf(MSG_DEBUG, "%s: set PRIVACY %u", __func__, privacy); - - if (set80211param(drv, IEEE80211_IOC_PRIVACY, privacy) < 0) - return -1; - - if (params->wpa_ie_len && - set80211param(drv, IEEE80211_IOC_WPA, - params->wpa_ie[0] == WLAN_EID_RSN ? 2 : 1) < 0) - return -1; + if (params->wpa_ie_len) { + rsn_ie = get_ie(params->wpa_ie, params->wpa_ie_len, + WLAN_EID_RSN); + if (rsn_ie) { + if (wpa_driver_bsd_set_rsn_wpa_ie(drv, params, + rsn_ie) < 0) + return -1; + } + else { + wpa_ie = get_vendor_ie(params->wpa_ie, + params->wpa_ie_len, WPA_IE_VENDOR_TYPE); + if (wpa_ie) { + if (wpa_driver_bsd_set_rsn_wpa_ie(drv, params, + wpa_ie) < 0) + return -1; + } + } + } /* * NB: interface must be marked UP for association