From patchwork Tue Oct 27 13:55:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 312682 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62C71C55179 for ; Tue, 27 Oct 2020 15:13:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2CA4A21D41 for ; Tue, 27 Oct 2020 15:13:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811627; bh=0Si8sYFictuo/anSAUU6Sehfcghwz4mryykeuuymkMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=GcHXUPMHz70Ty7zQGEAM3nDLr8smlREFj9HdcYEz4fTMkxw+Xhco3Q4caF0km+cmp 0xy4GL6/27FOMoXv44+6onqlvK1w4FCd9hEAOw1Ri96TR7UqJ2pAU3fzd13S3k4sQn MdMzah4E39nQcDnvKDVMvFUAxrzP4piLNFp8dTO8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1794812AbgJ0PNp (ORCPT ); Tue, 27 Oct 2020 11:13:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:50570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1794806AbgJ0PNn (ORCPT ); Tue, 27 Oct 2020 11:13:43 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 AC04920728; Tue, 27 Oct 2020 15:13:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603811622; bh=0Si8sYFictuo/anSAUU6Sehfcghwz4mryykeuuymkMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wuo+AquBJ+NHP/k5UiUMkmr8vsPyekCVxFxovOb2OgCsdxo4mcJjLnirrs9m4xj2s s5Wy+H4arAu98YMqG8+sTRST0DmFviZTujPZXbNAthKSbsCQ+RrDnHsN5skvYKvzWU F92r3yJqy4wvngasDHzZoOTtkZFm9LuuJzcqWelg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Pedersen , Johannes Berg , Sasha Levin Subject: [PATCH 5.8 559/633] mac80211: handle lack of sband->bitrates in rates Date: Tue, 27 Oct 2020 14:55:02 +0100 Message-Id: <20201027135549.029851608@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Thomas Pedersen [ Upstream commit 8b783d104e7f40684333d2ec155fac39219beb2f ] 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 Link: https://lore.kernel.org/r/20201005164522.18069-1-thomas@adapt-ip.com Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- 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 1079a07e43e49..d74cfec685477 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 05e966f1609e2..b93916c382cdb 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; + brate = sband->bitrates[rate_idx].bitrate; if (rinfo->bw == RATE_INFO_BW_5) shift = 2;