From patchwork Mon May 11 10:37:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 1287764 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=fail (p=none dis=none) header.from=kernel.org 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=aefsoXC1; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=default header.b=uHdOnleT; 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 49LMff27Ytz9sRf for ; Mon, 11 May 2020 23:46:34 +1000 (AEST) 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=OkrM2pnRLNn7j/hTZs4Oq7m1OJS5ghizTDoCYZdJkxE=; b=aefsoXC1NkxGth ImWUSiyvH1K0bWGcj0G1SUb7NYH1dLbzmYtKrwzGjOLhAbKAkvPuNIgGgyzhuMHZJs7TS8tT0QB9z R0HC6y74Xhq0d2gahnzRsaR/ZGCMj+4VjNSK9fZgFJ01jqVuOTBI+VIQN7Hy+6mipM/8iqmZcho14 inehIUBcVUG0GqS9bE6lNL3YgTucg5gqDQVx3w7OfL6qOq9khT5mOUSruSLhCPYhZLFDGVAukIkMU 2kY2SYSD3AOUajxadc+WCwzrgw930EQZ3ECw7yAwYf0tYqSG6PNfYC36G+vOA3f2TVYIVZ0iuKy97 Hlgv8YhAXH/fz4vuTmWA==; 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 1jY8l6-00052l-Pm; Mon, 11 May 2020 13:46:16 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jY5on-0006jL-R1 for hostap@lists.infradead.org; Mon, 11 May 2020 10:37:55 +0000 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F22E4206DB; Mon, 11 May 2020 10:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589193473; bh=YcQrx3ER0Z6Y8WFZgAKmU4i6bMkiem97pVxNZd7emFg=; h=Date:From:To:Subject:From; b=uHdOnleTMQdApTeJys8WxkAN4vV2uSWYX6/jKx57Eb5W4dDVwiOqJ+b/0MnVz/PX1 qoMd9Inb53fBOsNpf3Yjov337+9aXtG0xHgHMzsdEpuaBQ5McZvot7JiLJHBHSSvI2 nwwLlxm8sSlmEkysKVs0VpH4DKeZo6HxJUli852I= Received: by pali.im (Postfix) id AD3F4B72; Mon, 11 May 2020 12:37:50 +0200 (CEST) Date: Mon, 11 May 2020 12:37:50 +0200 From: Pali =?utf-8?b?Um9ow6Fy?= To: hostap@lists.infradead.org, Jouni Malinen Subject: WPA-EAP/802.1x AP mode without NL80211_CMD_SET_STATION driver support Message-ID: <20200511103750.wec4vxetnm3tjlh3@pali> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20180716 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200511_033753_917364_508C6BEB X-CRM114-Status: GOOD ( 15.96 ) X-Spam-Score: -5.4 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-5.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [198.145.29.99 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.2 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-Mailman-Approved-At: Mon, 11 May 2020 06:46:12 -0700 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: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Hello Jouni! When hostapd is compiled without CONFIG_NO_VLAN option then WPA-EAP/802.1x AP mode is not working with wifi card which does not support NL80211_CMD_SET_STATION command and uses nl80211 hostapd driver. NL80211_CMD_SET_STATION command is used by nl80211 hostapd driver to configure NL80211_ATTR_STA_VLAN, see i802_set_sta_vlan() function. Here is hostapd log from Turris MOX router when is configured in WPA-EAP AP mode. It has SDIO wifi card managed by kernel driver mwifiex_sdio which does not implement NL80211_CMD_SET_STATION command when card is in AP mode. May 11 09:31:28 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 RADIUS: Received RADIUS packet matched with a pending request, round trip time 0.00 sec May 11 09:31:28 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 IEEE 802.11: binding station to interface 'wlan1' May 11 09:31:28 turris hostapd: nl80211: NL80211_ATTR_STA_VLAN (addr=c4:d9:87:6c:38:01 ifname=wlan1 vlan_id=0) failed: -524 (No error information) May 11 09:31:28 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 IEEE 802.11: could not bind the STA entry to vlan_id=0 May 11 09:31:28 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 IEEE 802.1X: decapsulated EAP packet (code=3 id=27 len=4) from RADIUS server: EAP Success May 11 09:31:28 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 IEEE 802.1X: Sending EAP Packet (identifier 27) May 11 09:31:31 turris hostapd: wlan1: CTRL-EVENT-EAP-RETRANSMIT2 c4:d9:87:6c:38:01 May 11 09:31:31 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 IEEE 802.1X: Sending EAP Packet (identifier 27) May 11 09:31:37 turris hostapd: wlan1: CTRL-EVENT-EAP-RETRANSMIT2 c4:d9:87:6c:38:01 May 11 09:31:37 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 IEEE 802.1X: Sending EAP Packet (identifier 27) May 11 09:31:47 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 IEEE 802.11: disassociated May 11 09:31:47 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 WPA: event 2 notification EAP authentication from radius server is successful, wpa_supplicant on client side also see successful authentication, but link is not established. That failed error code 524 is internal Linux kernel number for ENOTSUPP (double PP), see [1]. Userspace uses ENOTSUP (single P) code 95. Error printed in hostapd log is triggered by ap_sta_bind_vlan() call from ieee802_1x_receive_auth() function located in src/ap/ieee802_1x.c file. ap_sta_bind_vlan() calls hostapd_drv_set_sta_vlan() which for unsupported hostapd driver returns zero and for supported hostapd driver calls appropriate kernel interface, i.e. hostapd_drv_set_sta_vlan(). Which for card with unsupported NL80211_CMD_SET_STATION command returns error code -524. When hostapd is compiled with CONFIG_NO_VLAN then ap_sta_bind_vlan() always returns zero. I applied following change to hostapd sources: It changes error code from ENOTSUP (single P) and ENOTSUPP (double PP) to zero, which is propagated back to the ieee802_1x_receive_auth() function. And with this change WPA-EAP/802.1x AP mode started working. Here is hostapd log: May 11 09:28:20 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 RADIUS: Received RADIUS packet matched with a pending request, round trip time 0.00 sec May 11 09:28:20 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 IEEE 802.11: binding station to interface 'wlan1' May 11 09:28:20 turris hostapd: nl80211: NL80211_ATTR_STA_VLAN (addr=c4:d9:87:6c:38:01 ifname=wlan1 vlan_id=0) failed: -95 (Not supported) May 11 09:28:20 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 IEEE 802.11: could not bind the STA entry to vlan_id=0 May 11 09:28:20 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 IEEE 802.1X: old identity 'anonymous' updated with User-Name from Access-Accept 'anonymous' May 11 09:28:20 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 IEEE 802.1X: decapsulated EAP packet (code=3 id=27 len=4) from RADIUS server: EAP Success May 11 09:28:20 turris hostapd: wlan1: CTRL-EVENT-EAP-SUCCESS2 c4:d9:87:6c:38:01 May 11 09:28:20 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 IEEE 802.1X: Sending EAP Packet (identifier 27) May 11 09:28:20 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 WPA: sending 1/4 msg of 4-Way Handshake May 11 09:28:20 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 WPA: received EAPOL-Key frame (2/4 Pairwise) May 11 09:28:20 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 WPA: sending 3/4 msg of 4-Way Handshake May 11 09:28:20 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 WPA: received EAPOL-Key frame (4/4 Pairwise) May 11 09:28:20 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 WPA: pairwise key handshake completed (RSN) May 11 09:28:20 turris hostapd: wlan1: AP-STA-CONNECTED c4:d9:87:6c:38:01 May 11 09:28:20 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 IEEE 802.1X: authorizing port May 11 09:28:20 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 RADIUS: starting accounting session 0C7AC96B17442FD4 May 11 09:28:20 turris hostapd: wlan1: RADIUS Sending RADIUS message to accounting server May 11 09:28:20 turris hostapd: wlan1: RADIUS Next RADIUS client retransmit in 3 seconds May 11 09:28:20 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 IEEE 802.1X: authenticated - EAP type: 21 (TTLS) May 11 09:28:20 turris hostapd: wlan1: RADIUS Received 20 bytes from RADIUS server May 11 09:28:20 turris hostapd: wlan1: RADIUS Received RADIUS message May 11 09:28:20 turris hostapd: wlan1: STA c4:d9:87:6c:38:01 RADIUS: Received RADIUS packet matched with a pending request, round trip time 0.00 sec Jouni, I think this is bug in hostapd's 802.1X code. Function ieee802_1x_receive_auth() skips whole processing of 802.1X path when receives RADIUS_CODE_ACCESS_ACCEPT response and ap_sta_bind_vlan() function fails. The most suspicious part for me is why hostapd_drv_set_sta_vlan() function returns zero when hostapd driver does not support set_sta_vlan() function, but returns -ENOTSUP (or -ENOTSUPP) when kernel driver does not support this functionality. And also why this code path is ignored when hostapd is configured with CONFIG_NO_VLAN compile time option. Do you have any suggestions how to make AP working in WPA-EAP/802.1x mode for cards without NL80211_CMD_SET_STATION command? I would like to avoid having custom hostapd patch (like one above) and have ability to use upstream unpatched hostapd daemon. [1] - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/errno.h diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c index 93f1f0c20..9059162a8 100644 --- a/src/ap/sta_info.c +++ b/src/ap/sta_info.c @@ -1092,6 +1092,10 @@ skip_counting: hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, HOSTAPD_LEVEL_DEBUG, "could not bind the STA " "entry to vlan_id=%d", sta->vlan_id); + /* Ignore error when driver does not support setting vlan + * and we were not requested to set non-zero vlan id */ + if (ret == -ENOTSUP && sta->vlan_id == 0) + ret = 0; } /* During 1x reauth, if the vlan id changes, then remove the old id. */ diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index d48f8cb76..0906508d4 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -6848,6 +6848,8 @@ static int i802_set_sta_vlan(struct i802_bss *bss, const u8 *addr, ret = send_and_recv_msgs(drv, msg, NULL, NULL); if (ret < 0) { + if (ret == -524) /* 524 - Linux internal ENOTSUPP (double PP) */ + ret = -ENOTSUP; wpa_printf(MSG_ERROR, "nl80211: NL80211_ATTR_STA_VLAN (addr=" MACSTR " ifname=%s vlan_id=%d) failed: %d (%s)", MAC2STR(addr), ifname, vlan_id, ret,