Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp769576pxa; Thu, 27 Aug 2020 15:34:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycjBVekUwil/iw2RS5U3TEQAjnjxSDxGvsNbViuCfOnYCnxZTqfOD+4ohKVSOqadHaBGZr X-Received: by 2002:aa7:cf19:: with SMTP id a25mr21289925edy.67.1598567649702; Thu, 27 Aug 2020 15:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598567649; cv=none; d=google.com; s=arc-20160816; b=D9lAg6h7vECgO8145aGdOxXyCXiwbOYPziO7VEYGl+dZKUebEU13uy5dHbx/ev4wYi dqcZ7d0ohG/1s3qZqnODx49a76hrjuWCt1UGaWrbJAXyL7bYftIhK/uK0Kr2dkW26Gji TbDn/x89meQLr0Bpl1rD7CIw1WJ8NgOtJr7NrtZI9/Ty+OedeUNIWlpnHu5LqoJVgeMs JiSw9MMSlz5FLQPtyRQB3uxgicmezQk69yRRcmT/34sYLu6xf0tkr7byhIz+LhF19rsq DSxbGIV4KlxOaQkj5Iryj+li+8WwV4Xti/rbr7kyTAhQ07tN+g9patX4x88QG+1B5kbG yqOA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=RrgG0D0AO0DEc0B79H+kUlw/SSx9/r4UQJ4IhW6xZF4=; b=XxmCNyQmTYNkCF7GoWjLfqoYIh5GVofLRpIWdmH4piYgbdOaIsFbv/VlBan/arQaGK 3perwSWte7uNnFdVvQPMYVAVkW6jjxeRO+Yv8t0KKls4nxIpFaEsfqo9kcUJHsGfBT9B 3ETy4Qd7lrXUKfxV242Ni7ll1mGGrkI6KBqP/wgn6E8lg1Kl2VVk/8IRJZcr3Is4HhY8 DB0Qfy1mEJgTj/vCWZany81w24qYLYCx6J2bt/Nxaj0Bp33QYxQmdXpMFl1ORQpDWVdi uuddlTfLIOS5fdFzF6V6t/dLFFaNoDiL8LNZHVjNBIhozqXo1TTK2F55DzevAddcskE3 pLpg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-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 lm17si2272890ejb.464.2020.08.27.15.33.45; Thu, 27 Aug 2020 15:34:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727992AbgH0WdU (ORCPT + 99 others); Thu, 27 Aug 2020 18:33:20 -0400 Received: from mail.adapt-ip.com ([173.164.178.19]:50384 "EHLO web.adapt-ip.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726953AbgH0WdR (ORCPT ); Thu, 27 Aug 2020 18:33:17 -0400 Received: from localhost (localhost [127.0.0.1]) by web.adapt-ip.com (Postfix) with ESMTP id 87F104F829A; Thu, 27 Aug 2020 22:33:16 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at web.adapt-ip.com Received: from web.adapt-ip.com ([127.0.0.1]) by localhost (web.adapt-ip.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id El1oB4XhOKJZ; Thu, 27 Aug 2020 22:33:13 +0000 (UTC) Received: from atlas.campbell.adapt-ip.com (gateway.adapt-ip.com [173.164.178.20]) (Authenticated sender: thomas@adapt-ip.com) by web.adapt-ip.com (Postfix) with ESMTPSA id 94F1C4F80CE; Thu, 27 Aug 2020 22:33:07 +0000 (UTC) From: Thomas Pedersen To: Johannes Berg Cc: linux-wireless , Thomas Pedersen Subject: [PATCH 04/22] nl80211: correctly validate S1G beacon head Date: Thu, 27 Aug 2020 15:32:46 -0700 Message-Id: <20200827223304.16155-5-thomas@adapt-ip.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200827223304.16155-1-thomas@adapt-ip.com> References: <20200827223304.16155-1-thomas@adapt-ip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The S1G beacon has a different header size than regular beacons, so adjust the beacon head validator. Signed-off-by: Thomas Pedersen --- net/wireless/nl80211.c | 16 +++++++++++++--- net/wireless/util.c | 5 +++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index a57872708108..c5950d154d66 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -209,14 +209,24 @@ static int validate_beacon_head(const struct nlattr *attr, unsigned int len = nla_len(attr); const struct element *elem; const struct ieee80211_mgmt *mgmt = (void *)data; - unsigned int fixedlen = offsetof(struct ieee80211_mgmt, - u.beacon.variable); + bool s1g_bcn = ieee80211_is_s1g_beacon(mgmt->frame_control); + unsigned int fixedlen, hdrlen; + + if (s1g_bcn) { + fixedlen = offsetof(struct ieee80211_ext, + u.s1g_beacon.variable); + hdrlen = offsetof(struct ieee80211_ext, u.s1g_beacon); + } else { + fixedlen = offsetof(struct ieee80211_mgmt, + u.beacon.variable); + hdrlen = offsetof(struct ieee80211_mgmt, u.beacon); + } if (len < fixedlen) goto err; if (ieee80211_hdrlen(mgmt->frame_control) != - offsetof(struct ieee80211_mgmt, u.beacon)) + hdrlen) goto err; data += fixedlen; diff --git a/net/wireless/util.c b/net/wireless/util.c index dfad1c0f57ad..383278c05a75 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -397,6 +397,11 @@ unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc) { unsigned int hdrlen = 24; + if (ieee80211_is_ext(fc)) { + hdrlen = 4; + goto out; + } + if (ieee80211_is_data(fc)) { if (ieee80211_has_a4(fc)) hdrlen = 30; -- 2.20.1