1. 19 2月, 2019 3 次提交
  2. 08 2月, 2019 5 次提交
  3. 01 2月, 2019 2 次提交
  4. 10 1月, 2019 4 次提交
  5. 08 1月, 2019 1 次提交
  6. 20 12月, 2018 2 次提交
  7. 13 12月, 2018 12 次提交
  8. 29 11月, 2018 3 次提交
    • L
      brcmfmac: Fix out of bounds memory access during fw load · b72c51a5
      Lyude Paul 提交于
      I ended up tracking down some rather nasty issues with f2fs (and other
      filesystem modules) constantly crashing on my kernel down to a
      combination of out of bounds memory accesses, one of which was coming
      from brcmfmac during module load:
      
      [   30.891382] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac4356-sdio for chip BCM4356/2
      [   30.894437] ==================================================================
      [   30.901581] BUG: KASAN: global-out-of-bounds in brcmf_fw_alloc_request+0x42c/0x480 [brcmfmac]
      [   30.909935] Read of size 1 at addr ffff2000024865df by task kworker/6:2/387
      [   30.916805]
      [   30.918261] CPU: 6 PID: 387 Comm: kworker/6:2 Tainted: G           O      4.20.0-rc3Lyude-Test+ #19
      [   30.927251] Hardware name: amlogic khadas-vim2/khadas-vim2, BIOS 2018.07-rc2-armbian 09/11/2018
      [   30.935964] Workqueue: events brcmf_driver_register [brcmfmac]
      [   30.941641] Call trace:
      [   30.944058]  dump_backtrace+0x0/0x3e8
      [   30.947676]  show_stack+0x14/0x20
      [   30.950968]  dump_stack+0x130/0x1c4
      [   30.954406]  print_address_description+0x60/0x25c
      [   30.959066]  kasan_report+0x1b4/0x368
      [   30.962683]  __asan_report_load1_noabort+0x18/0x20
      [   30.967547]  brcmf_fw_alloc_request+0x42c/0x480 [brcmfmac]
      [   30.967639]  brcmf_sdio_probe+0x163c/0x2050 [brcmfmac]
      [   30.978035]  brcmf_ops_sdio_probe+0x598/0xa08 [brcmfmac]
      [   30.983254]  sdio_bus_probe+0x190/0x398
      [   30.983270]  really_probe+0x2a0/0xa70
      [   30.983296]  driver_probe_device+0x1b4/0x2d8
      [   30.994901]  __driver_attach+0x200/0x280
      [   30.994914]  bus_for_each_dev+0x10c/0x1a8
      [   30.994925]  driver_attach+0x38/0x50
      [   30.994935]  bus_add_driver+0x330/0x608
      [   30.994953]  driver_register+0x140/0x388
      [   31.013965]  sdio_register_driver+0x74/0xa0
      [   31.014076]  brcmf_sdio_register+0x14/0x60 [brcmfmac]
      [   31.023177]  brcmf_driver_register+0xc/0x18 [brcmfmac]
      [   31.023209]  process_one_work+0x654/0x1080
      [   31.032266]  worker_thread+0x4f0/0x1308
      [   31.032286]  kthread+0x2a8/0x320
      [   31.039254]  ret_from_fork+0x10/0x1c
      [   31.039269]
      [   31.044226] The buggy address belongs to the variable:
      [   31.044351]  brcmf_firmware_path+0x11f/0xfffffffffffd3b40 [brcmfmac]
      [   31.055601]
      [   31.057031] Memory state around the buggy address:
      [   31.061800]  ffff200002486480: 04 fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
      [   31.068983]  ffff200002486500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      [   31.068993] >ffff200002486580: 00 00 00 00 00 00 00 00 fa fa fa fa 00 00 00 00
      [   31.068999]                                                     ^
      [   31.069017]  ffff200002486600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      [   31.096521]  ffff200002486680: 00 00 00 00 00 00 00 00 00 00 00 00 fa fa fa fa
      [   31.096528] ==================================================================
      [   31.096533] Disabling lock debugging due to kernel taint
      
      It appears that when trying to determine the length of the string in the
      alternate firmware path, we make the mistake of not handling the case
      where the firmware path is empty correctly. Since strlen(mp_path) can
      return 0, we'll end up accessing mp_path[-1] when the firmware_path
      isn't provided through the module arguments.
      
      So, fix this by just setting the end char to '\0' by default, and only
      changing it if we have a non-zero length. Additionally, use strnlen()
      with BRCMF_FW_ALTPATH_LEN instead of strlen() just to be extra safe.
      
      Fixes: 2baa3aae ("brcmfmac: introduce brcmf_fw_alloc_request() function")
      Cc: Hante Meuleman <hante.meuleman@broadcom.com>
      Cc: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
      Cc: Franky Lin <franky.lin@broadcom.com>
      Cc: Arend van Spriel <arend.vanspriel@broadcom.com>
      Cc: Kalle Valo <kvalo@codeaurora.org>
      Cc: Arend Van Spriel <arend.vanspriel@broadcom.com>
      Cc: Himanshu Jha <himanshujha199640@gmail.com>
      Cc: Dan Haab <dhaab@luxul.com>
      Cc: Jia-Shyr Chuang <saint.chuang@cypress.com>
      Cc: Ian Molton <ian@mnementh.co.uk>
      Cc: <stable@vger.kernel.org> # v4.17+
      Signed-off-by: NLyude Paul <lyude@redhat.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      b72c51a5
    • H
      brcmfmac: Call brcmf_dmi_probe before brcmf_of_probe · 554da386
      Hans de Goede 提交于
      ARM systems with UEFI may have both devicetree (of) and DMI data in this
      case we end up setting brcmf_mp_device.board_type twice.
      
      In this case we should prefer the devicetree data, because:
      1) The devicerree data is more reliable
      2) Some ARM systems (e.g. the Raspberry Pi 3 models) support both UEFI and
         classic uboot booting, the devicetree data is always there, so using it
         makes sure we ask for the same nvram file independent of how we booted.
      
      This commit moves the brcmf_dmi_probe call to before the brcmf_of_probe
      call, so that the latter can override the value of the first if both are
      set.
      
      Fixes: bd1e82bb ("brcmfmac: Set board_type from DMI on x86 based ...")
      Cc: Peter Robinson <pbrobinson@gmail.com>
      Tested-and-reported-by: NPeter Robinson <pbrobinson@gmail.com>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      554da386
    • D
      brcmfmac: support STA info struct v7 · 4282ff17
      Dan Haab 提交于
      The newest firmwares provide STA info using v7 of the struct. As v7
      isn't backward compatible, a union is needed.
      
      Even though brcmfmac does not use any of the new info it's important to
      provide the proper struct buffer. Without this change new firmwares will
      fallback to the very limited v3 instead of something in between such as
      v4.
      Signed-off-by: NDan Haab <dan.haab@luxul.com>
      Reviewed-by: NRafał Miłecki <rafal@milecki.pl>
      Reviewed-by: NArend van Spriel <arend.vanspriel@broadcom.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      4282ff17
  9. 16 11月, 2018 1 次提交
  10. 11 11月, 2018 1 次提交
    • D
      brcmfmac: Use standard SKB list accessors in brcmf_sdiod_sglist_rw. · 4a5a553d
      David S. Miller 提交于
      Instead of direct SKB list pointer accesses.
      
      The loops in this function had to be rewritten to accommodate this
      more easily.
      
      The first loop iterates now over the target list in the outer loop,
      and triggers an mmc data operation when the per-operation limits are
      hit.
      
      Then after the loops, if we have any residue, we trigger the last
      and final operation.
      
      For the page aligned workaround, where we have to copy the read data
      back into the original list of SKBs, we use a two-tiered loop.  The
      outer loop stays the same and iterates over pktlist, and then we have
      an inner loop which uses skb_peek_next().  The break logic has been
      simplified because we know that the aggregate length of the SKBs in
      the source and destination lists are the same.
      
      This change also ends up fixing a bug, having to do with the
      maintainance of the seg_sz variable and how it drove the outermost
      loop.  It begins as:
      
      	seg_sz = target_list->qlen;
      
      ie. the number of packets in the target_list queue.  The loop
      structure was then:
      
      	while (seq_sz) {
      		...
      		while (not at end of target_list) {
      			...
      			sg_cnt++
      			...
      		}
      		...
      		seg_sz -= sg_cnt;
      
      The assumption built into that last statement is that sg_cnt counts
      how many packets from target_list have been fully processed by the
      inner loop.  But this not true.
      
      If we hit one of the limits, such as the max segment size or the max
      request size, we will break and copy a partial packet then contine
      back up to the top of the outermost loop.
      
      With the new loops we don't have this problem as we don't guard the
      loop exit with a packet count, but instead use the progression of the
      pkt_next SKB through the list to the end.  The general structure is:
      
      	sg_cnt = 0;
      	skb_queue_walk(target_list, pkt_next) {
      		pkt_offset = 0;
      		...
      		sg_cnt++;
      		...
      		while (pkt_offset < pkt_next->len) {
      			pkt_offset += sg_data_size;
      			if (queued up max per request)
      				mmc_submit_one();
      		}
      	}
      	if (sg_cnt)
      		mmc_submit_one();
      
      The variables that maintain where we are in the MMC command state such
      as req_sz, sg_cnt, and sgl are reset when we emit one of these full
      sized requests.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4a5a553d
  11. 07 11月, 2018 6 次提交
    • C
      brcmfmac: fix spelling mistake "Retreiving" -> "Retrieving" · e966a79c
      Colin Ian King 提交于
      Trivial fix to spelling mistake in brcmf_err error message.
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Acked-by: NArend van Spriel <arend.vanspriel@broadcom.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      e966a79c
    • H
      brcmfmac: Fix ccode from EFI nvram when necessary · 29ec3394
      Hans de Goede 提交于
      In some cases the EFI-var stored nvram contains "ccode=ALL" or "ccode=XV"
      to specify "worldwide" compatible settings, but these 2 ccode-s do not work
      properly.
      
      I've tested the different known "worldwide" ccode-s used in various nvram
      sources with the latest firmwares from linux-firmware for various brcmfmac
      models, here is a simplified (*) table with what each setting results in:
      
      ALL: 12-14 disab, U-NII-1, U-NII-2 no-IR/radar, U-NII-3
      XV:  12-14 no-IR, disables all 5G channels
      XY:  12-13 enab, 14 disab, U-NII-1 enab, U-NII-2 no-IR/radar, U-NII-3 disab
      X2:  12-13 no-IR, 14 dis, U-NII-1 no-IR, U-NII-2 no-IR/radar, U-NII-3 no-IR
      
      Where 12,13,14 are 2.4G channels 12-14 and U-NII-1/2/3 are the 3 different
      5G channel groups. no-IR is no-Initiate-Radiation, we will never send on
      these channels without first having received valid wifi traffic there.
      
      This immediately shows that both ALL and XV are not as worldwide as we want
      them to be. ALL causes channels 12 and 13 to not be available and XV causes
      all 5GHz channels to not be available. Also ALL unconditionally enables the
      U-NII-1 and U-NII-3 5G groups, while we really should be using no-IR for
      these.
      
      This commit replace XV and ALL with X2, which allows usage of chan 12-13
      and 5G channels, but only after receiving valid wifi traffic there first.
      
      Note that this configure the firmware's channel limits, the kernels own
      regulatory restrictions based on e.g. regulatory info received from the
      access-point, will be applied on top of this.
      
      This fixes channels 12+13 not working on the Asus T200TA and the Lenovo
      Mixx 2 8 and 5G channels not working on the Asus T100HA.
      
      This has been tested on the following models: Acer Iconia Tab8 w1-810,
      Acer One 10, Asus T100CHI, Asus T100HA, Asus T100TA, Asus T200TA and a
      Lenovo Mixx 2 8.
      
      *) There are some exceptions to this table:
      1) On really old firmware e.g. linux-firmware's 2011 brcmfmac4330-sdio.bin
         ALL really means all, unconditionally enabling everything
      2) The exact meaning might be influenced by setting the regrev nvram var.
         Specifically using ccode=XV + regrev=1 on brcmfmac43241b4 leads to:
         12-14 no-ir, U-NII-1 no-ir, U-NII-2 no-ir/radar, U-NII-3 no-ir
         But only on the brcmfmac43241b4 and not on e.g. the brcmfmac43340
      Tested-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      29ec3394
    • H
      brcmfmac: Add support for getting nvram contents from EFI variables · ce2e6db5
      Hans de Goede 提交于
      Various X86 laptops with a SDIO attached brcmfmac wifi chip, store the
      nvram contents in a special EFI variable. This commit adds support for
      getting nvram directly from this EFI variable, without the user needing
      to manually copy it.
      
      This makes Wifi / Bluetooth work out of the box on these devices instead of
      requiring manual setup.
      
      This has been tested on the following models: Acer Iconia Tab8 w1-810,
      Acer One 10, Asus T100CHI, Asus T100HA, Asus T100TA, Asus T200TA and a
      Lenovo Mixx 2 8.
      Tested-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      ce2e6db5
    • H
      brcmfmac: Cleanup brcmf_fw_request_done() · 55e491ed
      Hans de Goede 提交于
      The "cur" variable is now only used for a debug print and we already
      print the same info from brcmf_fw_complete_request(), so the debug print
      does not provide any extra info and we can remove it.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      55e491ed
    • H
      brcmfmac: Set board_type from DMI on x86 based machines · bd1e82bb
      Hans de Goede 提交于
      For x86 based machines, set the board_type used for nvram file selection
      based on the DMI sys-vendor and product-name strings.
      
      Since on some models these strings are too generic, this commit also adds
      a quirk table overriding the strings for models listed in that table.
      
      The board_type setting is used to load the board-specific nvram file with
      a board-specific name so that we can ship files for each supported board
      in linux-firmware.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      bd1e82bb
    • H
      brcmfmac: Set board_type used for nvram file selection to machine-compatible · 0ad4b55b
      Hans de Goede 提交于
      For of/devicetree using machines, set the board_type used for nvram file
      selection to the first string listed in the top-level's node compatible
      string, aka the machine-compatible as used by of_machine_is_compatible().
      
      The board_type setting is used to load the board-specific nvram file with
      a board-specific name so that we can ship files for each supported board
      in linux-firmware.
      Signed-off-by: NHans de Goede <hdegoede@redhat.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      0ad4b55b