Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1057703pxu; Thu, 8 Oct 2020 02:03:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6QizUURML8InlSpgf4L+PRmabFfwPnXIodDvEHpOCUt4ikXqZEMqod04kXxrN+kBqlmIW X-Received: by 2002:a17:906:395a:: with SMTP id g26mr6825755eje.147.1602147831328; Thu, 08 Oct 2020 02:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602147831; cv=none; d=google.com; s=arc-20160816; b=iKT+R6LfAXoiv7Itji0HS4cSS1t/VP2iO1eTtcfA96mPNd4l4RR7tnNP6wxW+V+WNB B+cfpFL05XwD07tpTxQosTWYZuSJYw2C4ibJKAWxeKXK2EwjER3XmWb6oVBzwqseOD64 pksZIPec0Tng5/fVOIq8xMjC758osisHnOUd9XSNuPnJ+MOewgLaNBgLyvwfrZoNK7Ok 3Kcquo0Br9kVfr4Jz8NuNoZI7vgZxvS821aPbqj3upT/MbgUwnAjN8RfeFJdkob53HGA mT9QCNoB3UAY9lZ4cccSPX6PiQgK1hPqwkhb4LFUJCkI6dF4Hdu0rq40xg0hBCDICw7m hAyQ== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=0+d1R4HlQ4HHzuGKWhBdKybIEzH01qjD8YBd3XQL7js=; b=oH5AzUjVhAjZfBCT/CADENuDiYkzjx6wL3fXdVQirKPCLhI2fQ0SC3y8nBiJR+1zFm Knx84dg8mQ0uH8EjkVbL4dDNMufGznajB2j3WVkgjvVB8qVl+Cr5ByaBeV76A7c3imGW iWOP3l9m4WxF57E+Beb22a/j1JOIELLyT022ZzH7bY/QD4epOaSOsmfeike5uXMa1xCj BDbfLfoUUUoWo9jBkWwXeAvIbP+NQHirOcN7Dez49dZduByHwfgdxDG8ywlMdUYxRrkq t/aWrrMNQwIoGHLFjKmlQagFQ68Hyb8AO1H1UHyKBME+V6koO7EDUlJx4NVPAX9ptHNt OIgA== 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 y9si3249081ejg.460.2020.10.08.02.03.15; Thu, 08 Oct 2020 02:03:51 -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 S1726276AbgJHIh1 (ORCPT + 99 others); Thu, 8 Oct 2020 04:37:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725616AbgJHIh1 (ORCPT ); Thu, 8 Oct 2020 04:37:27 -0400 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D736C061755 for ; Thu, 8 Oct 2020 01:37:27 -0700 (PDT) Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94) (envelope-from ) id 1kQRQS-001UUN-MQ; Thu, 08 Oct 2020 10:37:24 +0200 Message-ID: <961b6dc93de57cc292f30741bf6d9d7190a9de0a.camel@sipsolutions.net> Subject: Re: [PATCH v2 1/2] mac80211: handle lack of sband->bitrates in rates From: Johannes Berg To: Thomas Pedersen Cc: linux-wireless Date: Thu, 08 Oct 2020 10:37:13 +0200 In-Reply-To: <20201005164522.18069-1-thomas@adapt-ip.com> References: <20201005164522.18069-1-thomas@adapt-ip.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Mon, 2020-10-05 at 09:45 -0700, Thomas Pedersen wrote: > Even though a driver or mac80211 shouldn't produce a > legacy bitrate if sband->bitrates doesn't exist, don't > crash if that is the case either. > > This fixes a kernel panic if station dump is run before > last_rate can be updated with a data frame when > sband->bitrates is missing (eg. in S1G bands). > > Signed-off-by: Thomas Pedersen > > --- > > v2: > WARN_ON -> WARN_ON_ONCE (Ben) > --- > net/mac80211/cfg.c | 3 ++- > net/mac80211/sta_info.c | 4 ++++ > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c > index da70f174d629..eb52aafd9381 100644 > --- a/net/mac80211/cfg.c > +++ b/net/mac80211/cfg.c > @@ -709,7 +709,8 @@ void sta_set_rate_info_tx(struct sta_info *sta, > u16 brate; > > sband = ieee80211_get_sband(sta->sdata); > - if (sband) { > + WARN_ON_ONCE(sband && !sband->bitrates); > + if (sband && sband->bitrates) { > brate = sband->bitrates[rate->idx].bitrate; > rinfo->legacy = DIV_ROUND_UP(brate, 1 << shift); > } > diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c > index f2840d1d95cf..fb4f2b9b294f 100644 > --- a/net/mac80211/sta_info.c > +++ b/net/mac80211/sta_info.c > @@ -2122,6 +2122,10 @@ static void sta_stats_decode_rate(struct ieee80211_local *local, u32 rate, > int rate_idx = STA_STATS_GET(LEGACY_IDX, rate); > > sband = local->hw.wiphy->bands[band]; > + > + if (WARN_ON_ONCE(!sband->bitrates)) > + break; > + Given the premise described in the commit message, neither of these really seem right - why would we want to trigger a WARN_ON(_ONCE) if userspace requests the information that early? Should be silent IMHO? johannes