Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp1916432rdf; Sun, 5 Nov 2023 21:20:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFY+7jkDbA/DOG94Vwl5meFbFeEVFsfg2w6agD7iIj5dK70vsx2B3QEI2Fx4LUNOFQi5xUw X-Received: by 2002:a05:6870:a9a1:b0:1e9:e605:279f with SMTP id ep33-20020a056870a9a100b001e9e605279fmr36655068oab.13.1699248000564; Sun, 05 Nov 2023 21:20:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699248000; cv=none; d=google.com; s=arc-20160816; b=dt6otAXMb0t33BPTzRG/DGJiDrW9jPh3YP4jpzWONN5yxzYSRC3nyao6Xc7USpz/6K pdmopVsAGsR336HNNPjVNXNeZEeFzt6lOXN0DWciN9XN6kLh1SOhZOpQihb3Uk8z1DZQ v7BK9J+ZPY7p01dBT6XtU1MFk3nQK1CdSSlYoqeAYUsM9um7oAHgOf7YNnu4fvkWsmrM ex2Rw98fNOsjI/W0Na1QOd9chPyNqZ61R2TV1Rod6TwA0rAw+mi6+wpzbeHADiLbDuej cXsHdMIrWB2S41Hf7uZUW0a7A6sgw9CnBpERcxEzsWcIoJ7dOdjyuFkWVj1NxdVNDa58 G0/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=EMahlO8uhra1dh8HKnzq7Y9z6mUAC2Qeqp72jyzvlME=; fh=BPTmKxf13ho/sPz7kfBHhmOfQDn8923bFuc84wa6Cak=; b=GtTnVh25Z4WgadQOGKkNaHFmGFa0C+2TdLeuZOP0Hofv4hkuD1J8JAipFbqPNc5jpF LMoCmAdXaB3bn4Oh/wWld/Np0TcHt0Edzo98bZxPyTEb0+7UV+TxXZmXMZ8vZ70K60Mu vwJjNqqYXKj/w+hKO4yuRvf8Dzp1JtiXyEK9UXCbgc3Fo9Lr4+UIyRy0JQpkFoZG2PAB OW8K9VO8WtmS5EGX/WB7dQ8oVmSlhI8XceAMrv/4qHROjbOcBqE8UGRtmWsWi1MMEyL/ AmlA8MwUJ27lM7PW2cf8LhmK5rqmOKV6YG1DzChmaJjoH6bIIv/Uqn2y5uIY5IC8s+T2 QiNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=f3q4H7Cg; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id m17-20020a656a11000000b005af7c6a2212si7912449pgu.648.2023.11.05.21.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 21:20:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=f3q4H7Cg; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8644E80ACCC4; Sun, 5 Nov 2023 21:19:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230348AbjKFFQn (ORCPT + 55 others); Mon, 6 Nov 2023 00:16:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjKFFQl (ORCPT ); Mon, 6 Nov 2023 00:16:41 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1C60100; Sun, 5 Nov 2023 21:16:38 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-27e0c1222d1so2944747a91.0; Sun, 05 Nov 2023 21:16:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699247798; x=1699852598; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=EMahlO8uhra1dh8HKnzq7Y9z6mUAC2Qeqp72jyzvlME=; b=f3q4H7CgUt1A9HlGRb3LIq4ipQMQDd6z4XYGwl1jhr/QvlSmMhDLRdpILKuYEesSq4 a2k9LfYxcL9vWZrapPpR1fZXQ/wq8WPgcJG4axWv/oZPI+SVqZC3ZCpEACv5KP1rutPq yXEQcT25na9DU+556iNrLNFh3ElebKGwKbC9+Im28lLR1o4uU56fFqt6+XZxDJQn/qaI UNqRB8EPOJuhABEgTeMCKffJbPZLvMbJ7mtTmqgpCbST+jQjTrnZEZczExHAWv7JGJee hG6XI+R21unVoKBSxOFMcH/8dgX5CmdRP7E50Mis5k4lTV3eyumPuGk4DjlShHdaZw5y 2oAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699247798; x=1699852598; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EMahlO8uhra1dh8HKnzq7Y9z6mUAC2Qeqp72jyzvlME=; b=lCqIjTFGcAV1t+VSRMSrUVMhua5TN5HHHgT9EGhn7871EFGnx433xQBU2k4wntLISL lzlFBL9JRhcn0dgTMb9GEhxKQGlj77dhNUvIWKSnQ/bEE/RPyT2cYFAZzLEtFkej6Bwj uTDwXYwdiZDakbh4W+4XpEe+ovymY0EjDyGS6h6AfnT84rKs4iiX2TP/8gAyx4HObRfW ZzpIhrtpBeAr7YZ0OgHqniDrQN3KSZ8WoUy+m9D4dXHA7L7pFrK017ZHur7ss4cv/j3h Dgw+nPefdYCpjpZWIDn+6RXdtsBjIaHRoJmTfRb7a//lhPjCR1Toi9qB5GQl+xV6eBAN MznA== X-Gm-Message-State: AOJu0YzB3oOPPX/d/6du3KwWSdYUOvQ0HUII42PMxhmEv5wOGuMyfjVq IkXIlcb959m+w4EI6dcpaTs3B9dY4nXR7vUxnGFibAbzCOcEQb03Rks= X-Received: by 2002:a17:90b:100b:b0:27f:fcc8:9196 with SMTP id gm11-20020a17090b100b00b0027ffcc89196mr24029499pjb.32.1699247798133; Sun, 05 Nov 2023 21:16:38 -0800 (PST) MIME-Version: 1.0 References: <20231106043957.815407-1-zyytlz.wz@163.com> In-Reply-To: <20231106043957.815407-1-zyytlz.wz@163.com> From: Zheng Hacker Date: Mon, 6 Nov 2023 13:16:26 +0800 Message-ID: Subject: Re: [PATCH v3] brcmfmac: Fix use-after-free bug in brcmf_cfg80211_detach To: Zheng Wang Cc: aspriel@gmail.com, franky.lin@broadcom.com, hante.meuleman@broadcom.com, kvalo@kernel.org, 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, SHA-cyfmac-dev-list@infineon.com, linux-kernel@vger.kernel.org, security@kernel.org, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,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 agentk.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 (agentk.vger.email [0.0.0.0]); Sun, 05 Nov 2023 21:19:55 -0800 (PST) This is the candidate patch of CVE-2023-47233 : https://nvd.nist.gov/vuln/detail/CVE-2023-47233 Appreciate the review and suggestions. Zheng Wang =E4=BA=8E2023=E5=B9=B411=E6=9C=886=E6=97=A5= =E5=91=A8=E4=B8=80 12:42=E5=86=99=E9=81=93=EF=BC=9A > > 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 > --- > v3: > - rename the subject as Johannes suggested > v2: > - fix the error of kernel test bot reported > --- > drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c = b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > index 667462369a32..646ec8bdf512 100644 > --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c > @@ -8431,6 +8431,9 @@ void brcmf_cfg80211_detach(struct brcmf_cfg80211_in= fo *cfg) > if (!cfg) > return; > > + if (timer_pending(&cfg->escan_timeout)) > + del_timer_sync(&cfg->escan_timeout); > + cancel_work_sync(&cfg->escan_timeout_work); > brcmf_pno_detach(cfg); > brcmf_btcoex_detach(cfg); > wiphy_unregister(cfg->wiphy); > -- > 2.25.1 >