From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 038EC226CF0; Tue, 11 Mar 2025 15:08:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741705726; cv=none; b=XdVVpZukv3BRP0XC9MjuMRwTILsZViIE/WPtK7+afOm+4Kx2ve+dlI0AVHac5opMeO58IHI2vL6Ynln+QDy8GzI9GI+Hi2Gtjs5TbIyuQF6N56I8xlT0Pjy+zS+2RWRqxdE+deLAN1eIoZ49Lwvelhn3qakbrZHIvO0GCVCzwZw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741705726; c=relaxed/simple; bh=rV2tBR2ulCDUEe29rxcBDI0fIi6DPvxj2stIHKGsS/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KIwM4Gc6dp/kAJHJqToBuKpV7X1VWbYaOh2SnS53JQ8qI6SzBnK2IZSnGDg0Vs1M8Vbv2hhelCq3eb3TH980nLMr/m9r4YhTVPNoJUCTImFM7zNviWxIEAPZSM3AotICUBdlkkhctrS+bn81n/dSPEjk6o9RytyWotnTvSNXiEw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=oQd3Dgnj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="oQd3Dgnj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77C3BC4CEE9; Tue, 11 Mar 2025 15:08:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1741705725; bh=rV2tBR2ulCDUEe29rxcBDI0fIi6DPvxj2stIHKGsS/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oQd3Dgnj5C03xOwLS7Vmo9iQ9T8A0IIH1k/IBx2yf/apPkGheXKTn2nkOaRjpkwNb 5gQxD4yBvbD9n8lXxoE27sqSxQv8H4L00gcenn/XCBd+hj+ojseMJBTZmVaAu2MoW1 /AwVbapvb9dRNT9hg+IvQyRqpwe1aj6WsGFra9yo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marcel Hamer , Arend van Spriel , Kalle Valo Subject: [PATCH 5.4 134/328] wifi: brcmfmac: fix NULL pointer dereference in brcmf_txfinalize() Date: Tue, 11 Mar 2025 15:58:24 +0100 Message-ID: <20250311145720.229564371@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311145714.865727435@linuxfoundation.org> References: <20250311145714.865727435@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marcel Hamer commit 68abd0c4ebf24cd499841a488b97a6873d5efabb upstream. On removal of the device or unloading of the kernel module a potential NULL pointer dereference occurs. The following sequence deletes the interface: brcmf_detach() brcmf_remove_interface() brcmf_del_if() Inside the brcmf_del_if() function the drvr->if2bss[ifidx] is updated to BRCMF_BSSIDX_INVALID (-1) if the bsscfgidx matches. After brcmf_remove_interface() call the brcmf_proto_detach() function is called providing the following sequence: brcmf_detach() brcmf_proto_detach() brcmf_proto_msgbuf_detach() brcmf_flowring_detach() brcmf_msgbuf_delete_flowring() brcmf_msgbuf_remove_flowring() brcmf_flowring_delete() brcmf_get_ifp() brcmf_txfinalize() Since brcmf_get_ip() can and actually will return NULL in this case the call to brcmf_txfinalize() will result in a NULL pointer dereference inside brcmf_txfinalize() when trying to update ifp->ndev->stats.tx_errors. This will only happen if a flowring still has an skb. Although the NULL pointer dereference has only been seen when trying to update the tx statistic, all other uses of the ifp pointer have been guarded as well with an early return if ifp is NULL. Cc: stable@vger.kernel.org Signed-off-by: Marcel Hamer Link: https://lore.kernel.org/all/b519e746-ddfd-421f-d897-7620d229e4b2@gmail.com/ Acked-by: Arend van Spriel Signed-off-by: Kalle Valo Link: https://patch.msgid.link/20250116132240.731039-1-marcel.hamer@windriver.com Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c @@ -538,6 +538,11 @@ void brcmf_txfinalize(struct brcmf_if *i struct ethhdr *eh; u16 type; + if (!ifp) { + brcmu_pkt_buf_free_skb(txp); + return; + } + eh = (struct ethhdr *)(txp->data); type = ntohs(eh->h_proto);