Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3860752pxb; Tue, 17 Nov 2020 05:37:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyuC2YZBfgJCh6hIlLeRyspIlhQ6u1cY+YHONBmDAX6uG2/K0os0bP9idrgxm3pE0CVa03f X-Received: by 2002:a17:906:cc8c:: with SMTP id oq12mr20634084ejb.177.1605620229913; Tue, 17 Nov 2020 05:37:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605620229; cv=none; d=google.com; s=arc-20160816; b=Kt49RV2oj55asFQCr4JUhg2+Dzg3qvg/I89qvQL0593cJBUJ7AFPrL8tncNdbZFcgr nC/Pgf3VvA27feNAVhvLoLivCUFi1HXYf5iiRUClFy+yToKG8Wfq5PRpf4VPwlPWD9JI T0NjloK/5ewdCcbLXEwBQV7vAuANAmOjcqAsUuOaXNQMjbbudFiWAb6F1osqP5q5X+3d mD79qziP4qk7upB/wXlf4bnFK5wjr3474ogC//MslxO62q+D5aZ16dUt/g2/nzOg2hmm RAk5i4LZb+0DDtESM7HkY6DptIp5xI5NQQ+XPHkxjTUmZQuoCyIBdsBigekJcbXI0hxA BDEQ== 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=ajlVs0S14wiFghxmt+ge7Mw/cdCqkmTFBIIA+tfqjjk=; b=cykV/Bj2/arywFYrumIC36/ZdcZ7NzybcYUhiVkdg9p/LC6iSvKdI/IsOUQfEw2lbo 6ayiCTUnHn4uqitvNMADk3CMolOgUWJiLALZLUsQeed1VuoGVEN2XE6TSj+BLcSQJJr6 mneQ+b2XxnmAotFN7AfBK7utR6Hx6Nq///zsVdg1px4rc0CJ04KwYoEFMUSJfS5wVjSZ jkvmMXJBqG58Lz1HW0UUf/e5HmhR+81EuTHUk+3/LBU5jLICyZGLf+TNJ79GJIA4xh4h H2DXiAFi49RJE1Vv8W/D2Syou1fBfMOFjMr8UTNvoclazlYgUGqAkLvKrP5TgJeX0X8J QM8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CpKDnhG7; 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=fail (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 a12si15386035edf.2.2020.11.17.05.36.46; Tue, 17 Nov 2020 05:37:09 -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=@kernel.org header.s=default header.b=CpKDnhG7; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732011AbgKQNeg (ORCPT + 99 others); Tue, 17 Nov 2020 08:34:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:45032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731644AbgKQNed (ORCPT ); Tue, 17 Nov 2020 08:34:33 -0500 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 720262168B; Tue, 17 Nov 2020 13:34:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605620073; bh=PyySKvSTnJuJvn5PuxvpYIZhLerqechqm4GPQpixtCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CpKDnhG72RU/meJ73QcE80YM8tS2nnkQ4YU08fpte7alzVY9SNKD/7ED/VL/82Nis bh4Q6KJiv6iRkZOBehDL90SzxhRAGIQxdViYVR4pajUfQ5LW9tFeS5Obwua2Qv4rkM w3HwKeBPzigGsP98bZq72rBDSgmVm2y56PqCgLvQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+2e293dbd67de2836ba42@syzkaller.appspotmail.com, Johannes Berg , Sasha Levin Subject: [PATCH 5.9 099/255] mac80211: always wind down STA state Date: Tue, 17 Nov 2020 14:03:59 +0100 Message-Id: <20201117122143.775631191@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122138.925150709@linuxfoundation.org> References: <20201117122138.925150709@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: Johannes Berg [ Upstream commit dcd479e10a0510522a5d88b29b8f79ea3467d501 ] When (for example) an IBSS station is pre-moved to AUTHORIZED before it's inserted, and then the insertion fails, we don't clean up the fast RX/TX states that might already have been created, since we don't go through all the state transitions again on the way down. Do that, if it hasn't been done already, when the station is freed. I considered only freeing the fast TX/RX state there, but we might add more state so it's more robust to wind down the state properly. Note that we warn if the station was ever inserted, it should have been properly cleaned up in that case, and the driver will probably not like things happening out of order. Reported-by: syzbot+2e293dbd67de2836ba42@syzkaller.appspotmail.com Link: https://lore.kernel.org/r/20201009141710.7223b322a955.I95bd08b9ad0e039c034927cce0b75beea38e059b@changeid Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- net/mac80211/sta_info.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c index fb4f2b9b294f0..4fe284ff1ea3d 100644 --- a/net/mac80211/sta_info.c +++ b/net/mac80211/sta_info.c @@ -258,6 +258,24 @@ struct sta_info *sta_info_get_by_idx(struct ieee80211_sub_if_data *sdata, */ void sta_info_free(struct ieee80211_local *local, struct sta_info *sta) { + /* + * If we had used sta_info_pre_move_state() then we might not + * have gone through the state transitions down again, so do + * it here now (and warn if it's inserted). + * + * This will clear state such as fast TX/RX that may have been + * allocated during state transitions. + */ + while (sta->sta_state > IEEE80211_STA_NONE) { + int ret; + + WARN_ON_ONCE(test_sta_flag(sta, WLAN_STA_INSERTED)); + + ret = sta_info_move_state(sta, sta->sta_state - 1); + if (WARN_ONCE(ret, "sta_info_move_state() returned %d\n", ret)) + break; + } + if (sta->rate_ctrl) rate_control_free_sta(sta); -- 2.27.0