Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2201570iof; Tue, 7 Jun 2022 23:03:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwafrojDFhhPdYjVL73z+Xz+d6sKRRdM7NbII7igoe+DCJK2x/ThZO8LzsQgQcrjJF31i2O X-Received: by 2002:aa7:8141:0:b0:518:425b:760e with SMTP id d1-20020aa78141000000b00518425b760emr33020622pfn.27.1654668209089; Tue, 07 Jun 2022 23:03:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668209; cv=none; d=google.com; s=arc-20160816; b=dqhJ3VGOIn3UxIlEPyqmEowOu7XqWvFxCQ8vy+fBfI2lWCpgqX/8eGeXMw3jpEGSWd vU/IC8/f0Fk5AdzbPrLeiHcOEOsfUvRfT1WRCdObmA7Z2c+OYImO16zCxE/cj0soMxV3 9NpqAN5AbHo1LizhjM7feQ77jaOcLWgZsmA8nVokxOdA4vcZk7LKsc7xMEPxDbTzbd3h 6SdHZAHwO3I6ew/IdkEpv96Mj0UPCv9+Zmbt6TCf627ZHNS7HgOjyX5bmxMDR4oUOvF1 XeIk2t9HAV8/0W69iD2QEWCBUv8yGKrFvgalZULeU32lUq2RhtSHuZBDOPolA8usmmVV ycUQ== 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=1ph3u99wi4oHshGZzqOqCJFF1onVNo75LsUhsiZWhpc=; b=kQW2rGH7grcMo3P1t5qwIw383bld2aJGY5BE3IKfKXJDYZcWxtBtPWWWpTKkhM73ji T+23xMlcYXOAKkPvaySQeBiLKt/jg2sPwi0S5ZqUM947dCkLvFXHTrKQ8ZlW9u8Ww++R 6lKSmRqLbbbunAYKLytnF3Fu20rh/hoBYfe68sGHV9GQLCfwY9x5CPzAHHQozggdDmGE wyCqTaOVlIZdj9pGs/Y0w0Sh5PnN6l8eGeOP5TYg0+XUA/geJKPDXO5tgYpSpRErVPnL RASEnzLhQG4VHMp4asdfWMoz5PbwBWm2gQNmcnNJkSa5+8xsygEhtyOeynnD/lrrjoEZ QagA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hq7YNUXE; 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 x11-20020a170902ec8b00b0016390f2f284si30890373plg.167.2022.06.07.23.03.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:03:29 -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=hq7YNUXE; 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 EBD3117A882; Tue, 7 Jun 2022 22:28:17 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238193AbiFHBUl (ORCPT + 99 others); Tue, 7 Jun 2022 21:20:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384265AbiFGWO7 (ORCPT ); Tue, 7 Jun 2022 18:14:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E21A725F406; Tue, 7 Jun 2022 12:19:44 -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 7BB646194C; Tue, 7 Jun 2022 19:19:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 849E4C385A2; Tue, 7 Jun 2022 19:19:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629562; bh=yNqqrwcWOyAH/kGSkz7R0fA0Xe+z0OmTr3r1WJlJDIs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hq7YNUXEd/5e7OVD2AcVU8ck8RAHRbOfkq+l1L9e0ihmbqVFh8XHZP99seawFQPzj weuO/oHn9Q4ZEkQoPq0Icw8J3xVsASzoG1ICBHeJsJQkQf6A+OZEMRFxe7RdxcSTfl 70VjnkMK+FuY3x+Pg0qhTTpJux+VArfJosIj159Q= 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.18 719/879] wifi: mac80211: fix use-after-free in chanctx code Date: Tue, 7 Jun 2022 19:03:57 +0200 Message-Id: <20220607165023.723872092@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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 @@ -1749,12 +1749,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); } /*