Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp579057iog; Mon, 13 Jun 2022 08:30:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgqOG0xQv5x8Nxbfq3RI5ABD8FeNS5vflq+w4nFqZh9gRWHm0/Qk/uuSypPVgtAh4u27De X-Received: by 2002:a05:6402:5211:b0:42e:2e1c:5bce with SMTP id s17-20020a056402521100b0042e2e1c5bcemr330325edd.198.1655134211356; Mon, 13 Jun 2022 08:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134211; cv=none; d=google.com; s=arc-20160816; b=T/ZTaiR40Nm+mczI4bYKXAjLbxvZC5jhM6Upa8svnVPvh+MA193YJXNGckGzlDUaZi QT4xXaZY0zmx8n6h/FFJy0v3U2ZlenDPfgC57sa4rLwz92jJps+Sk/9CcobcHPCteaCS xtscM6cC/t8zop3C9qykfYMkk+76heBAWnZjVcwyE+NtplckybBNS1PssoFuj06xSObe NQ2jF3In3TDzuaXDmn1uVLJHQpknTraS2XDS17ifvu98E7+G63kEJjnVMTz8c9daGMH1 KYAL9+GiCCRlqR6bgg49PTpDvtBVaKRR/eNiSvMEN6G+98VU9um3HlGr4T9EnK2AtrPK UtUg== 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=eyaA5jpQYogdbLpT8FRNOAJhHXk9XIZvEc+q54hbZjc=; b=nCp6P4y7Elzu8khMH2OyUl16D3qpmF+RlERNddS6jThQNblw79ve/96s/SLAZjVv8Z dP1qvP47L3hbBkW4HgsMUYOzTl2nifx10lKAe6/WOlq5ni5FkN2VW5JcegfigLNI14LH inEOeaY8gRT9ZLDOOQaCfJeBDHkMfC7f80GUxOfWNWDwQLZPPBI1nlcAl911jevZQ7YN IVFGS/UaQmilqWBM7fnCiY3mWxilWqUNQQ1O0L70AT6ARjIyAo/ohyiabqsGiWHX3PnC lfzObCPkolRv8b3kDXSOhK6R/JyZJ8eVI8eW+8sfHL+YVISyfaO9q+rxipZcfn1Wpy4o XRkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="mONa9Q4/"; 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 dp17-20020a170906c15100b006fea036b38esi8603857ejc.310.2022.06.13.08.29.46; Mon, 13 Jun 2022 08:30:11 -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="mONa9Q4/"; 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 S1353611AbiFMMKP (ORCPT + 99 others); Mon, 13 Jun 2022 08:10:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358605AbiFMMEW (ORCPT ); Mon, 13 Jun 2022 08:04:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CBB7427D3; Mon, 13 Jun 2022 03:57: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 dfw.source.kernel.org (Postfix) with ESMTPS id 43F9A61346; Mon, 13 Jun 2022 10:57:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5014FC34114; Mon, 13 Jun 2022 10:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117851; bh=+7lMIGEEM0SyYdAaiK7TVCobrDsuPE+uowxjx/D62q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mONa9Q4/t44pm63p3Ac2DnWeoUbvu2Jd2dTcWlY/TkJx2rp7BBv/98OH3DvlLALx6 3OcmV26ZGNBaz1+PyTYosNUXF03lHhIMOw/V6MAFukJO1MknDrxOcd+umLcXyQL3mA yxTZRdoq1objwEqUetnGRqPIIuBJ4i6LPe5hUiAI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , Kalle Valo Subject: [PATCH 4.19 143/287] wifi: mac80211: fix use-after-free in chanctx code Date: Mon, 13 Jun 2022 12:09:27 +0200 Message-Id: <20220613094928.212812400@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094923.832156175@linuxfoundation.org> References: <20220613094923.832156175@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=-8.3 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: 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 @@ -1638,12 +1638,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); } /*