Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp438951iog; Mon, 13 Jun 2022 06:03:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDlLpAoBH70P8tc00QcsJAL6L9yhAsedqk2silljHnVCuM9v9Z4ktOpHIGaRp96g7LCzOS X-Received: by 2002:a63:de42:0:b0:404:fcf1:683c with SMTP id y2-20020a63de42000000b00404fcf1683cmr13868568pgi.537.1655125386193; Mon, 13 Jun 2022 06:03:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125386; cv=none; d=google.com; s=arc-20160816; b=uCbSkUh/towiqoRcbexjxs/I02oC2ZAmtzocXZmW6q5NQLe4KYzJ3p2pf8V/MTgvB5 8BskLsvTk3N0YnOuubezAIknm/CLJPAx5YkTwozEu4XzKZTQESxPzMIcsu0I1D8GKqee MlTQJa4WzcWDup72YSAJpYGpsaeilacuskh/Bk5fvG3q8Rb1cR/bkZeyHNJ1Jl8JEkm3 gG/AC1e+vRb+QwMa1BNGxaqNviUSqyFi24mQwg4+0CnwAZ8QW6X339ARrSIr99f5Bhjw Wkqjy97Bh/HkpFju+AGXlnb0BQjQ+kJkdqPKqVzYhK4ustz6BlM0jZ/9L6fMqT14aC/X d9Bw== 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=lBlg+Wi2G6Np8wqWceUs/I1GFRMmQr7fjHu3DxpHFfM=; b=wdEhEujxXhUKaWriD6NesyKd6zSaBSU19ott8gA6GcxP9VAFQjdXiiSCnfM6oWbbas mtTjyudp7sWibeRPazOIfC/GaaY2Ko8ISFbslZ60uKMgOpfzqfZC2G3F50ogmRj6WH/d 5EZnv92rN3kPeeTlmse6+BAV/tBxuYVIidWENAbYeZVu/cE5b4Zh8JNKUVsa0jAS1nrL 4d4KPcAJy8uOkPZ5q7sHx9D+NmYZGRn1c/xgCnHO1bux9EwclOCwPUUiEtZIJQs2LUSn j+AIID/m1s9rgFgaGZWHi9ZAZJekHVaDseHdTaevchUPZxOwBO3ANyP4wupDdzzaOpHp EBGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=a477uGgf; 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 d1-20020a655ac1000000b003fe0166ab96si9779884pgt.296.2022.06.13.06.02.51; Mon, 13 Jun 2022 06:03:06 -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=a477uGgf; 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 S243375AbiFMKVM (ORCPT + 99 others); Mon, 13 Jun 2022 06:21:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242961AbiFMKUn (ORCPT ); Mon, 13 Jun 2022 06:20:43 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7E1BD5A; Mon, 13 Jun 2022 03:17:26 -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 sin.source.kernel.org (Postfix) with ESMTPS id 67726CE1102; Mon, 13 Jun 2022 10:17:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E03BC34114; Mon, 13 Jun 2022 10:17:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115442; bh=L+loGqkh9a3KGhATRv0kKG+dx/ozURz4KOnBC5vg7JQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a477uGgfAjlgfGuuopiJhsbhXWHxRU+Vy9NolW+kfjhPiSFH9DaDB5JGwJKwgHmnb EOkC4BvDqfAb0owXafxz9WsqJgjulwFHbZdhN6O78ubHTFQOSQCXPYKN5dWmpiH5zi YWGmiLuG41yzENtG8Z/RCx6jR4zwIw6A5ldT0kV4= 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.9 075/167] wifi: mac80211: fix use-after-free in chanctx code Date: Mon, 13 Jun 2022 12:09:09 +0200 Message-Id: <20220613094858.490570668@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094840.720778945@linuxfoundation.org> References: <20220613094840.720778945@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 @@ -1640,12 +1640,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); } /*