Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4096789pxb; Mon, 8 Feb 2021 07:53:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPRBJAjNgmzC9JBDNUnfxS/hjhqSbNBjGMjZ0Gbmgt/47I6O8losK9yKBwAmybyMYQe8Vy X-Received: by 2002:a17:907:210d:: with SMTP id qn13mr17248839ejb.377.1612799607241; Mon, 08 Feb 2021 07:53:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612799607; cv=none; d=google.com; s=arc-20160816; b=bTMc/4bzxEuLJ8FvU0nAAavzEKWAMOdJdjyQ1jvpEwmcNykqU7D+h5ApN8F8l2ClQq STeJimQX9UKJ/h6Y9WGRYzSA6DoSVZ5pqnhPQwa718EpYwqx0MhnaPgUsLrB1QMiOc/N Lxebwd0n8EAuB/Hc5GwWv6SF1kEMLZ0NzfK5njBh+dxcHp9zyNaID4Y55kioPY9CLonH Ey7fA3F42Nxy3HDBqtM0OoW4MokQpIrdjmUtJ1yQIyzKn7zM/lxcQhxWKxXbAz4P8aFJ psgZGPMYrJfAq4K2LweJwtXz+kJnVWhkOQeqUJmCNuQugGN6YlDBXT4ZUA9aHIfDH/bM YjNw== 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=XpoP8c/hZeotYJYy7bJbLDofzXwohAHupSSQKXpIPLY=; b=gSB7l1yAn9zHO1Uv2OC6aa9gJFouHn190cRAgoKxRjLNPcVvNofBDoWbmGwCozrKtg XOhNak081w8DXTNANQzVyXOXa1hq3a4YMHbacpw2ix/6eF9mfM2et2Yf+X2i/1DlsV/w YL4qSyM4BLeVveLp/PLlMhjbRk7RLJBo5aKPekpYrytO6qLrRkxsnI2wkbg57K+aGksn b6apFgsp8uYESUjfIt7Cgd2BldkzKX38L2mu5Avmv7fL/jxNOVjfp+HgDitmriZHYoEs ZAKUtJR9Jw6Ea6HADwazXwXvUdg+flsgrrKKzaDCHT1sxWQjJ7bKBzjBQKJG+mHOe9n9 qWhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VlENh6u8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gs5si11484206ejb.491.2021.02.08.07.53.02; Mon, 08 Feb 2021 07:53:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VlENh6u8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S234162AbhBHPuE (ORCPT + 99 others); Mon, 8 Feb 2021 10:50:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:52062 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232276AbhBHPHO (ORCPT ); Mon, 8 Feb 2021 10:07:14 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E26E864E84; Mon, 8 Feb 2021 15:05:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612796740; bh=BCh9qFsYtLmU+r4j51UqZbeU68kz/2QYEmXzYNsGO/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VlENh6u8Mz76/GmtfniwhXpo74vZ7iI8g8u21diytJ/YhHwL8OVEC/PU30La9hkii 4mybTsBiTqPC7mYgF6JM0NAz+lMpwd/jC3o1pJkMafmxK4qFD5lf5xvyBF+RyX88T/ oLflbkcnYPA/NZiVTGU8bX9KrEmnKGd8HrkkJMuU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felix Fietkau , Johannes Berg Subject: [PATCH 4.9 28/43] mac80211: fix station rate table updates on assoc Date: Mon, 8 Feb 2021 16:00:54 +0100 Message-Id: <20210208145807.452185088@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145806.281758651@linuxfoundation.org> References: <20210208145806.281758651@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Felix Fietkau commit 18fe0fae61252b5ae6e26553e2676b5fac555951 upstream. If the driver uses .sta_add, station entries are only uploaded after the sta is in assoc state. Fix early station rate table updates by deferring them until the sta has been uploaded. Cc: stable@vger.kernel.org Signed-off-by: Felix Fietkau Link: https://lore.kernel.org/r/20210201083324.3134-1-nbd@nbd.name [use rcu_access_pointer() instead since we won't dereference here] Signed-off-by: Johannes Berg Signed-off-by: Greg Kroah-Hartman --- net/mac80211/driver-ops.c | 5 ++++- net/mac80211/rate.c | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) --- a/net/mac80211/driver-ops.c +++ b/net/mac80211/driver-ops.c @@ -128,8 +128,11 @@ int drv_sta_state(struct ieee80211_local } else if (old_state == IEEE80211_STA_AUTH && new_state == IEEE80211_STA_ASSOC) { ret = drv_sta_add(local, sdata, &sta->sta); - if (ret == 0) + if (ret == 0) { sta->uploaded = true; + if (rcu_access_pointer(sta->sta.rates)) + drv_sta_rate_tbl_update(local, sdata, &sta->sta); + } } else if (old_state == IEEE80211_STA_ASSOC && new_state == IEEE80211_STA_AUTH) { drv_sta_remove(local, sdata, &sta->sta); --- a/net/mac80211/rate.c +++ b/net/mac80211/rate.c @@ -892,7 +892,8 @@ int rate_control_set_rates(struct ieee80 if (old) kfree_rcu(old, rcu_head); - drv_sta_rate_tbl_update(hw_to_local(hw), sta->sdata, pubsta); + if (sta->uploaded) + drv_sta_rate_tbl_update(hw_to_local(hw), sta->sdata, pubsta); return 0; }