Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp4889219pjb; Mon, 27 Jul 2020 07:40:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyumWYZFcyF046nrx2rAJBB9v5PoxIvanBQMgYsIg9E1O8lm5Ac/pw/Px8K1HGg8BIEgYYx X-Received: by 2002:a17:906:3282:: with SMTP id 2mr13160095ejw.11.1595860835382; Mon, 27 Jul 2020 07:40:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595860835; cv=none; d=google.com; s=arc-20160816; b=tct63KVsqvFn/Lh1wV59/WKPu8hZRhkz7k06V6/VZDQWQ257uEBPl9hvWC9SCtUUaj yYaUD7BhAbYVjBGllATrhPi++c4mrsOT4ueNKNOaCafEqGDS19JeGtMwD+aC/JjBooFK ktGQf/p00hK8K9GVJAZUeIQI/M82+zmA3ANZU0g7m1dJXoJHnobt1S5k2zeRK6Gv1r5U BeAofx69o4nDSf/jcEZpsYdfKd/7TZfaRLsffO5Kk+SoVW8R/ia+jm/OrolQU+z+99RH PNkAFt8STJtiT/Sr/fUc0cZC0SeUOMhq9ZZ5Lsc1/cnnBjTw7FzvYgs9ro/xkwqHC6kv xEWA== 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=03nrt9CW7E+r46br1yBCmSl2i4/WzOS7QjCcHzGWSOM=; b=HElY0uCtj0xUdU8hbVBqcedGJ2JBBQclRMRUplUAb7kBjojsguoLyMGPk3K3YnGkO1 tPzKksOIpreeqc31Mj669xvfyACkksuH23/lsUPOrfdD6rHpUIobhXfJaAuQZe4HhCo7 cqUXdCEcEaLX95JHa9F0A4lu9hM07bco/Ysa1g0fwwC+ulB3PD2GgZXD7vOqhBYX8fMm CTXuZMGkPyepVMMqzlN8vHb3BXgYmj6PfZB3ppEPn+ORrgSP6Dgz1L/29/eDiLqBTzKB MAJinJXllAX+IY38Oriu/72G5t2WL1rL3c3LetfxvBCWzfJGaseFh4yRDLeUeIkBv8J9 DENA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=t32iJKlF; 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 qp2si5958092ejb.598.2020.07.27.07.40.13; Mon, 27 Jul 2020 07:40:35 -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=t32iJKlF; 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 S1729784AbgG0OKM (ORCPT + 99 others); Mon, 27 Jul 2020 10:10:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:60982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729775AbgG0OKK (ORCPT ); Mon, 27 Jul 2020 10:10:10 -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 4390F20838; Mon, 27 Jul 2020 14:10:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1595859009; bh=yOHQNzrKgO5dGVzNFGwRdnu5BdnGHjIkXX7aoTeoJXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t32iJKlFmO5TvgI8a1wfQ4JEdKHnt2VkL5uPg9pTvfZsCVsY2WlgtI3gAN/LsJz4q 8zb7+d9FVAy/qwcl/jwybufWmcyZhTjSRaIUotbQiUu17DRnBz1MCuFzH/OVrqAFfY vkATBqCXGIVH0maaulqDVI9B8kzbN31hTG25fM+4= 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 4.19 05/86] mac80211: allow rx of mesh eapol frames with default rx key Date: Mon, 27 Jul 2020 16:03:39 +0200 Message-Id: <20200727134914.615975164@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200727134914.312934924@linuxfoundation.org> References: <20200727134914.312934924@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 c17e148e06e71..5e56719f999c4 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2230,6 +2230,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); @@ -2240,6 +2241,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