Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp4390332pxb; Wed, 20 Apr 2022 02:04:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjPRa2T1gpYrfm0HNCAoo2rOVezgekLxOihqYzmV7Y395NVVeyh8VVOyLMUO4XKLtDlsfo X-Received: by 2002:a63:f005:0:b0:3a3:ef7c:c8dd with SMTP id k5-20020a63f005000000b003a3ef7cc8ddmr18030451pgh.37.1650445484500; Wed, 20 Apr 2022 02:04:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650445484; cv=none; d=google.com; s=arc-20160816; b=0erKLRMNLTrrS+43Dx0n155K+nYP3S3uVips0pR99Wdqk3NTNfr6oWzmFKxcAbF6Hd vpV6Pv0Ojl8WnxccY+GLkr8Sqyuwfpxumf4j5LbwvSByYyApSEjIFavIMiFfplLSPT3C 1o7epIz19l16txlMorVHXPxpf193bszRoOGFul5Hqy1gogxEhdTNlBMNtfIh29gzDqHn XwsTDpJKXcmyzMboK3jr9RckPSILtSncG2jiV8+tMgvfEePbmql1tCx2uzfkvZcM7+ya A0FIv0c3gY0YJ9f20YC0Ac5xKJc8OBYxhP6Qk1jAx2Uw7l3g9uslWi9AjwzmiQpoYor+ Xj9A== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=5HTNovqDXz3PHENjxYg+FRYHhTyThJ+wQrenswBYmeU=; b=YWwGSNKK/2ay8nJ5RzYNvUvzFpzy7L4iGYAjAziuznF4WiGt/32fUR/isySebRRls5 weQud6b6+qPXN5uEEeR7P+UB11JbIBd9QbfiNFWrmBy5L12m7gqqSRpyvMERq2q4jpCk 9cm8C6wB47/SMwD2E6JPCNRiCp5QFv7WAe+mX+kRW4JN0SEcA/oadT0elB4tZ+e488bX h+8r40DR3XeyRkKpOThOr6L6kxXSpXJQLMW1Rs/rTAY54tvwcVaip/NNyf9Rwo1iomFF KwyelKYQVgxTYcPfFotQkF6/3+woyrk+MK+dfwuu6HKeYPqN6K6Qmo+YwtJKVcbnkYA8 rM7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JkGXa1Sk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a631b49000000b003aa635c5ff5si1790087pgm.596.2022.04.20.02.04.27; Wed, 20 Apr 2022 02:04:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JkGXa1Sk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241911AbiDRNNC (ORCPT + 99 others); Mon, 18 Apr 2022 09:13:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242264AbiDRM7p (ORCPT ); Mon, 18 Apr 2022 08:59:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4240420181; Mon, 18 Apr 2022 05:40:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BC8A4B80EC0; Mon, 18 Apr 2022 12:40:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E604C385A1; Mon, 18 Apr 2022 12:40:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650285629; bh=zfFhwuW+2QehhZz510GLnDsyoSabLcv+Oi0qhLXKq+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JkGXa1SktDPIybrOwKM20Lc9p2xy+pF3AjGSpqHIa0OYVdMRwAtclUSumDhpMfBTj TliWrIvPd2/2gI2di6V3OSWbg9jNd0bp0W+gm54XgcYkflldXpTHg3FrWReHfAP7+i WrflHcDtddHgR2hAT3vsLeDc8O/5sAIc8WLO+Dd0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Seiderer , =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , Kalle Valo Subject: [PATCH 5.10 078/105] ath9k: Fix usage of driver-private space in tx_info Date: Mon, 18 Apr 2022 14:13:20 +0200 Message-Id: <20220418121148.847148334@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121145.140991388@linuxfoundation.org> References: <20220418121145.140991388@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Toke Høiland-Jørgensen commit 5a6b06f5927c940fa44026695779c30b7536474c upstream. The ieee80211_tx_info_clear_status() helper also clears the rate counts and the driver-private part of struct ieee80211_tx_info, so using it breaks quite a few other things. So back out of using it, and instead define a ath-internal helper that only clears the area between the status_driver_data and the rates info. Combined with moving the ath_frame_info struct to status_driver_data, this avoids clearing anything we shouldn't be, and so we can keep the existing code for handling the rate information. While fixing this I also noticed that the setting of tx_info->status.rates[tx_rateindex].count on hardware underrun errors was always immediately overridden by the normal setting of the same fields, so rearrange the code so that the underrun detection actually takes effect. The new helper could be generalised to a 'memset_between()' helper, but leave it as a driver-internal helper for now since this needs to go to stable. Cc: stable@vger.kernel.org Reported-by: Peter Seiderer Fixes: 037250f0a45c ("ath9k: Properly clear TX status area before reporting to mac80211") Signed-off-by: Toke Høiland-Jørgensen Reviewed-by: Peter Seiderer Tested-by: Peter Seiderer Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20220404204800.2681133-1-toke@toke.dk Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/ath/ath9k/main.c | 2 +- drivers/net/wireless/ath/ath9k/xmit.c | 30 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 11 deletions(-) --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -839,7 +839,7 @@ static bool ath9k_txq_list_has_key(struc continue; txinfo = IEEE80211_SKB_CB(bf->bf_mpdu); - fi = (struct ath_frame_info *)&txinfo->rate_driver_data[0]; + fi = (struct ath_frame_info *)&txinfo->status.status_driver_data[0]; if (fi->keyix == keyix) return true; } --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -141,8 +141,8 @@ static struct ath_frame_info *get_frame_ { struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); BUILD_BUG_ON(sizeof(struct ath_frame_info) > - sizeof(tx_info->rate_driver_data)); - return (struct ath_frame_info *) &tx_info->rate_driver_data[0]; + sizeof(tx_info->status.status_driver_data)); + return (struct ath_frame_info *) &tx_info->status.status_driver_data[0]; } static void ath_send_bar(struct ath_atx_tid *tid, u16 seqno) @@ -2501,6 +2501,16 @@ skip_tx_complete: spin_unlock_irqrestore(&sc->tx.txbuflock, flags); } +static void ath_clear_tx_status(struct ieee80211_tx_info *tx_info) +{ + void *ptr = &tx_info->status; + + memset(ptr + sizeof(tx_info->status.rates), 0, + sizeof(tx_info->status) - + sizeof(tx_info->status.rates) - + sizeof(tx_info->status.status_driver_data)); +} + static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf, struct ath_tx_status *ts, int nframes, int nbad, int txok) @@ -2512,7 +2522,7 @@ static void ath_tx_rc_status(struct ath_ struct ath_hw *ah = sc->sc_ah; u8 i, tx_rateindex; - ieee80211_tx_info_clear_status(tx_info); + ath_clear_tx_status(tx_info); if (txok) tx_info->status.ack_signal = ts->ts_rssi; @@ -2528,6 +2538,13 @@ static void ath_tx_rc_status(struct ath_ tx_info->status.ampdu_len = nframes; tx_info->status.ampdu_ack_len = nframes - nbad; + tx_info->status.rates[tx_rateindex].count = ts->ts_longretry + 1; + + for (i = tx_rateindex + 1; i < hw->max_rates; i++) { + tx_info->status.rates[i].count = 0; + tx_info->status.rates[i].idx = -1; + } + if ((ts->ts_status & ATH9K_TXERR_FILT) == 0 && (tx_info->flags & IEEE80211_TX_CTL_NO_ACK) == 0) { /* @@ -2549,13 +2566,6 @@ static void ath_tx_rc_status(struct ath_ tx_info->status.rates[tx_rateindex].count = hw->max_rate_tries; } - - for (i = tx_rateindex + 1; i < hw->max_rates; i++) { - tx_info->status.rates[i].count = 0; - tx_info->status.rates[i].idx = -1; - } - - tx_info->status.rates[tx_rateindex].count = ts->ts_longretry + 1; } static void ath_tx_processq(struct ath_softc *sc, struct ath_txq *txq)