Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp438970iog; Mon, 13 Jun 2022 06:03:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAc62nC3YA2jpx1QdIH581MoYjOjTvQkrkdQAmsqRmCmNJCEICEbaRg8Fzas5fqoU31T4U X-Received: by 2002:a63:f455:0:b0:3fc:e1c1:bf10 with SMTP id p21-20020a63f455000000b003fce1c1bf10mr50763726pgk.467.1655125387057; Mon, 13 Jun 2022 06:03:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125387; cv=none; d=google.com; s=arc-20160816; b=c+NmW0/89W9xFTSwNnwOoPxK4UC9cJldnYbDBEGIHwS80tDQk6YzUryu7Ubbd0fuxV GCqgmX2cJteA3xc/P6iidCuQGhgLMRaKLIHmlEOT5450fcUFxiwZ+tpsrIGChCvImqsj OCS6Up7HUjznbW9mGVFHFcNRh5N2r8iY3d9sL/acPeSHqKwdN4SYnOURVuP6L/0raDeP vHfMaCU6Z804j3lKC2aWN8mrM+U4qOPP7LBwsy/GlJPWWvLm7IVmz6G55pj6PCMVqt3+ Rhyn2UajjNglS/lsFJGtpmHpvg/ANisPavKYXqFcNDjaN4azwkLgNprl15KWckBUBXay SFww== 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=IG3s6OeaNyASQfFJVJYkAcArFjNE0C7pJ/j9yZkkiq+jZsMSM/2pFKvA2Hkmpa4kMQ YhY833GDzhQ7eoj2zmwJWvYcuTqxFsY5RyBhFH+pr8f5BzsFrTtZiC5UQaK/tckqDlnl 91bsQaRYjUBka0SReXj64wN9M8+0GSnIjhlESVXytNEdVOZRSdFhqBCM9FplyM2dxZeF vBxvzUhEgE8aE/427UF/cwZCqo0w9zybFdQFkZMZ/3zWEacZnoyU8GO/mIq2FmFFUEfu c3sSYgjva2cGpvPOPP4lv7uZB3FFAFjJHtlHwl5CKE4ef/Hed0dzOkxD8AKPtl0l+Dx8 3U+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Pw1wBax8; 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 u13-20020a056a00124d00b0051c187b97d5si9547380pfi.11.2022.06.13.06.02.51; Mon, 13 Jun 2022 06:03:07 -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=Pw1wBax8; 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 S1347210AbiFMKvn (ORCPT + 99 others); Mon, 13 Jun 2022 06:51:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346682AbiFMKsq (ORCPT ); Mon, 13 Jun 2022 06:48:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E52012CDD7; Mon, 13 Jun 2022 03:26:17 -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 ED74A60F09; Mon, 13 Jun 2022 10:26:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2482C34114; Mon, 13 Jun 2022 10:26:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115976; bh=+7lMIGEEM0SyYdAaiK7TVCobrDsuPE+uowxjx/D62q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pw1wBax8YHbsqp87kfWf3FGS3vc085dCJ9TKIqiv0Uix3+xCL6RvqF+SMuffwzwuC D0qmj3hadZXhTyLayFgz15FJ8Pk4xKu1zHCzNQ4xIB2Vqn4NJfEz0XIa3CzNp/wERQ c6KpIRU2o+fYJc6p4EqIzm6P6j2cXSH2YUECaEi0= 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.14 102/218] wifi: mac80211: fix use-after-free in chanctx code Date: Mon, 13 Jun 2022 12:09:20 +0200 Message-Id: <20220613094923.647168349@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094908.257446132@linuxfoundation.org> References: <20220613094908.257446132@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); } /*