Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1307657pxk; Mon, 31 Aug 2020 15:58:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGHaJrzp+bbQQwtg8BngqKnhX8+U5IhkoJIpK02MHhObL9mN4RF/RyRLj9fI0QxQtJ6Xoo X-Received: by 2002:aa7:dd94:: with SMTP id g20mr3076759edv.238.1598914683333; Mon, 31 Aug 2020 15:58:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598914683; cv=none; d=google.com; s=arc-20160816; b=n6F4LOY9Xr2DCD/gRag7TeYTpiwT4vOe+TKUnBzeAxc/nLZL2MTf9hzcHJTOa9EN53 dV2sN9RsDQe3+LTmObUSE+u/g4oDyaGIp1yx0uaQB9mhTz1HmBxp6US/Ps70up5R1kFY BktYnV7E1yfTEGx+o3UcuJldjFlD3OHySBFnUSGKFIk+3IjYlihhLkDvZeDZPFAYhnSk yEBD+xCSnUREpENK2j4/OZNTwyJq8csbNKH1f/rtC+dvX6BKwoavrACei98qLMpLmpwn xM57ke+lU85OH9+cpeYlTX5vfbZ1165XY12M1obGFmDq2ZaBNOiQI3NLMI2dl2/A6Lg9 /l/w== 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=oo/OFOHv2tIMYkUl3hxQ67UtF0SVzRhhu9M2rayRxDk=; b=T9LOmoc/stadkZpZNqXOvl2dg4T46Uz8yLJlL8YpsYJuYCMLebr1BCxqC4WsI3KcMt +zk7PHAtOHkpRF8f1z0ayunsdl/igswnMCnXEW0DBG/1m1+19U7pWIdz50bI/jOUwEJ5 2vE76DPO+ArTLTgTxgmTev2rlmOJLybYUOZ8iK8/6cQSb5F1jMTbHvn4czUAZoO9/7ND vpSRCBGBRQ5MBnGbojT6CuURs0H65y9P/Zhxbrf29wxS6CVorBRNEG3z04Rp3L4kgy8K AfZqbINQoYAY+JkSYV3cvjFPG0gzqZNoeh+RTe4TLdBWTaUyz2LioTRWpms8KQ3S3fHm Tfow== 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 y1si5780440edt.595.2020.08.31.15.57.39; Mon, 31 Aug 2020 15:58:03 -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 S1729552AbgHaU4O (ORCPT + 99 others); Mon, 31 Aug 2020 16:56:14 -0400 Received: from mail.adapt-ip.com ([173.164.178.19]:52210 "EHLO web.adapt-ip.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729485AbgHaU4N (ORCPT ); Mon, 31 Aug 2020 16:56:13 -0400 Received: from localhost (localhost [127.0.0.1]) by web.adapt-ip.com (Postfix) with ESMTP id 51DAC4F8F09; Mon, 31 Aug 2020 20:56:13 +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 kxkuQSDrrqZr; Mon, 31 Aug 2020 20:56:10 +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 94E744F8D69; Mon, 31 Aug 2020 20:56:06 +0000 (UTC) From: Thomas Pedersen To: Johannes Berg Cc: linux-wireless , Thomas Pedersen Subject: [PATCH v2 04/22] nl80211: correctly validate S1G beacon head Date: Mon, 31 Aug 2020 13:55:42 -0700 Message-Id: <20200831205600.21058-5-thomas@adapt-ip.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200831205600.21058-1-thomas@adapt-ip.com> References: <20200831205600.21058-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 7da4d84bcc1a..3bf595c828db 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 4a9ff9ef513f..49e7c0cbbf62 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -399,6 +399,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