Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2168669rdf; Mon, 6 Nov 2023 06:42:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IEoWIADSW41kqaOKOlPb1Iw60b4XWb8nBe+JOzr7Da3CDmeQaz4myT5NTm/7Yxnd+56lYCO X-Received: by 2002:a05:6a21:7185:b0:180:d01b:ba93 with SMTP id wq5-20020a056a21718500b00180d01bba93mr22053402pzb.60.1699281731115; Mon, 06 Nov 2023 06:42:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699281731; cv=none; d=google.com; s=arc-20160816; b=SXPbVk7mhe5Y/khdB2Ap2Y6zeYvEaFbshX2L7HX5DS1bvzTpiWQ/bZTuQkIQNY3JKP P1ZKHhJrdir6rh2alwnkbpEM2+cGIhDFvqrgDN2yUM2fQLNQSFDVwqf6ggPMld4Q6/PQ fAlyVaaLNVpy8smXYICdBkhiRnVOMaQeLZuN7+4Pkh+RvZRaVVmyj+dUgYp+rMXOLGSl EqR342aoyzKRoCZx5n46ZdOMJ63iY7PRcmi0J0tuxKnWyIi2RhLEMmacsAKdmCPAz9IA GcNu3/6KqDxedBMUaFnh1ZF0r2vFo0v/ezBPm/xH8nWMdGcvriHxKM2SujoWkR4zQuMx 3q7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=Bth+FdZXs13CaOTV4AqDLf1oFtkhAbSFz5KiTnFrhg0=; fh=4SlLExXTj+b5lK0AWTDKnd3Q5PUAw6p83LPurV6QhIo=; b=hhXOxkN3RttfXUwhE8Esb8qJJ30x3kLsAIpgzTJRHUj70NwU6thN3H0aynkSE7CK38 w1jthulVfMgRAhsUKZmsXmCXIHZtRiLXznYHrt1ieBq3pC6i4/E3wv5CBIOx42aN/JL5 eF0qtxp3LlVxgHTy7lheJu/cXgp5GYc4D0JeZwLqhiLRnn6THA1l/Fw/aEjEBhTowIym B1yJnBnZmcjRkkke1lsiBO3/rta0HyUDas3SMqex6IS9Fiz84UnmPTInKOsYsps/CTnS wmsQne0YZE30G7Y0sFLGHQmQf/96bwJM4eFfbEwjkK+tP5dFHh0iksbG8oonIXukLVwx lDmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oLffnlK8; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id b23-20020a630c17000000b005b3b8896199si7397244pgl.591.2023.11.06.06.42.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 06:42:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oLffnlK8; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 92101805060A; Mon, 6 Nov 2023 06:42:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231759AbjKFOl5 (ORCPT + 56 others); Mon, 6 Nov 2023 09:41:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231630AbjKFOlz (ORCPT ); Mon, 6 Nov 2023 09:41:55 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF9F0191; Mon, 6 Nov 2023 06:41:52 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A38ADC433C8; Mon, 6 Nov 2023 14:41:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699281712; bh=iwGwlXfOQvVVL9bC4l5etMzOc91DO8OcU4GF8oO6Cf0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=oLffnlK8jpztOLnbDdHOUB5EVjFNObhhNPzj1/q1PezRoQ6QnI0pwh27lfokZpPLg xT77nLA2GhikNyQnfyRCXorf5ZW09Tddx55BFkOcRQPfSAmL2g0WYm8Wj1hce+OyqS NDeyX6SYQU6yrfAUHDE2/yX12WL8InkbFzAFoKoc1GvGt/dnSZH5Sib0fCfwf77/o7 /p0uCayiWGY0T0xD+21nNN4B+fmsx1ii6WMaTs6bPXG2e/ZPyGkUmQF+GYcsqIBgDR jlPkAjs4wHyixYkt9aecAXxjR8s+YSr40ENMFq2oBBhRm90+odOmIL/7zdouD940Wg 9DhmJoOlRfMhg== From: Kalle Valo To: Zheng Wang Cc: aspriel@gmail.com, franky.lin@broadcom.com, hante.meuleman@broadcom.com, johannes.berg@intel.com, marcan@marcan.st, linus.walleij@linaro.org, jisoo.jang@yonsei.ac.kr, linuxlovemin@yonsei.ac.kr, wataru.gohda@cypress.com, linux-wireless@vger.kernel.org, brcm80211-dev-list.pdl@broadcom.com, arend.vanspriel@broadcom.com, SHA-cyfmac-dev-list@infineon.com, linux-kernel@vger.kernel.org, security@kernel.org, stable@vger.kernel.org, hackerzheng666@gmail.com Subject: Re: [PATCH v5] wifi: brcmfmac: Fix use-after-free bug in brcmf_cfg80211_detach References: <20231106141704.866455-1-zyytlz.wz@163.com> Date: Mon, 06 Nov 2023 16:41:45 +0200 In-Reply-To: <20231106141704.866455-1-zyytlz.wz@163.com> (Zheng Wang's message of "Mon, 6 Nov 2023 22:17:04 +0800") Message-ID: <87o7g7ueom.fsf@kernel.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 06 Nov 2023 06:42:03 -0800 (PST) Zheng Wang writes: > This is the candidate patch of CVE-2023-47233 : > https://nvd.nist.gov/vuln/detail/CVE-2023-47233 > > In brcm80211 driver,it starts with the following invoking chain > to start init a timeout worker: > > ->brcmf_usb_probe > ->brcmf_usb_probe_cb > ->brcmf_attach > ->brcmf_bus_started > ->brcmf_cfg80211_attach > ->wl_init_priv > ->brcmf_init_escan > ->INIT_WORK(&cfg->escan_timeout_work, > brcmf_cfg80211_escan_timeout_worker); > > If we disconnect the USB by hotplug, it will call > brcmf_usb_disconnect to make cleanup. The invoking chain is : > > brcmf_usb_disconnect > ->brcmf_usb_disconnect_cb > ->brcmf_detach > ->brcmf_cfg80211_detach > ->kfree(cfg); > > While the timeout woker may still be running. This will cause > a use-after-free bug on cfg in brcmf_cfg80211_escan_timeout_worker. > > Fix it by deleting the timer and canceling the worker in > brcmf_cfg80211_detach. > > Fixes: e756af5b30b0 ("brcmfmac: add e-scan support.") > Signed-off-by: Zheng Wang > Cc: stable@vger.kernel.org > --- > v5: > - replace del_timer_sync with timer_shutdown_sync suggested by > Arend and Takashi > v4: > - rename the subject and add CVE number as Ping-Ke Shih suggested > v3: > - rename the subject as Johannes suggested > v2: > - fix the error of kernel test bot reported > --- > drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > index 667462369a32..a8723a61c9e4 100644 > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > @@ -8431,6 +8431,8 @@ void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg) > if (!cfg) > return; > > + timer_shutdown_sync(&cfg->escan_timeout); > + cancel_work_sync(&cfg->escan_timeout_work); > brcmf_pno_detach(cfg); > brcmf_btcoex_detach(cfg); > wiphy_unregister(cfg->wiphy); Has anyone tested this on a real device? As v1 didn't even compile I am very cautious: https://patchwork.kernel.org/project/linux-wireless/patch/20231104054709.716585-1-zyytlz.wz@163.com/ -- https://patchwork.kernel.org/project/linux-wireless/list/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches