339-v5.1-0010-brcmfmac-add-basic-validation-of-shared-RAM-address.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. From e0a8ef4d7b4315bc4c1641fb3f3a7dfdfa6627b8 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  3. Date: Wed, 20 Feb 2019 11:30:47 +0100
  4. Subject: [PATCH] brcmfmac: add basic validation of shared RAM address
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. While experimenting with firmware loading I ended up in a state of
  9. firmware reporting shared RAM address 0x04000001. It was causing:
  10. [ 94.448015] Unable to handle kernel paging request at virtual address cd680001
  11. due to reading out of the mapped memory.
  12. This patch adds some basic validation to avoid kernel crashes due to the
  13. unexpected firmware behavior.
  14. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  15. Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  16. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  17. ---
  18. drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 6 ++++++
  19. 1 file changed, 6 insertions(+)
  20. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  21. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  22. @@ -1532,6 +1532,12 @@ static int brcmf_pcie_download_fw_nvram(
  23. brcmf_err(bus, "FW failed to initialize\n");
  24. return -ENODEV;
  25. }
  26. + if (sharedram_addr < devinfo->ci->rambase ||
  27. + sharedram_addr >= devinfo->ci->rambase + devinfo->ci->ramsize) {
  28. + brcmf_err(bus, "Invalid shared RAM address 0x%08x\n",
  29. + sharedram_addr);
  30. + return -ENODEV;
  31. + }
  32. brcmf_dbg(PCIE, "Shared RAM addr: 0x%08x\n", sharedram_addr);
  33. return (brcmf_pcie_init_share_ram_info(devinfo, sharedram_addr));