From: Soeren Coremans <sorencoremans@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: arend.vanspriel@broadcom.com, brcm80211@lists.linux.dev,
brcm80211-dev-list.pdl@broadcom.com,
Soeren Coremans <sorencoremans@gmail.com>
Subject: [PATCH wireless-next 2/3] wifi: brcmfmac: pcie: bound memdump to the mapped TCM window
Date: Thu, 5 Nov 2026 22:59:53 +0100 [thread overview]
Message-ID: <20261105215954.184290-3-sorencoremans@gmail.com> (raw)
In-Reply-To: <20261105215954.184290-1-sorencoremans@gmail.com>
brcmf_chip_get_raminfo() reports "RAM size is incorrect" on a dead
device but leaves the bogus value in ci->ramsize. A following
brcmf_fw_crashed() then dumps that many bytes from the TCM mapping,
which is only as large as BAR2, and faults in ioread32():
memdump 0x00200000+15728640 exceeds TCM window 0x800000
Remember the BAR2 size and refuse dumps that do not fit. Only builds
with CONFIG_BRCMDBG create the memdump, so only they are affected.
Found and written with the help of an AI coding assistant (Claude Opus
5.5); the cover letter describes how.
Fixes: ff4445a8502c ("brcmfmac: expose device memory to devcoredump subsystem")
Signed-off-by: Soeren Coremans <sorencoremans@gmail.com>
---
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index 02c58de67b82..5abc85013110 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -343,6 +343,7 @@ struct brcmf_otp_params {
struct brcmf_pciedev_info {
enum brcmf_pcie_state state;
+ resource_size_t tcm_size;
bool in_irq;
struct pci_dev *pdev;
char fw_name[BRCMF_FW_NAME_LEN];
@@ -1669,6 +1670,12 @@ static int brcmf_pcie_get_memdump(struct device *dev, void *data, size_t len)
struct brcmf_pciedev_info *devinfo = buspub->devinfo;
brcmf_dbg(PCIE, "dump at 0x%08X: len=%zu\n", devinfo->ci->rambase, len);
+ if (devinfo->ci->rambase > devinfo->tcm_size ||
+ len > devinfo->tcm_size - devinfo->ci->rambase) {
+ brcmf_err(bus_if, "memdump 0x%08X+%zu exceeds TCM window %pa\n",
+ devinfo->ci->rambase, len, &devinfo->tcm_size);
+ return -EINVAL;
+ }
brcmf_pcie_copy_dev_tomem(devinfo, devinfo->ci->rambase, data, len);
return 0;
}
@@ -2145,6 +2152,7 @@ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
devinfo->regs = ioremap(bar0_addr, BRCMF_PCIE_REG_MAP_SIZE);
devinfo->tcm = ioremap(bar1_addr, bar1_size);
+ devinfo->tcm_size = bar1_size;
if (!devinfo->regs || !devinfo->tcm) {
brcmf_err(bus, "ioremap() failed (%p,%p)\n", devinfo->regs,
--
2.53.0
next prev parent reply other threads:[~2026-11-05 22:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 21:59 [PATCH wireless-next 0/3] wifi: brcmfmac: pcie: recover from fatal PCIe errors Soeren Coremans
2026-11-05 21:59 ` [PATCH wireless-next 1/3] wifi: brcmfmac: pcie: stop console read on invalid write index Soeren Coremans
2026-11-26 14:29 ` Arend van Spriel
2026-11-05 21:59 ` Soeren Coremans [this message]
2026-11-26 14:29 ` [PATCH wireless-next 2/3] wifi: brcmfmac: pcie: bound memdump to the mapped TCM window Arend van Spriel
2026-11-05 21:59 ` [PATCH wireless-next 3/3] wifi: brcmfmac: pcie: recover from fatal PCIe errors Soeren Coremans
2026-11-26 14:29 ` Arend van Spriel
2026-11-26 14:29 ` [PATCH wireless-next 0/3] " Arend van Spriel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261105215954.184290-3-sorencoremans@gmail.com \
--to=sorencoremans@gmail.com \
--cc=arend.vanspriel@broadcom.com \
--cc=brcm80211-dev-list.pdl@broadcom.com \
--cc=brcm80211@lists.linux.dev \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox