Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2172904iof; Tue, 7 Jun 2022 22:08:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyD36c0bBlJsB1MygU/xqG7ILLH8XJ8mTPg0CZCKrxZefq9eUoX4QL29K/p33IhcUEUsEX9 X-Received: by 2002:a17:90a:bc98:b0:1e8:6895:645e with SMTP id x24-20020a17090abc9800b001e86895645emr19877442pjr.131.1654664932875; Tue, 07 Jun 2022 22:08:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654664932; cv=none; d=google.com; s=arc-20160816; b=xtgU89MxuP4p0NPJ6W9nSI7QEfNM4OfGszO0MOMvV+rpj5lcH8VWfnX0szkb61dJf/ FNEvngZXK2NWM/OK7Ahw+2+5CXdbGQo/SThEP1i/3UPJWMHojLclJNiQ04RviSQyzjS5 5+JFRq6BM4GB/6fc188vpmZ4E0x2pK5vhaBFEd3wqY3TvJLY5grqBxtHb2BEuOxdDseX fxuTRE7WxdyHN7p6JQAdvqbzvm4qlaZ0kOPFARGH94xwJk00sRPHouhBWhKkSxiWR3O6 /0SUr+iWHuJffKo4K/SZdpe3ao1rYoUSDnTa6tkf1dTzF9fykDjEYHcOQh8HRJ8d6jz6 kJDg== 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=vWI01tm1rtE5XM/sOyzZ7TooE7eTqkkiyb+M9RWjqHI=; b=RRBaPN3sRhrS3L1zRdnBTHDV2XzWF9BkvAnuJMGCU41Q3CmFOQo5F39IEidVJqY6w0 7QXz3wN9kAzNMBstf99W0bz/hZdR4aLOz6Y8e/izPEnwWR/+2po942a0p0oK6ECnCtpr n3+uSw9NUCdiiiwHe45WA3sYqJot5QmN7M5HjTa33lB7ATG6ysjcYR6a0zEM9MnDoXea qZf1yCNEhLWvK+GCGg9ZxQGUs5kXbOjT6qHlc19D09LdyPI1/Knnn1suNDrnX5/qUHT0 A1WdS9zYc1H9/Jo8xN68P+2WDBSgmi/XquiqnXIplkJdXisnayjnTUDS8O+dzj929f+d 6bZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sbrnd3mb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id pq1-20020a17090b3d8100b001df7c2c5f37si30601165pjb.82.2022.06.07.22.08.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:08:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sbrnd3mb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 161FB24941; Tue, 7 Jun 2022 21:38:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351248AbiFGSBz (ORCPT + 99 others); Tue, 7 Jun 2022 14:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347851AbiFGRmj (ORCPT ); Tue, 7 Jun 2022 13:42:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 052AD12E305; Tue, 7 Jun 2022 10:35:04 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 7CC286159B; Tue, 7 Jun 2022 17:34:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87FB5C36AFF; Tue, 7 Jun 2022 17:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654623257; bh=NJJ+Nkarf9LFJX66CXV++Zsx5I6VyYCOdtWPcYpe+9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sbrnd3mbld83pfyKyBx5jEixNxbzK91mo5OlmQZmNnImOymMAhDjngt9QK+iDYKXM 1UU9UWX+wYHZ//pqB9UTXZYI6iOdGRKGhqHJyvCvev32sTtldYrYC1f+edt7lPdTcn e1VUcV5UjEcYQ5nRKBMoHr/L1Bbe0VSx1OAutdmE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Kalle Valo Subject: [PATCH 5.10 352/452] wifi: mac80211: fix use-after-free in chanctx code Date: Tue, 7 Jun 2022 19:03:29 +0200 Message-Id: <20220607164919.047331076@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Johannes Berg commit 2965c4cdf7ad9ce0796fac5e57debb9519ea721e upstream. In ieee80211_vif_use_reserved_context(), when we have an old context and the new context's replace_state is set to IEEE80211_CHANCTX_REPLACE_NONE, we free the old context in ieee80211_vif_use_reserved_reassign(). Therefore, we cannot check the old_ctx anymore, so we should set it to NULL after this point. However, since the new_ctx replace state is clearly not IEEE80211_CHANCTX_REPLACES_OTHER, we're not going to do anything else in this function and can just return to avoid accessing the freed old_ctx. Cc: stable@vger.kernel.org Fixes: 5bcae31d9cb1 ("mac80211: implement multi-vif in-place reservations") Signed-off-by: Johannes Berg Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20220601091926.df419d91b165.I17a9b3894ff0b8323ce2afdb153b101124c821e5@changeid Signed-off-by: Greg Kroah-Hartman --- net/mac80211/chan.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c @@ -1652,12 +1652,9 @@ int ieee80211_vif_use_reserved_context(s if (new_ctx->replace_state == IEEE80211_CHANCTX_REPLACE_NONE) { if (old_ctx) - err = ieee80211_vif_use_reserved_reassign(sdata); - else - err = ieee80211_vif_use_reserved_assign(sdata); + return ieee80211_vif_use_reserved_reassign(sdata); - if (err) - return err; + return ieee80211_vif_use_reserved_assign(sdata); } /*