Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4885120pjb; Mon, 27 Jul 2020 07:34:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycsAK8TUNZ60OdSIPHK8PaBs28dspf0e9S5KFth5fZSZ+rq9VoLpoDWpw5lXANTAUiJ67D X-Received: by 2002:a17:906:f181:: with SMTP id gs1mr22158420ejb.293.1595860489195; Mon, 27 Jul 2020 07:34:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595860489; cv=none; d=google.com; s=arc-20160816; b=InfAynFY6BqFO+YbsFMqk+A3O+gk0E7LBTySEPUfdK+OcY42TNrmjqJRKKWV0AwqS1 YjMv8rLroJmksGkmFFRUG5ndmW4O7VgzFgxB0yo8WBnZnTL3rIqJsFwbfvxmnAjmg0LC 8vwiuTkLb6ta6F3akyTm42LjiVwWySt8CuwhYxBcycViL8xjQ5jBDWEI4aWa6fGA4G2X BtUS8DIPYULWp0O95Gv99nTVGD44XnU6irlPG8SqjUpBKslEXq2NogSaIT7Xq12S40Qg 2C2KoWsPVMPPYi1oGljq8BvCBjWwGnfQNG+HNLDj6jtcr8OiH6bwrVGp0quJIpVnllAc 42YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vPNJw3Qwx2k2nh/k9LelJ8/6LfPqQCF5qi4mxliHFhM=; b=YYUlBX8x+ZcCziJZcr0wXxZswi75U0r7k/VuCuyDlf8n/K00R6TPD0M6P08kd0TFDT ao2jgXiHPbG8L9dQQi2P0W/sG9dIKy+11IYhinwYMUJjikkDa+dfBSC+7bqQgWANCUYa /P7Ct6SGVvsPO4HJmdCLLgWuowZ0D4HN9bSkUoEnQe2P6TYkMVDroPEGHzE1Y3wnD/IE gxk9knJYUBDhsVzu5Pu5R1gCVSCrugpPr9mm4Kbk1zHANeMv2OjkuGtMMsrCeZKNLeN8 GKXRAFfsmONCACOX6omGXLGs13tOVWC9UdNRrDAhGZbFfeTK1HeLKr8dsk9mdMi0QgTK BGmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xQbZinNu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si5721868ede.534.2020.07.27.07.34.27; Mon, 27 Jul 2020 07:34:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xQbZinNu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732832AbgG0OcP (ORCPT + 99 others); Mon, 27 Jul 2020 10:32:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:47376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731390AbgG0OTZ (ORCPT ); Mon, 27 Jul 2020 10:19:25 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 B0E022075A; Mon, 27 Jul 2020 14:19:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859564; bh=10DbsIHggpfnX/L/cuS6NGvTsPwVjqJzSZhttOZm9R8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xQbZinNuZKfBuchJqmF4rNdRxUBghLnhgGCuN5N349+wVBQUFteTc4ovVzHSHo/6F lLCvhCvUo5PRav7a1ilCYshPNo4knVahRcdi5j1T6s8mUfdF5gbH4pWYgaUDLuhPIg DfROaThjXrFZ2zYchbm722wNqJGfE0pHBrZqjn8E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Markus Theil , Johannes Berg , Sasha Levin Subject: [PATCH 5.7 006/179] mac80211: allow rx of mesh eapol frames with default rx key Date: Mon, 27 Jul 2020 16:03:01 +0200 Message-Id: <20200727134932.981087761@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134932.659499757@linuxfoundation.org> References: <20200727134932.659499757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Theil [ Upstream commit 0b467b63870d9c05c81456aa9bfee894ab2db3b6 ] Without this patch, eapol frames cannot be received in mesh mode, when 802.1X should be used. Initially only a MGTK is defined, which is found and set as rx->key, when there are no other keys set. ieee80211_drop_unencrypted would then drop these eapol frames, as they are data frames without encryption and there exists some rx->key. Fix this by differentiating between mesh eapol frames and other data frames with existing rx->key. Allow mesh mesh eapol frames only if they are for our vif address. With this patch in-place, ieee80211_rx_h_mesh_fwding continues after the ieee80211_drop_unencrypted check and notices, that these eapol frames have to be delivered locally, as they should. Signed-off-by: Markus Theil Link: https://lore.kernel.org/r/20200625104214.50319-1-markus.theil@tu-ilmenau.de [small code cleanups] Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- net/mac80211/rx.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 91a13aee43784..961f37c0701bc 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2357,6 +2357,7 @@ static int ieee80211_802_1x_port_control(struct ieee80211_rx_data *rx) static int ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc) { + struct ieee80211_hdr *hdr = (void *)rx->skb->data; struct sk_buff *skb = rx->skb; struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); @@ -2367,6 +2368,31 @@ static int ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc) if (status->flag & RX_FLAG_DECRYPTED) return 0; + /* check mesh EAPOL frames first */ + if (unlikely(rx->sta && ieee80211_vif_is_mesh(&rx->sdata->vif) && + ieee80211_is_data(fc))) { + struct ieee80211s_hdr *mesh_hdr; + u16 hdr_len = ieee80211_hdrlen(fc); + u16 ethertype_offset; + __be16 ethertype; + + if (!ether_addr_equal(hdr->addr1, rx->sdata->vif.addr)) + goto drop_check; + + /* make sure fixed part of mesh header is there, also checks skb len */ + if (!pskb_may_pull(rx->skb, hdr_len + 6)) + goto drop_check; + + mesh_hdr = (struct ieee80211s_hdr *)(skb->data + hdr_len); + ethertype_offset = hdr_len + ieee80211_get_mesh_hdrlen(mesh_hdr) + + sizeof(rfc1042_header); + + if (skb_copy_bits(rx->skb, ethertype_offset, ðertype, 2) == 0 && + ethertype == rx->sdata->control_port_protocol) + return 0; + } + +drop_check: /* Drop unencrypted frames if key is set. */ if (unlikely(!ieee80211_has_protected(fc) && !ieee80211_is_any_nullfunc(fc) && -- 2.25.1