From patchwork Wed Apr 3 15:26:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bethany Jamison X-Patchwork-Id: 1919359 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V8pWV2Rgnz1yZJ for ; Thu, 4 Apr 2024 02:26:46 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rs2Vb-0007Kr-CZ; Wed, 03 Apr 2024 15:26:39 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rs2VY-0007Jz-QA for kernel-team@lists.ubuntu.com; Wed, 03 Apr 2024 15:26:36 +0000 Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 92DE33F274 for ; Wed, 3 Apr 2024 15:26:36 +0000 (UTC) Received: by mail-io1-f72.google.com with SMTP id ca18e2360f4ac-7cc0a422d43so718487039f.2 for ; Wed, 03 Apr 2024 08:26:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712157995; x=1712762795; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9JhHfFbITN1h9+KG7V6IX79HgsDGd3p2d0Krrfeu5rQ=; b=d6kudwVb6grUNQs/7SAXnSLw3sULSLDv+KNV0jH+jP6KRG2sGTT/F8fXqqhNIqZpze 88Kklh03gVjbN+0j33MN6ilD84Xyp2+KC1xN7zJU2nUXGTrxWJq+hkbxXErV7UztgXWW 4xIPbJRpT0soqOwHcIbhV6K05kaMf+4i5FlS7ZmhDg0+o5jPJYIHAVxfAB49+eZv3KhK DLgePcIRqerub/E+y6e7UdXtq0hHoDGxSoWwoSsI0Dc+Tt4aalljatVRsdN8vO2C1FDC z+lrW8Qnwfbe8jZZroibEA9XroaeCSdxlnklYTza5UqoqxV53bnrluDVep1uBHcOI7/N qdPw== X-Gm-Message-State: AOJu0YyuNFsaFEBiK9Mykq3Q87zU0XgSYSdsEOvmb7UqpBOXuEZ68qfP 7y8mOxECsV/rumdM6RuLKcI9NIwQj3bLKN6cUpe3cg5wuPKfYF/g7ukPHcORrPUzpe9MS9UI7iR iJY/V18ULY9kDB6R3DhTSQfkseRVXY8T0EssmCwKVBdtrkc7Sqa1YtAF4sBnEODCHHYyWWlX5C1 TJl1MtBCq7wg== X-Received: by 2002:a05:6602:1205:b0:7d3:4ef3:e6c1 with SMTP id y5-20020a056602120500b007d34ef3e6c1mr348103iot.10.1712157994483; Wed, 03 Apr 2024 08:26:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENH21gALwNEW0cRZ5Fs/b0fSQTZBTGJ7YcDHlAr5G8mioO6PFf5yFoEI3RC7SFjZ367tM4Kw== X-Received: by 2002:a05:6602:1205:b0:7d3:4ef3:e6c1 with SMTP id y5-20020a056602120500b007d34ef3e6c1mr348041iot.10.1712157993490; Wed, 03 Apr 2024 08:26:33 -0700 (PDT) Received: from smtp.gmail.com (104-218-69-129.dynamic.lnk.ne.allofiber.net. [104.218.69.129]) by smtp.gmail.com with ESMTPSA id l15-20020a056638144f00b0047ef25012b2sm2258159jad.109.2024.04.03.08.26.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 08:26:33 -0700 (PDT) From: Bethany Jamison To: kernel-team@lists.ubuntu.com Subject: [SRU][M/J][PATCH 1/1] wifi: brcmfmac: Fix use-after-free bug in brcmf_cfg80211_detach Date: Wed, 3 Apr 2024 10:26:30 -0500 Message-Id: <20240403152631.10248-2-bethany.jamison@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240403152631.10248-1-bethany.jamison@canonical.com> References: <20240403152631.10248-1-bethany.jamison@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Zheng Wang 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 [arend.vanspriel@broadcom.com: keep timer delete as is and cancel work just before free] Signed-off-by: Arend van Spriel Signed-off-by: Kalle Valo Link: https://msgid.link/20240107072504.392713-1-arend.vanspriel@broadcom.com (cherry picked from commit 0f7352557a35ab7888bc7831411ec8a3cbe20d78) CVE-2023-47233 Signed-off-by: Bethany Jamison --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c index 2a90bb24ba77f..c5c357aa7f23f 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c @@ -1179,8 +1179,7 @@ s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg, scan_request = cfg->scan_request; cfg->scan_request = NULL; - if (timer_pending(&cfg->escan_timeout)) - del_timer_sync(&cfg->escan_timeout); + timer_delete_sync(&cfg->escan_timeout); if (fw_abort) { /* Do a scan abort to stop the driver's scan engine */ @@ -8436,6 +8435,7 @@ void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg) brcmf_btcoex_detach(cfg); wiphy_unregister(cfg->wiphy); wl_deinit_priv(cfg); + cancel_work_sync(&cfg->escan_timeout_work); brcmf_free_wiphy(cfg->wiphy); kfree(cfg); }