Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2928766pxk; Mon, 28 Sep 2020 04:09:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+Rz16die4gKcq5zIoKt3nvuj2xKp5TRoIdWTsZDxdEnlm78XUD/YY0eeg3tGTKva8AuJN X-Received: by 2002:a05:6402:d09:: with SMTP id eb9mr1052334edb.219.1601291362547; Mon, 28 Sep 2020 04:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601291362; cv=none; d=google.com; s=arc-20160816; b=vxtYvyN1m/YdO0A2LhBvutqApnqDMX8I3lZFoODVDeT2ws5Ft1WHEdpF7od0atOc/I tZs5TyfKpGEC4cXdhRDjHRDdLL2zgZsU5q1Igki9hafJxd0mhMGiydG5jb/KWs8YKtEi JpwPLoJaLMOtwqLa01t5jGxLRQPHF/6/F3vw/vuQctBKa2S/3c0nt1qfXJ2WEM+1tIwe JalYjDIvaWByHg8nRI9KrLC0mDIG+09meXRL122Kvh6bsy7peFCkVrxFPX8K6+XPe7cm 0DrlAAfQA2FxqjF2DaSDyvUKaU1M21wrdEaspJT4De1CH+JEAX2Yy+CNmvpPfEzHUreH 7CrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=AAmXmZ1O1Q3zxfngzKlAURc7W2bH8z/efZ9n+MT7Zlc=; b=BcgZVeM+u4XIjIIaUcyWTHDVVi+OJdj280oBkJKXWWP8x0/UL+qMa2XLfRiJm7Drs5 PXv6RMFCY6CIa6AUKY3zyjxxeaqRLr6z2rnTl4VnxrO/Rs+7ZoiL3GO8DBZqfhbnDoBA Yxq7Q+Wnnh6wk3dtMPcYkF+KHLCZJf/1NmjB0ZRhoemCqbubBb6ptG7qaEWcagojqPi5 VatyfAY7vJsCAApIUVAEaQK2nW5wpOdydRnhGt+21hI+NROZfYC19WvsWS40+5NxFGre TArDHg/vZr00tyYgbXYbnqNrG0ExbLjU+ixgxXVFM66cJyogW/keRSxVnMs5c4D7Veb/ cNZw== 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 q16si407080ejt.139.2020.09.28.04.08.57; Mon, 28 Sep 2020 04:09:22 -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 S1726564AbgI1LHD (ORCPT + 99 others); Mon, 28 Sep 2020 07:07:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726526AbgI1LHD (ORCPT ); Mon, 28 Sep 2020 07:07:03 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45A6BC061755 for ; Mon, 28 Sep 2020 04:07:03 -0700 (PDT) Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1kMqzl-00CRWo-Ih; Mon, 28 Sep 2020 13:07:01 +0200 From: Johannes Berg To: linux-wireless@vger.kernel.org Cc: Johannes Berg , Martin Willi Subject: [PATCH] nl80211: reduce non-split wiphy dump size Date: Mon, 28 Sep 2020 13:06:56 +0200 Message-Id: <20200928130655.53bce7873164.I71f06c9a221cd0630429a1a56eeae68a13beca61@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Johannes Berg When wiphy dumps cannot be split, such as in events or with older userspace that doesn't support it, the size can today be too big. Reduce it, by doing two things: 1) remove data that couldn't have been present before the split capability was introduced since it's new, such as HE capabilities 2) as suggested by Martin Willi, remove management frame subtypes from the split dumps, as just (1) isn't even enough due to other new code capabilities. This is fine as old consumers (really just wpa_supplicant) didn't check this data before they got support for split dumps. Reported-by: Martin Willi Suggested-by: Martin Willi Signed-off-by: Johannes Berg --- net/wireless/nl80211.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 935ff973412a..9633b7af04c4 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -926,6 +926,8 @@ static int nl80211_msg_put_channel(struct sk_buff *msg, struct wiphy *wiphy, if (!large && chan->flags & (IEEE80211_CHAN_NO_10MHZ | IEEE80211_CHAN_NO_20MHZ)) return 0; + if (!large && chan->freq_offset) + return 0; if (nla_put_u32(msg, NL80211_FREQUENCY_ATTR_FREQ, chan->center_freq)) @@ -1603,7 +1605,8 @@ nl80211_send_iftype_data(struct sk_buff *msg, } static int nl80211_send_band_rateinfo(struct sk_buff *msg, - struct ieee80211_supported_band *sband) + struct ieee80211_supported_band *sband, + bool large) { struct nlattr *nl_rates, *nl_rate; struct ieee80211_rate *rate; @@ -1631,7 +1634,7 @@ static int nl80211_send_band_rateinfo(struct sk_buff *msg, sband->vht_cap.cap))) return -ENOBUFS; - if (sband->n_iftype_data) { + if (large && sband->n_iftype_data) { struct nlattr *nl_iftype_data = nla_nest_start_noflag(msg, NL80211_BAND_ATTR_IFTYPE_DATA); @@ -1659,7 +1662,7 @@ static int nl80211_send_band_rateinfo(struct sk_buff *msg, } /* add EDMG info */ - if (sband->edmg_cap.channels && + if (large && sband->edmg_cap.channels && (nla_put_u8(msg, NL80211_BAND_ATTR_EDMG_CHANNELS, sband->edmg_cap.channels) || nla_put_u8(msg, NL80211_BAND_ATTR_EDMG_BW_CONFIG, @@ -2077,13 +2080,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, nla_put_u16(msg, NL80211_ATTR_MAX_SCHED_SCAN_IE_LEN, rdev->wiphy.max_sched_scan_ie_len) || nla_put_u8(msg, NL80211_ATTR_MAX_MATCH_SETS, - rdev->wiphy.max_match_sets) || - nla_put_u32(msg, NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS, - rdev->wiphy.max_sched_scan_plans) || - nla_put_u32(msg, NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL, - rdev->wiphy.max_sched_scan_plan_interval) || - nla_put_u32(msg, NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS, - rdev->wiphy.max_sched_scan_plan_iterations)) + rdev->wiphy.max_match_sets)) goto nla_put_failure; if ((rdev->wiphy.flags & WIPHY_FLAG_IBSS_RSN) && @@ -2173,6 +2170,10 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, band < NUM_NL80211_BANDS; band++) { struct ieee80211_supported_band *sband; + /* omit higher bands for ancient software */ + if (band > NL80211_BAND_5GHZ && !state->split) + break; + sband = rdev->wiphy.bands[band]; if (!sband) @@ -2184,7 +2185,8 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, switch (state->chan_start) { case 0: - if (nl80211_send_band_rateinfo(msg, sband)) + if (nl80211_send_band_rateinfo(msg, sband, + state->split)) goto nla_put_failure; state->chan_start++; if (state->split) @@ -2286,8 +2288,6 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, nla_put_flag(msg, NL80211_ATTR_OFFCHANNEL_TX_OK)) goto nla_put_failure; - if (nl80211_send_mgmt_stypes(msg, mgmt_stypes)) - goto nla_put_failure; state->split_start++; if (state->split) break; @@ -2361,6 +2361,17 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, state->split_start = 0; break; case 9: + if (nl80211_send_mgmt_stypes(msg, mgmt_stypes)) + goto nla_put_failure; + + if (nla_put_u32(msg, NL80211_ATTR_MAX_NUM_SCHED_SCAN_PLANS, + rdev->wiphy.max_sched_scan_plans) || + nla_put_u32(msg, NL80211_ATTR_MAX_SCAN_PLAN_INTERVAL, + rdev->wiphy.max_sched_scan_plan_interval) || + nla_put_u32(msg, NL80211_ATTR_MAX_SCAN_PLAN_ITERATIONS, + rdev->wiphy.max_sched_scan_plan_iterations)) + goto nla_put_failure; + if (rdev->wiphy.extended_capabilities && (nla_put(msg, NL80211_ATTR_EXT_CAPA, rdev->wiphy.extended_capabilities_len, -- 2.26.2