From patchwork Mon Jan 13 11:37:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Theil X-Patchwork-Id: 1222089 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tu-ilmenau.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=fsqF2tfv; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47xBRG5vGdz9s29 for ; Mon, 13 Jan 2020 22:38:02 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=giliLcoY/zoTDK9+plmJFKNAyci82346wdhXH2LD+G0=; b=fsqF2tfvqn7djeIwI804g03bok 6tvb2PSYKga+t26fuI09DXlQOWlPU6PDznAo+bCD0j4oUEQ8EB4cWh+sDIPZgGJq30vJ4QhIjDr3/ FbBjg4b/bM/uVqNZj7dfCSK+N0NmUoX0XrYZNUcOaq6ai6jJ2FnRPIf1pADqcewbHeJpjyCSRP6A6 1JyCXvm9+p1gQjhv5Z/ABYqePYCmFXpZ7YDr82ILDhF6NZQEk/eP1tkdIUknbKv47Uvg/5Cpo8pG4 m8ODbH7Qg5/Y9xZq1W+Mle5VfBcDGsAPivR/F96+sNZxTVkNeCvXjfVPahG3QMZ/OCkwSOyGdtR8c R2jTVoCA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iqy2e-0005ZJ-IF; Mon, 13 Jan 2020 11:37:56 +0000 Received: from smail.rz.tu-ilmenau.de ([141.24.186.67]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iqy2b-0005Wj-1O for hostap@lists.infradead.org; Mon, 13 Jan 2020 11:37:54 +0000 Received: from thunderstorm.prakinf.tu-ilmenau.de (thunderstorm.prakinf.tu-ilmenau.de [141.24.212.108]) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPA id 5F824580068; Mon, 13 Jan 2020 12:37:47 +0100 (CET) From: Markus Theil To: hostap@lists.infradead.org Subject: [PATCH 1/4] driver: add rsn pre-auth rx event Date: Mon, 13 Jan 2020 12:37:32 +0100 Message-Id: <20200113113735.32182-2-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200113113735.32182-1-markus.theil@tu-ilmenau.de> References: <20200113113735.32182-1-markus.theil@tu-ilmenau.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200113_033753_235017_68182981 X-CRM114-Status: UNSURE ( 9.84 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [141.24.186.67 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Theil MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This patch adds an event for receiving pre-auth frames directly from drivers. Source and destination MACs are included in the corresponding struct to allow for forwarding of pre-auth frames in AP mode. Signed-off-by: Markus Theil --- src/drivers/driver.h | 31 +++++++++++++++++++++++++++++++ src/drivers/driver_common.c | 1 + 2 files changed, 32 insertions(+) diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 9bdf88011..65dc5de97 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -4636,6 +4636,14 @@ enum wpa_event_type { */ EVENT_EAPOL_RX, + /** + * EVENT_RSN_PREAUTH_RX - Report received RSN Pre-auth frame + * + * When in AP mode with hostapd, this event is required to be used to + * deliver the receive RSN Pre-auth frames from the driver. + */ + EVENT_RSN_PREAUTH_RX, + /** * EVENT_SIGNAL_CHANGE - Indicate change in signal strength * @@ -5531,6 +5539,16 @@ union wpa_event_data { size_t data_len; } eapol_rx; + /** + * struct rsn_preauth_rx - Data for EVENT_RSN_PREAUTH_RX events + */ + struct rsn_preauth_rx { + const u8 *src; + const u8 *dst; + const u8 *data; + size_t data_len; + } rsn_preauth_rx; + /** * signal_change - Data for EVENT_SIGNAL_CHANGE events */ @@ -5854,6 +5872,19 @@ static inline void drv_event_eapol_rx(void *ctx, const u8 *src, const u8 *data, wpa_supplicant_event(ctx, EVENT_EAPOL_RX, &event); } +static inline void drv_event_rsn_preauth_rx(void *ctx, const u8 *src, + const u8 *dst, const u8 *data, + size_t data_len) +{ + union wpa_event_data event; + os_memset(&event, 0, sizeof(event)); + event.rsn_preauth_rx.src = src; + event.rsn_preauth_rx.dst = dst; + event.rsn_preauth_rx.data = data; + event.rsn_preauth_rx.data_len = data_len; + wpa_supplicant_event(ctx, EVENT_RSN_PREAUTH_RX, &event); +} + /* driver_common.c */ void wpa_scan_results_free(struct wpa_scan_results *res); diff --git a/src/drivers/driver_common.c b/src/drivers/driver_common.c index 731c6a3b1..d6cb4cf74 100644 --- a/src/drivers/driver_common.c +++ b/src/drivers/driver_common.c @@ -52,6 +52,7 @@ const char * event_to_string(enum wpa_event_type event) E2S(RX_PROBE_REQ); E2S(NEW_STA); E2S(EAPOL_RX); + E2S(RSN_PREAUTH_RX); E2S(SIGNAL_CHANGE); E2S(INTERFACE_ENABLED); E2S(INTERFACE_DISABLED); From patchwork Mon Jan 13 11:37:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Theil X-Patchwork-Id: 1222092 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tu-ilmenau.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=V1Lcnnpp; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47xBRv2GPSz9s29 for ; Mon, 13 Jan 2020 22:38:35 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=uk45JwhFsfPO59HkVbm6A2vr0NwkgyrhCNFRGTtEHFY=; b=V1LcnnppyEdevKHJswLWw0LWnD drDxjMBj/B42NWPJVkwQ8lMUcQ/ovkzz8jbYlsN8t0iS3BAkI64+3Ni8RwlVRdVOYAivrQMkJS0T4 se8fDAKHNbu/EdR+ojdB593RfV59sA7Kbdk3UKpLok0/C3hNqbjCQ+mbIffpP6VcMzSKvBrcYqP1y XUpKgDrfZzh5mwX8zFXXDRJSZAZJrFU9QvYGIeQLtfbfsyUiumVgXNwMrlNRUBf6jcKu4rveO+G0l aDhk2OkWQxkpWrJK8AnhwSQ3Gxl//ia6c2CNSVrq5xLvXzmIvzVHFbCKlIc6hsYbG7YC7XH3D7qjY QchJ2A8w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iqy38-00064d-C3; Mon, 13 Jan 2020 11:38:26 +0000 Received: from smail.rz.tu-ilmenau.de ([141.24.186.67]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iqy2b-0005Wn-Qj for hostap@lists.infradead.org; Mon, 13 Jan 2020 11:37:56 +0000 Received: from thunderstorm.prakinf.tu-ilmenau.de (thunderstorm.prakinf.tu-ilmenau.de [141.24.212.108]) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPA id DE86658006E; Mon, 13 Jan 2020 12:37:47 +0100 (CET) From: Markus Theil To: hostap@lists.infradead.org Subject: [PATCH 2/4] nl80211: differentiate between ETH_P_PAE and ETH_P_RSN_PREAUTH for control port rx Date: Mon, 13 Jan 2020 12:37:33 +0100 Message-Id: <20200113113735.32182-3-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200113113735.32182-1-markus.theil@tu-ilmenau.de> References: <20200113113735.32182-1-markus.theil@tu-ilmenau.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200113_033754_010264_41D001A1 X-CRM114-Status: GOOD ( 10.31 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [141.24.186.67 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Theil MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org nl80211 control port event handling currently does not differentiate between EAPOL and PREAUTH frames. This patch add this and is later used to receive PREAUTH frames in hostapd and wpa_supplicant over nl80211. Signed-off-by: Markus Theil --- src/drivers/driver_nl80211_event.c | 38 ++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c index 8327644fb..625030adb 100644 --- a/src/drivers/driver_nl80211_event.c +++ b/src/drivers/driver_nl80211_event.c @@ -2451,12 +2451,36 @@ static void nl80211_sta_opmode_change_event(struct wpa_driver_nl80211_data *drv, static void nl80211_control_port_frame(struct wpa_driver_nl80211_data *drv, struct nlattr **tb) { - if (!tb[NL80211_ATTR_MAC] || !tb[NL80211_ATTR_FRAME]) + const u8 *src_addr = NULL; + const u8 *dst_addr = NULL; + + if (!tb[NL80211_ATTR_MAC] || + !tb[NL80211_ATTR_FRAME] || + !tb[NL80211_ATTR_CONTROL_PORT_ETHERTYPE]) return; - drv_event_eapol_rx(drv->ctx, nla_data(tb[NL80211_ATTR_MAC]), - nla_data(tb[NL80211_ATTR_FRAME]), - nla_len(tb[NL80211_ATTR_FRAME])); + src_addr = nla_data(tb[NL80211_ATTR_MAC]); + + switch(nla_get_u16(tb[NL80211_ATTR_CONTROL_PORT_ETHERTYPE])) { + case ETH_P_RSN_PREAUTH: + /* TODO: re-enable when upstream in kernel */ + /* + if (tb[NL80211_ATTR_DST_MAC]) + dst_addr = nla_data(tb[NL80211_ATTR_DST_MAC]); + */ + + drv_event_rsn_preauth_rx(drv->ctx, + src_addr, + dst_addr, + nla_data(tb[NL80211_ATTR_FRAME]), + nla_len(tb[NL80211_ATTR_FRAME])); + break; + case ETH_P_PAE: + drv_event_eapol_rx(drv->ctx, src_addr, + nla_data(tb[NL80211_ATTR_FRAME]), + nla_len(tb[NL80211_ATTR_FRAME])); + break; + } } @@ -2675,9 +2699,6 @@ static void do_process_drv_event(struct i802_bss *bss, int cmd, case NL80211_CMD_UPDATE_OWE_INFO: mlme_event_dh_event(drv, bss, tb); break; - case NL80211_CMD_CONTROL_PORT_FRAME: - nl80211_control_port_frame(drv, tb); - break; default: wpa_dbg(drv->ctx, MSG_DEBUG, "nl80211: Ignored unknown event " "(cmd=%d)", cmd); @@ -2767,6 +2788,9 @@ int process_bss_event(struct nl_msg *msg, void *arg) case NL80211_CMD_EXTERNAL_AUTH: nl80211_external_auth(bss->drv, tb); break; + case NL80211_CMD_CONTROL_PORT_FRAME: + nl80211_control_port_frame(bss->drv, tb); + break; default: wpa_printf(MSG_DEBUG, "nl80211: Ignored unknown event " "(cmd=%d)", gnlh->cmd); From patchwork Mon Jan 13 11:37:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Theil X-Patchwork-Id: 1222093 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tu-ilmenau.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=JWe4F8aB; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47xBS15W1Pz9s29 for ; Mon, 13 Jan 2020 22:38:41 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=M6kMNntJM5aIpbE7VL56cRfapGSkHf+xWJu6I7E9tzs=; b=JWe4F8aBzSW2Zu4fO8bmPHqoaM tNx4Sql1xJBDJ2ijJMhq8CiCVTA6rGZReuuonF6rNfEnh+4ShbhOWcVmUrP1V3HVRAz15mVRrAdcz hgauKwxaDrZB95hg4D0FaUVtHXFYfcQhO/foNxwGA5NbM+ptO0IhtLW9y0ZIURcNxSLHmACKC7QP8 jQ+z7gD3Z9eXiZaHnSDU4ro6H7KULCjWKycNgypSmj/eIhxPvPniWmzIa14rjkM2bth6B+BUq4A5E e/voRs9og5uzx4hMcbCpsjewRG4NqGpBWC8DZhyaQbKNiXGig0Y68Psgrzb7vEh33Qdd2v/BFnq14 6Mz3QgxQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iqy3J-0006Fj-1y; Mon, 13 Jan 2020 11:38:37 +0000 Received: from smail.rz.tu-ilmenau.de ([141.24.186.67]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iqy2b-0005Wo-Qk for hostap@lists.infradead.org; Mon, 13 Jan 2020 11:37:56 +0000 Received: from thunderstorm.prakinf.tu-ilmenau.de (thunderstorm.prakinf.tu-ilmenau.de [141.24.212.108]) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPA id 5F92F580073; Mon, 13 Jan 2020 12:37:48 +0100 (CET) From: Markus Theil To: hostap@lists.infradead.org Subject: [PATCH 3/4] wpa_supplicant: add support for pre-auth rx over driver event Date: Mon, 13 Jan 2020 12:37:34 +0100 Message-Id: <20200113113735.32182-4-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200113113735.32182-1-markus.theil@tu-ilmenau.de> References: <20200113113735.32182-1-markus.theil@tu-ilmenau.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200113_033754_015432_6836F8E0 X-CRM114-Status: GOOD ( 13.11 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [141.24.186.67 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Theil MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This patch enables wpa_supplicant to receive pre-auth frames over nl80211. Signed-off-by: Markus Theil --- src/rsn_supp/preauth.c | 4 ++-- src/rsn_supp/preauth.h | 7 +++++++ wpa_supplicant/events.c | 5 +++++ wpa_supplicant/wpa_supplicant.c | 28 ++++++++++++++++++++++++++++ wpa_supplicant/wpa_supplicant_i.h | 2 ++ 5 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/rsn_supp/preauth.c b/src/rsn_supp/preauth.c index a7ca2ed8b..f90da68c9 100644 --- a/src/rsn_supp/preauth.c +++ b/src/rsn_supp/preauth.c @@ -58,8 +58,8 @@ static int rsn_preauth_key_mgmt(int akmp) } -static void rsn_preauth_receive(void *ctx, const u8 *src_addr, - const u8 *buf, size_t len) +void rsn_preauth_receive(void *ctx, const u8 *src_addr, + const u8 *buf, size_t len) { struct wpa_sm *sm = ctx; diff --git a/src/rsn_supp/preauth.h b/src/rsn_supp/preauth.h index 8caf3ee56..992ba86fc 100644 --- a/src/rsn_supp/preauth.h +++ b/src/rsn_supp/preauth.h @@ -14,6 +14,8 @@ struct wpa_scan_results; #if defined(IEEE8021X_EAPOL) && !defined(CONFIG_NO_WPA) void pmksa_candidate_free(struct wpa_sm *sm); +void rsn_preauth_receive(void *ctx, const u8 *src_addr, + const u8 *buf, size_t len); int rsn_preauth_init(struct wpa_sm *sm, const u8 *dst, struct eap_peer_config *eap_conf); void rsn_preauth_deinit(struct wpa_sm *sm); @@ -33,6 +35,11 @@ static inline void pmksa_candidate_free(struct wpa_sm *sm) { } +static inline void rsn_preauth_receive(void *ctx, const u8 *src_addr, + const u8 *buf, size_t len) +{ +} + static inline void rsn_preauth_candidate_process(struct wpa_sm *sm) { } diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 90138c60d..ef2492b63 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -4872,6 +4872,11 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, data->eapol_rx.data, data->eapol_rx.data_len); break; + case EVENT_RSN_PREAUTH_RX: + wpa_supplicant_rx_rsn_preauth(wpa_s, data->rsn_preauth_rx.src, + data->rsn_preauth_rx.data, + data->rsn_preauth_rx.data_len); + break; case EVENT_SIGNAL_CHANGE: wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_SIGNAL_CHANGE "above=%d signal=%d noise=%d txrate=%d", diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index 9f3d6ef60..bd617d454 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -4657,6 +4657,34 @@ void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr, } } +/** + * wpa_supplicant_rx_rsn_preauth - Deliver a received PREAUTH frame to + * wpa_supplicant + * @ctx: Context pointer (wpa_s); this is the ctx variable registered + * with struct wpa_driver_ops::init() + * @src_addr: Source address of the PREAUTH frame + * @buf: EAPOL data starting from the PREAUTH header (i.e., no Ethernet header) + * @len: Length of the PREAUTH data + * + * This function is called for each received PREAUTH frame. Most driver + * interfaces rely on more generic OS mechanism for receiving frames through + * l2_packet, but if such a mechanism is not available, the driver wrapper may + * take care of received PREAUTH frames and deliver them to the core supplicant + * code by calling this function. + */ +void wpa_supplicant_rx_rsn_preauth(void *ctx, const u8 *src_addr, + const u8 *buf, size_t len) +{ + struct wpa_supplicant *wpa_s = ctx; + + wpa_dbg(wpa_s, MSG_DEBUG, "RX RSN PREAUTH from " MACSTR, MAC2STR(src_addr)); + wpa_hexdump(MSG_MSGDUMP, "RX RSN PREAUTH", buf, len); + + if (wpa_s->wpa) { + rsn_preauth_receive(wpa_s->wpa, src_addr, buf, len); + } +} + int wpa_supplicant_update_mac_addr(struct wpa_supplicant *wpa_s) { diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index 7ab6ca377..397aedab0 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1372,6 +1372,8 @@ int wpa_supplicant_scard_init(struct wpa_supplicant *wpa_s, void wpa_supplicant_terminate_proc(struct wpa_global *global); void wpa_supplicant_rx_eapol(void *ctx, const u8 *src_addr, const u8 *buf, size_t len); +void wpa_supplicant_rx_rsn_preauth(void *ctx, const u8 *src_addr, + const u8 *buf, size_t len); void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s); void wpa_supplicant_clear_status(struct wpa_supplicant *wpa_s); void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid); From patchwork Mon Jan 13 11:37:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Theil X-Patchwork-Id: 1222090 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=tu-ilmenau.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20170209 header.b=aoIKVF2U; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (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) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47xBRM6xsYz9sPn for ; Mon, 13 Jan 2020 22:38:07 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=k7IGk0Y+Hv9vZMrl7gTKhi91HJ0K5TX89YVkYqpk51s=; b=aoIKVF2ULKG/oTLx9cJ3AZh1tp 52p4FaIAVPT+YDL6hpmd+swLCpAtHmwJU6Dq3N0KGzgVVV3xxHvSZBUk7goi02OpyAWeDd6JQtHuI qON3BfP83022t89+89fIzWz6lhHI6UE/YtRtDIaSCNSan3Ja3+VB3NHwfuKIMpEAyMfrG1ygi0PG7 DR926z/VyAGnkF10/7AQkWQ0IvnMXKwv1sqNjIWbayXW2yiHV/qXmPnOTbetkILucnYYCY6KKLCqf ZxJ0sP9ffGu9j/UC4nyGElMdjWKg3tccRFYFtP/skxPdrP4X31+YWlQ+fXbKcBBBOsWla1orxC/Hy qODNexng==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iqy2j-0005de-Ce; Mon, 13 Jan 2020 11:38:01 +0000 Received: from smail.rz.tu-ilmenau.de ([141.24.186.67]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iqy2b-0005Wt-1a for hostap@lists.infradead.org; Mon, 13 Jan 2020 11:37:54 +0000 Received: from thunderstorm.prakinf.tu-ilmenau.de (thunderstorm.prakinf.tu-ilmenau.de [141.24.212.108]) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPA id 26EDE580074; Mon, 13 Jan 2020 12:37:49 +0100 (CET) From: Markus Theil To: hostap@lists.infradead.org Subject: [PATCH 4/4] hostapd: add support for pre-auth rx over driver event Date: Mon, 13 Jan 2020 12:37:35 +0100 Message-Id: <20200113113735.32182-5-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200113113735.32182-1-markus.theil@tu-ilmenau.de> References: <20200113113735.32182-1-markus.theil@tu-ilmenau.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200113_033753_234537_61F63076 X-CRM114-Status: UNSURE ( 9.41 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [141.24.186.67 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 SPF_NONE SPF: sender does not publish an SPF Record X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Theil MIME-Version: 1.0 Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This patch enables hostapd to receive pre-auth frames over nl80211. Signed-off-by: Markus Theil --- src/ap/drv_callbacks.c | 32 ++++++++++++++++++++++++++++++++ src/ap/preauth_auth.c | 29 +++++++++++++++++++++++++++++ src/ap/preauth_auth.h | 13 +++++++++++++ 3 files changed, 74 insertions(+) diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c index fdd845573..4c0ea80c4 100644 --- a/src/ap/drv_callbacks.c +++ b/src/ap/drv_callbacks.c @@ -42,6 +42,7 @@ #include "dpp_hostapd.h" #include "fils_hlp.h" #include "neighbor_db.h" +#include "preauth_auth.h" #ifdef CONFIG_FILS @@ -1424,6 +1425,30 @@ static void hostapd_event_eapol_rx(struct hostapd_data *hapd, const u8 *src, ieee802_1x_receive(hapd, src, data, data_len); } + +static void hostapd_event_rsn_preauth_rx(struct hostapd_data *hapd, + const u8 *src, const u8 *dst, + const u8 *data, size_t data_len) +{ + if (!hapd->preauth_iface) { + wpa_printf(MSG_DEBUG, "Received pre-auth frame from " MACSTR + " without preauth_iface created", + MAC2STR(src)); + return; + } + + if (!dst) { + wpa_printf(MSG_DEBUG, "Received pre-auth frame from " MACSTR + " without destination MAC set, maybe your kernel " + "is too old for nl80211 control port rx", + MAC2STR(src)); + return; + } + + rsn_preauth_receive_or_forward(hapd, src, dst, data, data_len); +} + + #endif /* HOSTAPD */ @@ -1797,6 +1822,13 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, data->eapol_rx.data, data->eapol_rx.data_len); break; + case EVENT_RSN_PREAUTH_RX: + hostapd_event_rsn_preauth_rx(hapd, + data->rsn_preauth_rx.src, + data->rsn_preauth_rx.dst, + data->rsn_preauth_rx.data, + data->rsn_preauth_rx.data_len); + break; case EVENT_ASSOC: if (!data) return; diff --git a/src/ap/preauth_auth.c b/src/ap/preauth_auth.c index 3e0c8000d..a367b5e19 100644 --- a/src/ap/preauth_auth.c +++ b/src/ap/preauth_auth.c @@ -270,4 +270,33 @@ void rsn_preauth_free_station(struct hostapd_data *hapd, struct sta_info *sta) eloop_cancel_timeout(rsn_preauth_finished_cb, hapd, sta); } +void rsn_preauth_receive_or_forward(struct hostapd_data *hapd, + const u8 *src_addr, + const u8 *dst_addr, + const u8 *buf, size_t len) +{ + struct l2_ethhdr *ethhdr; + + ethhdr = os_malloc(sizeof(*ethhdr) + len); + if (ethhdr == NULL) + return; + + if (os_memcmp(dst_addr, hapd->own_addr, ETH_ALEN) != 0) { + os_memcpy(ethhdr->h_dest, dst_addr, ETH_ALEN); + os_memcpy(ethhdr->h_source, src_addr, ETH_ALEN); + ethhdr->h_proto = host_to_be16(ETH_P_PREAUTH); + os_memcpy(ethhdr + 1, buf, len); + + if (l2_packet_send(hapd->preauth_iface->l2, dst_addr, ETH_P_PREAUTH, (u8 *) ethhdr, + sizeof(*ethhdr) + len) < 0) { + wpa_printf(MSG_ERROR, "Failed to forward preauth packet using " + "l2_packet_send\n"); + } + } else { + rsn_preauth_receive(hapd->preauth_iface, src_addr, buf, len); + } + + os_free(ethhdr); +} + #endif /* CONFIG_RSN_PREAUTH */ diff --git a/src/ap/preauth_auth.h b/src/ap/preauth_auth.h index 69fb3566e..d6ae1b72d 100644 --- a/src/ap/preauth_auth.h +++ b/src/ap/preauth_auth.h @@ -19,6 +19,11 @@ void rsn_preauth_send(struct hostapd_data *hapd, struct sta_info *sta, u8 *buf, size_t len); void rsn_preauth_free_station(struct hostapd_data *hapd, struct sta_info *sta); +void rsn_preauth_receive_or_forward(struct hostapd_data *hapd, + const u8 *src_addr, + const u8 *dst_addr, + const u8 *buf, size_t len); + #else /* CONFIG_RSN_PREAUTH */ static inline int rsn_preauth_iface_init(struct hostapd_data *hapd) @@ -47,6 +52,14 @@ static inline void rsn_preauth_free_station(struct hostapd_data *hapd, { } +static inline void rsn_preauth_receive_or_forward(struct hostapd_data *hapd, + const u8 *src_addr, + const u8 *dst_addr, + const u8 *buf, size_t len) +{ +} + + #endif /* CONFIG_RSN_PREAUTH */ #endif /* PREAUTH_H */