From patchwork Tue Jun 25 05:18:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasanthakumar Thiagarajan X-Patchwork-Id: 11014709 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA082924 for ; Tue, 25 Jun 2019 05:18:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 996A628957 for ; Tue, 25 Jun 2019 05:18:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D63928ABA; Tue, 25 Jun 2019 05:18:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 301BE28957 for ; Tue, 25 Jun 2019 05:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=7hBSP0q/X/lO8kBN9TZoy74yc1D8ozx6tmvy1uVwEQk=; b=qgzSalwxe/Tyeq HPyeRltKA0PW5s8SdVa1zjvMYjRB59Q9xjxf74G07JkZHgUkN0AwTihuKp8tkK8QO0wZZn/hy8bcE iOd/G3KQWh/vBOeKTtt45x/7s01Zr/YBS8eNF7czXMMrV4+tA2lXJJIw9gcYQV+M7il8TFrFVhNIc oWTBdcIs5riKyZbrwe+p90Hdt9l7OVrzgpYcOdtlB55IQ6F1chzp12IyfQut3FRzCANyEbLXoJmBO 4gWvL7swktSncaIJ07gg7a6pj+X6GpXuGSXDricHdmofsETrKeKMKVpFsMl0GndX+So3FDJid7Pj7 7vF2vUO1Rl7kURwQZUuQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hfdqx-00073y-Ef; Tue, 25 Jun 2019 05:18:47 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hfdqu-00073f-Sa for ath11k@lists.infradead.org; Tue, 25 Jun 2019 05:18:46 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id EC4D36070D; Tue, 25 Jun 2019 05:18:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1561439923; bh=RohjkJZZxYkfhVm7HDVRodg4l73sBqFzQTKCBPSRhoc=; h=From:To:Subject:Date:From; b=H2vNIHG05bDSkX5xErGzhB5k74saODNitdn8rKd7bgwcB3LUY0p0aplIP3ZAbiYOl hhBvLho6sfum+5SE6pYJT7JluZJPNXrOtpeSeaixO6F+LClMKNpJSIZKSRPv/LbKDz FF770DazOCECFOlQlUcXq7N1KyVwNP5oyOgPvq5M= Received: from vasanth-lnx.qca.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vthiagar@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 22CB860709 for ; Tue, 25 Jun 2019 05:18:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1561439923; bh=RohjkJZZxYkfhVm7HDVRodg4l73sBqFzQTKCBPSRhoc=; h=From:To:Subject:Date:From; b=H2vNIHG05bDSkX5xErGzhB5k74saODNitdn8rKd7bgwcB3LUY0p0aplIP3ZAbiYOl hhBvLho6sfum+5SE6pYJT7JluZJPNXrOtpeSeaixO6F+LClMKNpJSIZKSRPv/LbKDz FF770DazOCECFOlQlUcXq7N1KyVwNP5oyOgPvq5M= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 22CB860709 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vthiagar@codeaurora.org From: Vasanthakumar Thiagarajan To: ath11k@lists.infradead.org Subject: [PATCH] ath11k: Fix NULL pointer dereference in sta_statistics() callback Date: Tue, 25 Jun 2019 10:48:18 +0530 Message-Id: <1561439898-24320-1-git-send-email-vthiagar@codeaurora.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190624_221844_964997_38A616A9 X-CRM114-Status: GOOD ( 13.16 ) X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "ath11k" Errors-To: ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP It is possible to dereference NULL arsta->rx_stats memory to get rssi information after STA disconnection. Instead of dereferencing a memory which is allocated/freed in sta_state() callback, add a new member for rssi in arsta itself and use it in sta_statistics(). ath11k c000000.wifi1: Station 8c:fd:f0:0a:90:f3 moved to disassociated state ath11k c000000.wifi1: Removed peer: 8c:fd:f0:0a:90:f3 for VDEV: 0 Unable to handle kernel NULL pointer dereference at virtual address 00000218 Internal error: Oops: 5 [#1] PREEMPT SMP ARM PC is at ath11k_sta_statistics+0x90/0xa0 [ath11k] LR is at sta_set_sinfo+0xb8/0xcb4 [mac80211] Fixes: ecdb3adeda5c ("ath11k: Fix Rx signal strength reporting") Reported-by: Pradeep Kumar Chitrapu Signed-off-by: Vasanthakumar Thiagarajan --- drivers/net/wireless/ath/ath11k/core.h | 2 +- drivers/net/wireless/ath/ath11k/dp_rx.c | 2 +- drivers/net/wireless/ath/ath11k/mac.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index 65c1a6d..ff73ccf 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -237,7 +237,6 @@ struct ath11k_rx_peer_stats { u64 tid_count[IEEE80211_NUM_TIDS + 1]; u64 pream_cnt[HAL_RX_PREAMBLE_MAX]; u64 reception_type[HAL_RX_RECEPTION_TYPE_MAX]; - u32 rssi_comb; }; #define ATH11K_HE_MCS_NUM 12 @@ -330,6 +329,7 @@ struct ath11k_sta { struct rate_info txrate; struct rate_info last_txrate; u64 rx_duration; + u8 rssi_comb; struct ath11k_htt_tx_stats *tx_stats; struct ath11k_rx_peer_stats *rx_stats; }; diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index afe8399..0467753 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -2373,7 +2373,7 @@ static void ath11k_dp_rx_update_peer_stats(struct ath11k_sta *arsta, rx_stats->num_mpdu_fcs_ok += ppdu_info->num_mpdu_fcs_ok; rx_stats->num_mpdu_fcs_err += ppdu_info->num_mpdu_fcs_err; - rx_stats->rssi_comb = ppdu_info->rssi_comb; + arsta->rssi_comb = ppdu_info->rssi_comb; } static struct sk_buff *ath11k_dp_rx_alloc_mon_status_buf(struct ath11k_base *ab, diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 7a6c927..ada1dde 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -5110,7 +5110,7 @@ static void ath11k_sta_statistics(struct ieee80211_hw *hw, sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); /* TODO: Use real NF instead of default one. */ - sinfo->signal = arsta->rx_stats->rssi_comb + ATH11K_DEFAULT_NOISE_FLOOR; + sinfo->signal = arsta->rssi_comb + ATH11K_DEFAULT_NOISE_FLOOR; } static const struct ieee80211_ops ath11k_ops = {