1. 16 8月, 2019 5 次提交
  2. 04 8月, 2019 1 次提交
  3. 26 7月, 2019 19 次提交
    • E
      iwlwifi: fix RF-Kill interrupt while FW load for gen2 devices · 6825ff01
      Emmanuel Grumbach 提交于
      commit ed3e4c6d3cd8f093a3636cb05492429fe2af228d upstream.
      
      Newest devices have a new firmware load mechanism. This
      mechanism is called the context info. It means that the
      driver doesn't need to load the sections of the firmware.
      The driver rather prepares a place in DRAM, with pointers
      to the relevant sections of the firmware, and the firmware
      loads itself.
      At the end of the process, the firmware sends the ALIVE
      interrupt. This is different from the previous scheme in
      which the driver expected the FH_TX interrupt after each
      section being transferred over the DMA.
      
      In order to support this new flow, we enabled all the
      interrupts. This broke the assumption that we have in the
      code that the RF-Kill interrupt can't interrupt the firmware
      load flow.
      
      Change the context info flow to enable only the ALIVE
      interrupt, and re-enable all the other interrupts only
      after the firmware is alive. Then, we won't see the RF-Kill
      interrupt until then. Getting the RF-Kill interrupt while
      loading the firmware made us kill the firmware while it is
      loading and we ended up dumping garbage instead of the firmware
      state.
      
      Re-enable the ALIVE | RX interrupts from the ISR when we
      get the ALIVE interrupt to be able to get the RX interrupt
      that comes immediately afterwards for the ALIVE
      notification. This is needed for non MSI-X only.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NEmmanuel Grumbach <emmanuel.grumbach@intel.com>
      Signed-off-by: NLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6825ff01
    • E
      iwlwifi: don't WARN when calling iwl_get_shared_mem_conf with RF-Kill · a32e2cec
      Emmanuel Grumbach 提交于
      commit 0d53cfd0cca3c729a089c39eef0e7d8ae7662974 upstream.
      
      iwl_mvm_send_cmd returns 0 when the command won't be sent
      because RF-Kill is asserted. Do the same when we call
      iwl_get_shared_mem_conf since it is not sent through
      iwl_mvm_send_cmd but directly calls the transport layer.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NEmmanuel Grumbach <emmanuel.grumbach@intel.com>
      Signed-off-by: NLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a32e2cec
    • E
      iwlwifi: pcie: fix ALIVE interrupt handling for gen2 devices w/o MSI-X · d9ce0788
      Emmanuel Grumbach 提交于
      commit ec46ae30245ecb41d73f8254613db07c653fb498 upstream.
      
      We added code to restock the buffer upon ALIVE interrupt
      when MSI-X is disabled. This was added as part of the context
      info code. This code was added only if the ISR debug level
      is set which is very unlikely to be related.
      Move this code to run even when the ISR debug level is not
      set.
      
      Note that gen2 devices work with MSI-X in most cases so that
      this path is seldom used.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NEmmanuel Grumbach <emmanuel.grumbach@intel.com>
      Signed-off-by: NLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d9ce0788
    • E
      iwlwifi: pcie: don't service an interrupt that was masked · 04c52c10
      Emmanuel Grumbach 提交于
      commit 3b57a10ca14c619707398dc58fe5ece18c95b20b upstream.
      
      Sometimes the register status can include interrupts that
      were masked. We can, for example, get the RF-Kill bit set
      in the interrupt status register although this interrupt
      was masked. Then if we get the ALIVE interrupt (for example)
      that was not masked, we need to *not* service the RF-Kill
      interrupt.
      Fix this in the MSI-X interrupt handler.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NEmmanuel Grumbach <emmanuel.grumbach@intel.com>
      Signed-off-by: NLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      04c52c10
    • A
      iwlwifi: mvm: Drop large non sta frames · af3790a4
      Andrei Otcheretianski 提交于
      [ Upstream commit ac70499ee97231a418dc1a4d6c9dc102e8f64631 ]
      
      In some buggy scenarios we could possible attempt to transmit frames larger
      than maximum MSDU size. Since our devices don't know how to handle this,
      it may result in asserts, hangs etc.
      This can happen, for example, when we receive a large multicast frame
      and try to transmit it back to the air in AP mode.
      Since in a legal scenario this should never happen, drop such frames and
      warn about it.
      Signed-off-by: NAndrei Otcheretianski <andrei.otcheretianski@intel.com>
      Signed-off-by: NLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      af3790a4
    • W
      ath10k: destroy sdio workqueue while remove sdio module · 05592b9b
      Wen Gong 提交于
      [ Upstream commit 3ed39f8e747a7aafeec07bb244f2c3a1bdca5730 ]
      
      The workqueue need to flush and destory while remove sdio module,
      otherwise it will have thread which is not destory after remove
      sdio modules.
      
      Tested with QCA6174 SDIO with firmware
      WLAN.RMH.4.4.1-00007-QCARMSWP-1.
      Signed-off-by: NWen Gong <wgong@codeaurora.org>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      05592b9b
    • A
      wil6210: drop old event after wmi_call timeout · e54cc89e
      Ahmad Masri 提交于
      [ Upstream commit 1a276003111c0404f6bfeffe924c5a21f482428b ]
      
      This change fixes a rare race condition of handling WMI events after
      wmi_call expires.
      
      wmi_recv_cmd immediately handles an event when reply_buf is defined and
      a wmi_call is waiting for the event.
      However, in case the wmi_call has already timed-out, there will be no
      waiting/running wmi_call and the event will be queued in WMI queue and
      will be handled later in wmi_event_handle.
      Meanwhile, a new similar wmi_call for the same command and event may
      be issued. In this case, when handling the queued event we got WARN_ON
      printed.
      
      Fixing this case as a valid timeout and drop the unexpected event.
      Signed-off-by: NAhmad Masri <amasri@codeaurora.org>
      Signed-off-by: NMaya Erez <merez@codeaurora.org>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      e54cc89e
    • M
      ath10k: fix PCIE device wake up failed · 7201cc22
      Miaoqing Pan 提交于
      [ Upstream commit 011d4111c8c602ea829fa4917af1818eb0500a90 ]
      
      Observed PCIE device wake up failed after ~120 iterations of
      soft-reboot test. The error message is
      "ath10k_pci 0000:01:00.0: failed to wake up device : -110"
      
      The call trace as below:
      ath10k_pci_probe -> ath10k_pci_force_wake -> ath10k_pci_wake_wait ->
      ath10k_pci_is_awake
      
      Once trigger the device to wake up, we will continuously check the RTC
      state until it returns RTC_STATE_V_ON or timeout.
      
      But for QCA99x0 chips, we use wrong value for RTC_STATE_V_ON.
      Occasionally, we get 0x7 on the fist read, we thought as a failure
      case, but actually is the right value, also verified with the spec.
      So fix the issue by changing RTC_STATE_V_ON from 0x5 to 0x7, passed
      ~2000 iterations.
      
      Tested HW: QCA9984
      Signed-off-by: NMiaoqing Pan <miaoqing@codeaurora.org>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      7201cc22
    • C
      ath10k: add missing error handling · 8a808fad
      Claire Chang 提交于
      [ Upstream commit 4b553f3ca4cbde67399aa3a756c37eb92145b8a1 ]
      
      In function ath10k_sdio_mbox_rx_alloc() [sdio.c],
      ath10k_sdio_mbox_alloc_rx_pkt() is called without handling the error cases.
      This will make the driver think the allocation for skb is successful and
      try to access the skb. If we enable failslab, system will easily crash with
      NULL pointer dereferencing.
      
      Call trace of CONFIG_FAILSLAB:
      ath10k_sdio_irq_handler+0x570/0xa88 [ath10k_sdio]
      process_sdio_pending_irqs+0x4c/0x174
      sdio_run_irqs+0x3c/0x64
      sdio_irq_work+0x1c/0x28
      
      Fixes: d96db25d ("ath10k: add initial SDIO support")
      Signed-off-by: NClaire Chang <tientzu@chromium.org>
      Reviewed-by: NBrian Norris <briannorris@chromium.org>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      8a808fad
    • L
      mt7601u: fix possible memory leak when the device is disconnected · 20de38d2
      Lorenzo Bianconi 提交于
      [ Upstream commit 23377c200b2eb48a60d0f228b2a2e75ed6ee6060 ]
      
      When the device is disconnected while passing traffic it is possible
      to receive out of order urbs causing a memory leak since the skb linked
      to the current tx urb is not removed. Fix the issue deallocating the skb
      cleaning up the tx ring. Moreover this patch fixes the following kernel
      warning
      
      [   57.480771] usb 1-1: USB disconnect, device number 2
      [   57.483451] ------------[ cut here ]------------
      [   57.483462] TX urb mismatch
      [   57.483481] WARNING: CPU: 1 PID: 32 at drivers/net/wireless/mediatek/mt7601u/dma.c:245 mt7601u_complete_tx+0x165/00
      [   57.483483] Modules linked in:
      [   57.483496] CPU: 1 PID: 32 Comm: kworker/1:1 Not tainted 5.2.0-rc1+ #72
      [   57.483498] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.12.0-2.fc30 04/01/2014
      [   57.483502] Workqueue: usb_hub_wq hub_event
      [   57.483507] RIP: 0010:mt7601u_complete_tx+0x165/0x1e0
      [   57.483510] Code: 8b b5 10 04 00 00 8b 8d 14 04 00 00 eb 8b 80 3d b1 cb e1 00 00 75 9e 48 c7 c7 a4 ea 05 82 c6 05 f
      [   57.483513] RSP: 0000:ffffc900000a0d28 EFLAGS: 00010092
      [   57.483516] RAX: 000000000000000f RBX: ffff88802c0a62c0 RCX: ffffc900000a0c2c
      [   57.483518] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffff810a8371
      [   57.483520] RBP: ffff88803ced6858 R08: 0000000000000000 R09: 0000000000000001
      [   57.483540] R10: 0000000000000002 R11: 0000000000000000 R12: 0000000000000046
      [   57.483542] R13: ffff88802c0a6c88 R14: ffff88803baab540 R15: ffff88803a0cc078
      [   57.483548] FS:  0000000000000000(0000) GS:ffff88803eb00000(0000) knlGS:0000000000000000
      [   57.483550] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   57.483552] CR2: 000055e7f6780100 CR3: 0000000028c86000 CR4: 00000000000006a0
      [   57.483554] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [   57.483556] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [   57.483559] Call Trace:
      [   57.483561]  <IRQ>
      [   57.483565]  __usb_hcd_giveback_urb+0x77/0xe0
      [   57.483570]  xhci_giveback_urb_in_irq.isra.0+0x8b/0x140
      [   57.483574]  handle_cmd_completion+0xf5b/0x12c0
      [   57.483577]  xhci_irq+0x1f6/0x1810
      [   57.483581]  ? lockdep_hardirqs_on+0x9e/0x180
      [   57.483584]  ? _raw_spin_unlock_irq+0x24/0x30
      [   57.483588]  __handle_irq_event_percpu+0x3a/0x260
      [   57.483592]  handle_irq_event_percpu+0x1c/0x60
      [   57.483595]  handle_irq_event+0x2f/0x4c
      [   57.483599]  handle_edge_irq+0x7e/0x1a0
      [   57.483603]  handle_irq+0x17/0x20
      [   57.483607]  do_IRQ+0x54/0x110
      [   57.483610]  common_interrupt+0xf/0xf
      [   57.483612]  </IRQ>
      Acked-by: NJakub Kicinski <kubakici@wp.pl>
      Signed-off-by: NLorenzo Bianconi <lorenzo@kernel.org>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      20de38d2
    • L
      mt7601u: do not schedule rx_tasklet when the device has been disconnected · 3f7952b2
      Lorenzo Bianconi 提交于
      [ Upstream commit 4079e8ccabc3b6d1b503f2376123cb515d14921f ]
      
      Do not schedule rx_tasklet when the usb dongle is disconnected.
      Moreover do not grub rx_lock in mt7601u_kill_rx since usb_poison_urb
      can run concurrently with urb completion and we can unlink urbs from rx
      ring in any order.
      This patch fixes the common kernel warning reported when
      the device is removed.
      
      [   24.921354] usb 3-14: USB disconnect, device number 7
      [   24.921593] ------------[ cut here ]------------
      [   24.921594] RX urb mismatch
      [   24.921675] WARNING: CPU: 4 PID: 163 at drivers/net/wireless/mediatek/mt7601u/dma.c:200 mt7601u_complete_rx+0xcb/0xd0 [mt7601u]
      [   24.921769] CPU: 4 PID: 163 Comm: kworker/4:2 Tainted: G           OE     4.19.31-041931-generic #201903231635
      [   24.921770] Hardware name: To Be Filled By O.E.M. To Be Filled By O.E.M./Z97 Extreme4, BIOS P1.30 05/23/2014
      [   24.921782] Workqueue: usb_hub_wq hub_event
      [   24.921797] RIP: 0010:mt7601u_complete_rx+0xcb/0xd0 [mt7601u]
      [   24.921800] RSP: 0018:ffff9bd9cfd03d08 EFLAGS: 00010086
      [   24.921802] RAX: 0000000000000000 RBX: ffff9bd9bf043540 RCX: 0000000000000006
      [   24.921803] RDX: 0000000000000007 RSI: 0000000000000096 RDI: ffff9bd9cfd16420
      [   24.921804] RBP: ffff9bd9cfd03d28 R08: 0000000000000002 R09: 00000000000003a8
      [   24.921805] R10: 0000002f485fca34 R11: 0000000000000000 R12: ffff9bd9bf043c1c
      [   24.921806] R13: ffff9bd9c62fa3c0 R14: 0000000000000082 R15: 0000000000000000
      [   24.921807] FS:  0000000000000000(0000) GS:ffff9bd9cfd00000(0000) knlGS:0000000000000000
      [   24.921808] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   24.921808] CR2: 00007fb2648b0000 CR3: 0000000142c0a004 CR4: 00000000001606e0
      [   24.921809] Call Trace:
      [   24.921812]  <IRQ>
      [   24.921819]  __usb_hcd_giveback_urb+0x8b/0x140
      [   24.921821]  usb_hcd_giveback_urb+0xca/0xe0
      [   24.921828]  xhci_giveback_urb_in_irq.isra.42+0x82/0xf0
      [   24.921834]  handle_cmd_completion+0xe02/0x10d0
      [   24.921837]  xhci_irq+0x274/0x4a0
      [   24.921838]  xhci_msi_irq+0x11/0x20
      [   24.921851]  __handle_irq_event_percpu+0x44/0x190
      [   24.921856]  handle_irq_event_percpu+0x32/0x80
      [   24.921861]  handle_irq_event+0x3b/0x5a
      [   24.921867]  handle_edge_irq+0x80/0x190
      [   24.921874]  handle_irq+0x20/0x30
      [   24.921889]  do_IRQ+0x4e/0xe0
      [   24.921891]  common_interrupt+0xf/0xf
      [   24.921892]  </IRQ>
      [   24.921900] RIP: 0010:usb_hcd_flush_endpoint+0x78/0x180
      [   24.921354] usb 3-14: USB disconnect, device number 7
      Signed-off-by: NLorenzo Bianconi <lorenzo@kernel.org>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      3f7952b2
    • P
      rtlwifi: rtl8192cu: fix error handle when usb probe failed · 6f6e126e
      Ping-Ke Shih 提交于
      [ Upstream commit 6c0ed66f1a5b84e2a812c7c2d6571a5621bf3396 ]
      
      rtl_usb_probe() must do error handle rtl_deinit_core() only if
      rtl_init_core() is done, otherwise goto error_out2.
      
      | usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
      | rtl_usb: reg 0xf0, usbctrl_vendorreq TimeOut! status:0xffffffb9 value=0x0
      | rtl8192cu: Chip version 0x10
      | rtl_usb: reg 0xa, usbctrl_vendorreq TimeOut! status:0xffffffb9 value=0x0
      | rtl_usb: Too few input end points found
      | INFO: trying to register non-static key.
      | the code is fine but needs lockdep annotation.
      | turning off the locking correctness validator.
      | CPU: 0 PID: 12 Comm: kworker/0:1 Not tainted 5.1.0-rc4-319354-g9a33b36 #3
      | Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
      | Google 01/01/2011
      | Workqueue: usb_hub_wq hub_event
      | Call Trace:
      |   __dump_stack lib/dump_stack.c:77 [inline]
      |   dump_stack+0xe8/0x16e lib/dump_stack.c:113
      |   assign_lock_key kernel/locking/lockdep.c:786 [inline]
      |   register_lock_class+0x11b8/0x1250 kernel/locking/lockdep.c:1095
      |   __lock_acquire+0xfb/0x37c0 kernel/locking/lockdep.c:3582
      |   lock_acquire+0x10d/0x2f0 kernel/locking/lockdep.c:4211
      |   __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
      |   _raw_spin_lock_irqsave+0x44/0x60 kernel/locking/spinlock.c:152
      |   rtl_c2hcmd_launcher+0xd1/0x390
      | drivers/net/wireless/realtek/rtlwifi/base.c:2344
      |   rtl_deinit_core+0x25/0x2d0 drivers/net/wireless/realtek/rtlwifi/base.c:574
      |   rtl_usb_probe.cold+0x861/0xa70
      | drivers/net/wireless/realtek/rtlwifi/usb.c:1093
      |   usb_probe_interface+0x31d/0x820 drivers/usb/core/driver.c:361
      |   really_probe+0x2da/0xb10 drivers/base/dd.c:509
      |   driver_probe_device+0x21d/0x350 drivers/base/dd.c:671
      |   __device_attach_driver+0x1d8/0x290 drivers/base/dd.c:778
      |   bus_for_each_drv+0x163/0x1e0 drivers/base/bus.c:454
      |   __device_attach+0x223/0x3a0 drivers/base/dd.c:844
      |   bus_probe_device+0x1f1/0x2a0 drivers/base/bus.c:514
      |   device_add+0xad2/0x16e0 drivers/base/core.c:2106
      |   usb_set_configuration+0xdf7/0x1740 drivers/usb/core/message.c:2021
      |   generic_probe+0xa2/0xda drivers/usb/core/generic.c:210
      |   usb_probe_device+0xc0/0x150 drivers/usb/core/driver.c:266
      |   really_probe+0x2da/0xb10 drivers/base/dd.c:509
      |   driver_probe_device+0x21d/0x350 drivers/base/dd.c:671
      |   __device_attach_driver+0x1d8/0x290 drivers/base/dd.c:778
      |   bus_for_each_drv+0x163/0x1e0 drivers/base/bus.c:454
      |   __device_attach+0x223/0x3a0 drivers/base/dd.c:844
      |   bus_probe_device+0x1f1/0x2a0 drivers/base/bus.c:514
      |   device_add+0xad2/0x16e0 drivers/base/core.c:2106
      |   usb_new_device.cold+0x537/0xccf drivers/usb/core/hub.c:2534
      |   hub_port_connect drivers/usb/core/hub.c:5089 [inline]
      |   hub_port_connect_change drivers/usb/core/hub.c:5204 [inline]
      |   port_event drivers/usb/core/hub.c:5350 [inline]
      |   hub_event+0x138e/0x3b00 drivers/usb/core/hub.c:5432
      |   process_one_work+0x90f/0x1580 kernel/workqueue.c:2269
      |   worker_thread+0x9b/0xe20 kernel/workqueue.c:2415
      |   kthread+0x313/0x420 kernel/kthread.c:253
      |   ret_from_fork+0x3a/0x50 arch/x86/entry/entry_64.S:352
      
      Reported-by: syzbot+1fcc5ef45175fc774231@syzkaller.appspotmail.com
      Signed-off-by: NPing-Ke Shih <pkshih@realtek.com>
      Acked-by: NLarry Finger <Larry.Finger@lwfinger.net>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      6f6e126e
    • A
      ath: DFS JP domain W56 fixed pulse type 3 RADAR detection · 2b5b12c0
      Anilkumar Kolli 提交于
      [ Upstream commit d8792393a783158cbb2c39939cb897dc5e5299b6 ]
      
      Increase pulse width range from 1-2usec to 0-4usec.
      During data traffic HW occasionally fails detecting radar pulses,
      so that SW cannot get enough radar reports to achieve the success rate.
      
      Tested ath10k hw and fw:
      	* QCA9888(10.4-3.5.1-00052)
      	* QCA4019(10.4-3.2.1.1-00017)
      	* QCA9984(10.4-3.6-00104)
      	* QCA988X(10.2.4-1.0-00041)
      
      Tested ath9k hw: AR9300
      Tested-by: NTamizh chelvam <tamizhr@codeaurora.org>
      Signed-off-by: NTamizh chelvam <tamizhr@codeaurora.org>
      Signed-off-by: NAnilkumar Kolli <akolli@codeaurora.org>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      2b5b12c0
    • M
      wil6210: fix spurious interrupts in 3-msi · da153c0c
      Maya Erez 提交于
      [ Upstream commit e10b0eddd5235aa5aef4e40b970e34e735611a80 ]
      
      Interrupt is set in ICM (ICR & ~IMV) rising trigger.
      As the driver masks the IRQ after clearing it, there can
      be a race where an additional spurious interrupt is triggered
      when the driver unmask the IRQ.
      This can happen in case HW triggers an interrupt after the clear
      and before the mask.
      
      To prevent the second spurious interrupt the driver needs to mask the
      IRQ before reading and clearing it.
      Signed-off-by: NMaya Erez <merez@codeaurora.org>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      da153c0c
    • W
      ath10k: add peer id check in ath10k_peer_find_by_id · a4bf4fec
      Wen Gong 提交于
      [ Upstream commit 49ed34b835e231aa941257394716bc689bc98d9f ]
      
      For some SDIO chip, the peer id is 65535 for MPDU with error status,
      then test_bit will trigger buffer overflow for peer's memory, if kasan
      enabled, it will report error.
      
      Reason is when station is in disconnecting status, firmware do not delete
      the peer info since it not disconnected completely, meanwhile some AP will
      still send data packet to station, then hardware will receive the packet
      and send to firmware, firmware's logic will report peer id of 65535 for
      MPDU with error status.
      
      Add check for overflow the size of peer's peer_ids will avoid the buffer
      overflow access.
      
      Call trace of kasan:
      dump_backtrace+0x0/0x2ec
      show_stack+0x20/0x2c
      __dump_stack+0x20/0x28
      dump_stack+0xc8/0xec
      print_address_description+0x74/0x240
      kasan_report+0x250/0x26c
      __asan_report_load8_noabort+0x20/0x2c
      ath10k_peer_find_by_id+0x180/0x1e4 [ath10k_core]
      ath10k_htt_t2h_msg_handler+0x100c/0x2fd4 [ath10k_core]
      ath10k_htt_htc_t2h_msg_handler+0x20/0x34 [ath10k_core]
      ath10k_sdio_irq_handler+0xcc8/0x1678 [ath10k_sdio]
      process_sdio_pending_irqs+0xec/0x370
      sdio_run_irqs+0x68/0xe4
      sdio_irq_work+0x1c/0x28
      process_one_work+0x3d8/0x8b0
      worker_thread+0x508/0x7cc
      kthread+0x24c/0x264
      ret_from_fork+0x10/0x18
      
      Tested with QCA6174 SDIO with firmware
      WLAN.RMH.4.4.1-00007-QCARMSWP-1.
      Signed-off-by: NWen Gong <wgong@codeaurora.org>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      a4bf4fec
    • D
      ath6kl: add some bounds checking · 83c911f4
      Dan Carpenter 提交于
      [ Upstream commit 5d6751eaff672ea77642e74e92e6c0ac7f9709ab ]
      
      The "ev->traffic_class" and "reply->ac" variables come from the network
      and they're used as an offset into the wmi->stream_exist_for_ac[] array.
      Those variables are u8 so they can be 0-255 but the stream_exist_for_ac[]
      array only has WMM_NUM_AC (4) elements.  We need to add a couple bounds
      checks to prevent array overflows.
      
      I also modified one existing check from "if (traffic_class > 3) {" to
      "if (traffic_class >= WMM_NUM_AC) {" just to make them all consistent.
      
      Fixes: bdcd8170 (" Add ath6kl cleaned up driver")
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      83c911f4
    • T
      ath9k: Check for errors when reading SREV register · 42dcbf20
      Tim Schumacher 提交于
      [ Upstream commit 2f90c7e5d09437a4d8d5546feaae9f1cf48cfbe1 ]
      
      Right now, if an error is encountered during the SREV register
      read (i.e. an EIO in ath9k_regread()), that error code gets
      passed all the way to __ath9k_hw_init(), where it is visible
      during the "Chip rev not supported" message.
      
          ath9k_htc 1-1.4:1.0: ath9k_htc: HTC initialized with 33 credits
          ath: phy2: Mac Chip Rev 0x0f.3 is not supported by this driver
          ath: phy2: Unable to initialize hardware; initialization status: -95
          ath: phy2: Unable to initialize hardware; initialization status: -95
          ath9k_htc: Failed to initialize the device
      
      Check for -EIO explicitly in ath9k_hw_read_revisions() and return
      a boolean based on the success of the operation. Check for that in
      __ath9k_hw_init() and abort with a more debugging-friendly message
      if reading the revisions wasn't successful.
      
          ath9k_htc 1-1.4:1.0: ath9k_htc: HTC initialized with 33 credits
          ath: phy2: Failed to read SREV register
          ath: phy2: Could not read hardware revision
          ath: phy2: Unable to initialize hardware; initialization status: -95
          ath: phy2: Unable to initialize hardware; initialization status: -95
          ath9k_htc: Failed to initialize the device
      
      This helps when debugging by directly showing the first point of
      failure and it could prevent possible errors if a 0x0f.3 revision
      is ever supported.
      Signed-off-by: NTim Schumacher <timschumi@gmx.de>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      42dcbf20
    • S
      ath10k: Do not send probe response template for mesh · 7e19e658
      Surabhi Vishnoi 提交于
      [ Upstream commit 97354f2c432788e3163134df6bb144f4b6289d87 ]
      
      Currently mac80211 do not support probe response template for
      mesh point. When WMI_SERVICE_BEACON_OFFLOAD is enabled, host
      driver tries to configure probe response template for mesh, but
      it fails because the interface type is not NL80211_IFTYPE_AP but
      NL80211_IFTYPE_MESH_POINT.
      
      To avoid this failure, skip sending probe response template to
      firmware for mesh point.
      
      Tested HW: WCN3990/QCA6174/QCA9984
      Signed-off-by: NSurabhi Vishnoi <svishnoi@codeaurora.org>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      7e19e658
    • G
      wil6210: fix potential out-of-bounds read · 009edc62
      Gustavo A. R. Silva 提交于
      [ Upstream commit bfabdd6997323adbedccb13a3fed1967fb8cf8f5 ]
      
      Notice that *rc* can evaluate to up to 5, include/linux/netdevice.h:
      
      enum gro_result {
              GRO_MERGED,
              GRO_MERGED_FREE,
              GRO_HELD,
              GRO_NORMAL,
              GRO_DROP,
              GRO_CONSUMED,
      };
      typedef enum gro_result gro_result_t;
      
      In case *rc* evaluates to 5, we end up having an out-of-bounds read
      at drivers/net/wireless/ath/wil6210/txrx.c:821:
      
      	wil_dbg_txrx(wil, "Rx complete %d bytes => %s\n",
      		     len, gro_res_str[rc]);
      
      Fix this by adding element "GRO_CONSUMED" to array gro_res_str.
      
      Addresses-Coverity-ID: 1444666 ("Out-of-bounds read")
      Fixes: 194b482b ("wil6210: Debug print GRO Rx result")
      Signed-off-by: NGustavo A. R. Silva <gustavo@embeddedor.com>
      Reviewed-by: NMaya Erez <merez@codeaurora.org>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      009edc62
  4. 14 7月, 2019 7 次提交
    • C
      carl9170: fix misuse of device driver API · 486c3232
      Christian Lamparter 提交于
      commit feb09b2933275a70917a869989ea2823e7356be8 upstream.
      
      This patch follows Alan Stern's recent patch:
      "p54: Fix race between disconnect and firmware loading"
      
      that overhauled carl9170 buggy firmware loading and driver
      unbinding procedures.
      
      Since the carl9170 code was adapted from p54 it uses the
      same functions and is likely to have the same problem, but
      it's just that the syzbot hasn't reproduce them (yet).
      
      a summary from the changes (copied from the p54 patch):
       * Call usb_driver_release_interface() rather than
         device_release_driver().
      
       * Lock udev (the interface's parent) before unbinding the
         driver instead of locking udev->parent.
      
       * During the firmware loading process, take a reference
         to the USB interface instead of the USB device.
      
       * Don't take an unnecessary reference to the device during
         probe (and then don't drop it during disconnect).
      
      and
      
       * Make sure to prevent use-after-free bugs by explicitly
         setting the driver context to NULL after signaling the
         completion.
      
      Cc: <stable@vger.kernel.org>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NChristian Lamparter <chunkeey@gmail.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      486c3232
    • A
      p54usb: Fix race between disconnect and firmware loading · 449a8d08
      Alan Stern 提交于
      commit 6e41e2257f1094acc37618bf6c856115374c6922 upstream.
      
      The syzbot fuzzer found a bug in the p54 USB wireless driver.  The
      issue involves a race between disconnect and the firmware-loader
      callback routine, and it has several aspects.
      
      One big problem is that when the firmware can't be loaded, the
      callback routine tries to unbind the driver from the USB _device_ (by
      calling device_release_driver) instead of from the USB _interface_ to
      which it is actually bound (by calling usb_driver_release_interface).
      
      The race involves access to the private data structure.  The driver's
      disconnect handler waits for a completion that is signalled by the
      firmware-loader callback routine.  As soon as the completion is
      signalled, you have to assume that the private data structure may have
      been deallocated by the disconnect handler -- even if the firmware was
      loaded without errors.  However, the callback routine does access the
      private data several times after that point.
      
      Another problem is that, in order to ensure that the USB device
      structure hasn't been freed when the callback routine runs, the driver
      takes a reference to it.  This isn't good enough any more, because now
      that the callback routine calls usb_driver_release_interface, it has
      to ensure that the interface structure hasn't been freed.
      
      Finally, the driver takes an unnecessary reference to the USB device
      structure in the probe function and drops the reference in the
      disconnect handler.  This extra reference doesn't accomplish anything,
      because the USB core already guarantees that a device structure won't
      be deallocated while a driver is still bound to any of its interfaces.
      
      To fix these problems, this patch makes the following changes:
      
      	Call usb_driver_release_interface() rather than
      	device_release_driver().
      
      	Don't signal the completion until after the important
      	information has been copied out of the private data structure,
      	and don't refer to the private data at all thereafter.
      
      	Lock udev (the interface's parent) before unbinding the driver
      	instead of locking udev->parent.
      
      	During the firmware loading process, take a reference to the
      	USB interface instead of the USB device.
      
      	Don't take an unnecessary reference to the device during probe
      	(and then don't drop it during disconnect).
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Reported-and-tested-by: syzbot+200d4bb11b23d929335f@syzkaller.appspotmail.com
      CC: <stable@vger.kernel.org>
      Acked-by: NChristian Lamparter <chunkeey@gmail.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      449a8d08
    • B
      mwifiex: Don't abort on small, spec-compliant vendor IEs · bb902b6c
      Brian Norris 提交于
      commit 63d7ef36103d26f20325a921ecc96a3288560146 upstream.
      
      Per the 802.11 specification, vendor IEs are (at minimum) only required
      to contain an OUI. A type field is also included in ieee80211.h (struct
      ieee80211_vendor_ie) but doesn't appear in the specification. The
      remaining fields (subtype, version) are a convention used in WMM
      headers.
      
      Thus, we should not reject vendor-specific IEs that have only the
      minimum length (3 bytes) -- we should skip over them (since we only want
      to match longer IEs, that match either WMM or WPA formats). We can
      reject elements that don't have the minimum-required 3 byte OUI.
      
      While we're at it, move the non-standard subtype and version fields into
      the WMM structs, to avoid this confusion in the future about generic
      "vendor header" attributes.
      
      Fixes: 685c9b7750bf ("mwifiex: Abort at too short BSS descriptor element")
      Cc: Takashi Iwai <tiwai@suse.de>
      Signed-off-by: NBrian Norris <briannorris@chromium.org>
      Reviewed-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb902b6c
    • T
      mwifiex: Abort at too short BSS descriptor element · ffbbd626
      Takashi Iwai 提交于
      commit 685c9b7750bfacd6fc1db50d86579980593b7869 upstream.
      
      Currently mwifiex_update_bss_desc_with_ie() implicitly assumes that
      the source descriptor entries contain the enough size for each type
      and performs copying without checking the source size.  This may lead
      to read over boundary.
      
      Fix this by putting the source size check in appropriate places.
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ffbbd626
    • T
      mwifiex: Fix heap overflow in mwifiex_uap_parse_tail_ies() · c7e427e2
      Takashi Iwai 提交于
      [ Upstream commit 69ae4f6aac1578575126319d3f55550e7e440449 ]
      
      A few places in mwifiex_uap_parse_tail_ies() perform memcpy()
      unconditionally, which may lead to either buffer overflow or read over
      boundary.
      
      This patch addresses the issues by checking the read size and the
      destination size at each place more properly.  Along with the fixes,
      the patch cleans up the code slightly by introducing a temporary
      variable for the token size, and unifies the error path with the
      standard goto statement.
      Reported-by: Nhuangwen <huangwen@venustech.com.cn>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      c7e427e2
    • J
      iwlwifi: Fix double-free problems in iwl_req_fw_callback() · 8e115a07
      Jia-Ju Bai 提交于
      [ Upstream commit a8627176b0de7ba3f4524f641ddff4abf23ae4e4 ]
      
      In the error handling code of iwl_req_fw_callback(), iwl_dealloc_ucode()
      is called to free data. In iwl_drv_stop(), iwl_dealloc_ucode() is called
      again, which can cause double-free problems.
      
      To fix this bug, the call to iwl_dealloc_ucode() in
      iwl_req_fw_callback() is deleted.
      
      This bug is found by a runtime fuzzing tool named FIZZER written by us.
      Signed-off-by: NJia-Ju Bai <baijiaju1990@gmail.com>
      Signed-off-by: NLuca Coelho <luciano.coelho@intel.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      8e115a07
    • T
      mwifiex: Fix possible buffer overflows at parsing bss descriptor · d4c0f752
      Takashi Iwai 提交于
      [ Upstream commit 13ec7f10b87f5fc04c4ccbd491c94c7980236a74 ]
      
      mwifiex_update_bss_desc_with_ie() calls memcpy() unconditionally in
      a couple places without checking the destination size.  Since the
      source is given from user-space, this may trigger a heap buffer
      overflow.
      
      Fix it by putting the length check before performing memcpy().
      
      This fix addresses CVE-2019-3846.
      Reported-by: Nhuangwen <huangwen@venustech.com.cn>
      Signed-off-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      d4c0f752
  5. 25 6月, 2019 2 次提交
    • D
      brcmfmac: sdio: Don't tune while the card is off · d64f99ef
      Douglas Anderson 提交于
      commit 65dade6044079a5c206fd1803642ff420061417a upstream.
      
      When Broadcom SDIO cards are idled they go to sleep and a whole
      separate subsystem takes over their SDIO communication.  This is the
      Always-On-Subsystem (AOS) and it can't handle tuning requests.
      
      Specifically, as tested on rk3288-veyron-minnie (which reports having
      BCM4354/1 in dmesg), if I force a retune in brcmf_sdio_kso_control()
      when "on = 1" (aka we're transition from sleep to wake) by whacking:
        bus->sdiodev->func1->card->host->need_retune = 1
      ...then I can often see tuning fail.  In this case dw_mmc reports "All
      phases bad!").  Note that I don't get 100% failure, presumably because
      sometimes the card itself has already transitioned away from the AOS
      itself by the time we try to wake it up.  If I force retuning when "on
      = 0" (AKA force retuning right before sending the command to go to
      sleep) then retuning is always OK.
      
      NOTE: we need _both_ this patch and the patch to avoid triggering
      tuning due to CRC errors in the sleep/wake transition, AKA ("brcmfmac:
      sdio: Disable auto-tuning around commands expected to fail").  Though
      both patches handle issues with Broadcom's AOS, the problems are
      distinct:
      1. We want to defer (but not ignore) asynchronous (like
         timer-requested) tuning requests till the card is awake.  However,
         we want to ignore CRC errors during the transition, we don't want
         to queue deferred tuning request.
      2. You could imagine that the AOS could implement retuning but we
         could still get errors while transitioning in and out of the AOS.
         Similarly you could imagine a seamless transition into and out of
         the AOS (with no CRC errors) even if the AOS couldn't handle
         tuning.
      
      ALSO NOTE: presumably there is never a desperate need to retune in
      order to wake up the card, since doing so is impossible.  Luckily the
      only way the card can get into sleep state is if we had a good enough
      tuning to send it the command to put it into sleep, so presumably that
      "good enough" tuning is enough to wake us up, at least with a few
      retries.
      
      Cc: stable@vger.kernel.org #v4.18+
      Signed-off-by: NDouglas Anderson <dianders@chromium.org>
      Acked-by: NAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: NArend van Spriel <arend.vanspriel@broadcom.com>
      Acked-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d64f99ef
    • D
      brcmfmac: sdio: Disable auto-tuning around commands expected to fail · 0ad82f2e
      Douglas Anderson 提交于
      commit 2de0b42da263c97d330d276f5ccf7c4470e3324f upstream.
      
      There are certain cases, notably when transitioning between sleep and
      active state, when Broadcom SDIO WiFi cards will produce errors on the
      SDIO bus.  This is evident from the source code where you can see that
      we try commands in a loop until we either get success or we've tried
      too many times.  The comment in the code reinforces this by saying
      "just one write attempt may fail"
      
      Unfortunately these failures sometimes end up causing an "-EILSEQ"
      back to the core which triggers a retuning of the SDIO card and that
      blocks all traffic to the card until it's done.
      
      Let's disable retuning around the commands we expect might fail.
      
      Cc: stable@vger.kernel.org #v4.18+
      Signed-off-by: NDouglas Anderson <dianders@chromium.org>
      Acked-by: NAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: NArend van Spriel <arend.vanspriel@broadcom.com>
      Acked-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0ad82f2e
  6. 09 6月, 2019 1 次提交
    • P
      brcmfmac: fix NULL pointer derefence during USB disconnect · c18a0ecc
      Piotr Figiel 提交于
      commit 5cdb0ef6144f47440850553579aa923c20a63f23 upstream.
      
      In case USB disconnect happens at the moment transmitting workqueue is in
      progress the underlying interface may be gone causing a NULL pointer
      dereference. Add synchronization of the workqueue destruction with the
      detach implementation in core so that the transmitting workqueue is stopped
      during detach before the interfaces are removed.
      
      Fix following Oops:
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000008
      pgd = 9e6a802d
      [00000008] *pgd=00000000
      Internal error: Oops: 5 [#1] PREEMPT SMP ARM
      Modules linked in: nf_log_ipv4 nf_log_common xt_LOG xt_limit iptable_mangle
      xt_connmark xt_tcpudp xt_conntrack nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4
      iptable_filter ip_tables x_tables usb_f_mass_storage usb_f_rndis u_ether
      usb_serial_simple usbserial cdc_acm brcmfmac brcmutil smsc95xx usbnet
      ci_hdrc_imx ci_hdrc ulpi usbmisc_imx 8250_exar 8250_pci 8250 8250_base
      libcomposite configfs udc_core
      CPU: 0 PID: 7 Comm: kworker/u8:0 Not tainted 4.19.23-00076-g03740aa-dirty #102
      Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
      Workqueue: brcmf_fws_wq brcmf_fws_dequeue_worker [brcmfmac]
      PC is at brcmf_txfinalize+0x34/0x90 [brcmfmac]
      LR is at brcmf_fws_dequeue_worker+0x218/0x33c [brcmfmac]
      pc : [<7f0dee64>]    lr : [<7f0e4140>]    psr: 60010093
      sp : ee8abef0  ip : 00000000  fp : edf38000
      r10: ffffffed  r9 : edf38970  r8 : edf38004
      r7 : edf3e970  r6 : 00000000  r5 : ede69000  r4 : 00000000
      r3 : 00000a97  r2 : 00000000  r1 : 0000888e  r0 : ede69000
      Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment none
      Control: 10c5387d  Table: 7d03c04a  DAC: 00000051
      Process kworker/u8:0 (pid: 7, stack limit = 0x24ec3e04)
      Stack: (0xee8abef0 to 0xee8ac000)
      bee0:                                     ede69000 00000000 ed56c3e0 7f0e4140
      bf00: 00000001 00000000 edf38004 edf3e99c ed56c3e0 80d03d00 edfea43a edf3e970
      bf20: ee809880 ee804200 ee971100 00000000 edf3e974 00000000 ee804200 80135a70
      bf40: 80d03d00 ee804218 ee809880 ee809894 ee804200 80d03d00 ee804218 ee8aa000
      bf60: 00000088 80135d5c 00000000 ee829f00 ee829dc0 00000000 ee809880 80135d30
      bf80: ee829f1c ee873eac 00000000 8013b1a0 ee829dc0 8013b07c 00000000 00000000
      bfa0: 00000000 00000000 00000000 801010e8 00000000 00000000 00000000 00000000
      bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      bfe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
      [<7f0dee64>] (brcmf_txfinalize [brcmfmac]) from [<7f0e4140>] (brcmf_fws_dequeue_worker+0x218/0x33c [brcmfmac])
      [<7f0e4140>] (brcmf_fws_dequeue_worker [brcmfmac]) from [<80135a70>] (process_one_work+0x138/0x3f8)
      [<80135a70>] (process_one_work) from [<80135d5c>] (worker_thread+0x2c/0x554)
      [<80135d5c>] (worker_thread) from [<8013b1a0>] (kthread+0x124/0x154)
      [<8013b1a0>] (kthread) from [<801010e8>] (ret_from_fork+0x14/0x2c)
      Exception stack(0xee8abfb0 to 0xee8abff8)
      bfa0:                                     00000000 00000000 00000000 00000000
      bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      bfe0: 00000000 00000000 00000000 00000000 00000013 00000000
      Code: e1530001 0a000007 e3560000 e1a00005 (05942008)
      ---[ end trace 079239dd31c86e90 ]---
      Signed-off-by: NPiotr Figiel <p.figiel@camlintechnologies.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c18a0ecc
  7. 31 5月, 2019 5 次提交
    • L
      wil6210: fix return code of wmi_mgmt_tx and wmi_mgmt_tx_ext · da30c277
      Lior David 提交于
      [ Upstream commit 49122ec42634f73babb1dc96f170023e5228d080 ]
      
      The functions that send management TX frame have 3 possible
      results: success and other side acknowledged receive (ACK=1),
      success and other side did not acknowledge receive(ACK=0) and
      failure to send the frame. The current implementation
      incorrectly reports the ACK=0 case as failure.
      Signed-off-by: NLior David <liord@codeaurora.org>
      Signed-off-by: NMaya Erez <merez@codeaurora.org>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      da30c277
    • P
      rtlwifi: fix potential NULL pointer dereference · c9e44a1a
      Ping-Ke Shih 提交于
      [ Upstream commit 60209d482b97743915883d293c8b85226d230c19 ]
      
      In case dev_alloc_skb fails, the fix safely returns to avoid
      potential NULL pointer dereference.
      Signed-off-by: NPing-Ke Shih <pkshih@realtek.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      c9e44a1a
    • P
      brcmfmac: fix Oops when bringing up interface during USB disconnect · e29aba14
      Piotr Figiel 提交于
      [ Upstream commit 24d413a31afaee9bbbf79226052c386b01780ce2 ]
      
      Fix a race which leads to an Oops with NULL pointer dereference.  The
      dereference is in brcmf_config_dongle() when cfg_to_ndev() attempts to get
      net_device structure of interface with index 0 via if2bss mapping. This
      shouldn't fail because of check for bus being ready in brcmf_netdev_open(),
      but it's not synchronised with USB disconnect and there is a race: after
      the check the bus can be marked down and the mapping for interface 0 may be
      gone.
      
      Solve this by modifying disconnect handling so that the removal of mapping
      of ifidx to brcmf_if structure happens after netdev removal (which is
      synchronous with brcmf_netdev_open() thanks to rtln being locked in
      devinet_ioctl()). This assures brcmf_netdev_open() returns before the
      mapping is removed during disconnect.
      
      Unable to handle kernel NULL pointer dereference at virtual address 00000008
      pgd = bcae2612
      [00000008] *pgd=8be73831
      Internal error: Oops: 17 [#1] PREEMPT SMP ARM
      Modules linked in: brcmfmac brcmutil nf_log_ipv4 nf_log_common xt_LOG xt_limit
      iptable_mangle xt_connmark xt_tcpudp xt_conntrack nf_conntrack nf_defrag_ipv6
      nf_defrag_ipv4 iptable_filter ip_tables x_tables usb_f_mass_storage usb_f_rndis
      u_ether usb_serial_simple usbserial cdc_acm smsc95xx usbnet ci_hdrc_imx ci_hdrc
      usbmisc_imx ulpi 8250_exar 8250_pci 8250 8250_base libcomposite configfs
      udc_core [last unloaded: brcmutil]
      CPU: 2 PID: 24478 Comm: ifconfig Not tainted 4.19.23-00078-ga62866d-dirty #115
      Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
      PC is at brcmf_cfg80211_up+0x94/0x29c [brcmfmac]
      LR is at brcmf_cfg80211_up+0x8c/0x29c [brcmfmac]
      pc : [<7f26a91c>]    lr : [<7f26a914>]    psr: a0070013
      sp : eca99d28  ip : 00000000  fp : ee9c6c00
      r10: 00000036  r9 : 00000000  r8 : ece4002c
      r7 : edb5b800  r6 : 00000000  r5 : 80f08448  r4 : edb5b968
      r3 : ffffffff  r2 : 00000000  r1 : 00000002  r0 : 00000000
      Flags: NzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
      Control: 10c5387d  Table: 7ca0c04a  DAC: 00000051
      Process ifconfig (pid: 24478, stack limit = 0xd9e85a0e)
      Stack: (0xeca99d28 to 0xeca9a000)
      9d20:                   00000000 80f873b0 0000000d 80f08448 eca99d68 50d45f32
      9d40: 7f27de94 ece40000 80f08448 80f08448 7f27de94 ece4002c 00000000 00000036
      9d60: ee9c6c00 7f27262c 00001002 50d45f32 ece40000 00000000 80f08448 80772008
      9d80: 00000001 00001043 00001002 ece40000 00000000 50d45f32 ece40000 00000001
      9da0: 80f08448 00001043 00001002 807723d0 00000000 50d45f32 80f08448 eca99e58
      9dc0: 80f87113 50d45f32 80f08448 ece40000 ece40138 00001002 80f08448 00000000
      9de0: 00000000 80772434 edbd5380 eca99e58 edbd5380 80f08448 ee9c6c0c 80805f70
      9e00: 00000000 ede08e00 00008914 ece40000 00000014 ee9c6c0c 600c0013 00001043
      9e20: 0208a8c0 ffffffff 00000000 50d45f32 eca98000 80f08448 7ee9fc38 00008914
      9e40: 80f68e40 00000051 eca98000 00000036 00000003 80808b9c 6e616c77 00000030
      9e60: 00000000 00000000 00001043 0208a8c0 ffffffff 00000000 80f08448 00000000
      9e80: 00000000 816d8b20 600c0013 00000001 ede09320 801763d4 00000000 50d45f32
      9ea0: eca98000 80f08448 7ee9fc38 50d45f32 00008914 80f08448 7ee9fc38 80f68e40
      9ec0: ed531540 8074721c 00000800 00000001 00000000 6e616c77 00000030 00000000
      9ee0: 00000000 00001002 0208a8c0 ffffffff 00000000 50d45f32 80f08448 7ee9fc38
      9f00: ed531560 ec8fc900 80285a6c 80285138 edb910c0 00000000 ecd91008 ede08e00
      9f20: 80f08448 00000000 00000000 816d8b20 600c0013 00000001 ede09320 801763d4
      9f40: 00000000 50d45f32 00021000 edb91118 edb910c0 80f08448 01b29000 edb91118
      9f60: eca99f7c 50d45f32 00021000 ec8fc900 00000003 ec8fc900 00008914 7ee9fc38
      9f80: eca98000 00000036 00000003 80285a6c 00086364 7ee9fe1c 000000c3 00000036
      9fa0: 801011c4 80101000 00086364 7ee9fe1c 00000003 00008914 7ee9fc38 00086364
      9fc0: 00086364 7ee9fe1c 000000c3 00000036 0008630c 7ee9fe1c 7ee9fc38 00000003
      9fe0: 000a42b8 7ee9fbd4 00019914 76e09acc 600c0010 00000003 00000000 00000000
      [<7f26a91c>] (brcmf_cfg80211_up [brcmfmac]) from [<7f27262c>] (brcmf_netdev_open+0x74/0xe8 [brcmfmac])
      [<7f27262c>] (brcmf_netdev_open [brcmfmac]) from [<80772008>] (__dev_open+0xcc/0x150)
      [<80772008>] (__dev_open) from [<807723d0>] (__dev_change_flags+0x168/0x1b4)
      [<807723d0>] (__dev_change_flags) from [<80772434>] (dev_change_flags+0x18/0x48)
      [<80772434>] (dev_change_flags) from [<80805f70>] (devinet_ioctl+0x67c/0x79c)
      [<80805f70>] (devinet_ioctl) from [<80808b9c>] (inet_ioctl+0x210/0x3d4)
      [<80808b9c>] (inet_ioctl) from [<8074721c>] (sock_ioctl+0x350/0x524)
      [<8074721c>] (sock_ioctl) from [<80285138>] (do_vfs_ioctl+0xb0/0x9b0)
      [<80285138>] (do_vfs_ioctl) from [<80285a6c>] (ksys_ioctl+0x34/0x5c)
      [<80285a6c>] (ksys_ioctl) from [<80101000>] (ret_fast_syscall+0x0/0x28)
      Exception stack(0xeca99fa8 to 0xeca99ff0)
      9fa0:                   00086364 7ee9fe1c 00000003 00008914 7ee9fc38 00086364
      9fc0: 00086364 7ee9fe1c 000000c3 00000036 0008630c 7ee9fe1c 7ee9fc38 00000003
      9fe0: 000a42b8 7ee9fbd4 00019914 76e09acc
      Code: e5970328 eb002021 e1a02006 e3a01002 (e5909008)
      ---[ end trace 5cbac2333f3ac5df ]---
      Signed-off-by: NPiotr Figiel <p.figiel@camlintechnologies.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      e29aba14
    • P
      brcmfmac: fix race during disconnect when USB completion is in progress · 8a412ed9
      Piotr Figiel 提交于
      [ Upstream commit db3b9e2e1d58080d0754bdf9293dabf8c6491b67 ]
      
      It was observed that rarely during USB disconnect happening shortly after
      connect (before full initialization completes) usb_hub_wq would wait
      forever for the dev_init_lock to be unlocked. dev_init_lock would remain
      locked though because of infinite wait during usb_kill_urb:
      
      [ 2730.656472] kworker/0:2     D    0   260      2 0x00000000
      [ 2730.660700] Workqueue: events request_firmware_work_func
      [ 2730.664807] [<809dca20>] (__schedule) from [<809dd164>] (schedule+0x4c/0xac)
      [ 2730.670587] [<809dd164>] (schedule) from [<8069af44>] (usb_kill_urb+0xdc/0x114)
      [ 2730.676815] [<8069af44>] (usb_kill_urb) from [<7f258b50>] (brcmf_usb_free_q+0x34/0xa8 [brcmfmac])
      [ 2730.684833] [<7f258b50>] (brcmf_usb_free_q [brcmfmac]) from [<7f2517d4>] (brcmf_detach+0xa0/0xb8 [brcmfmac])
      [ 2730.693557] [<7f2517d4>] (brcmf_detach [brcmfmac]) from [<7f251a34>] (brcmf_attach+0xac/0x3d8 [brcmfmac])
      [ 2730.702094] [<7f251a34>] (brcmf_attach [brcmfmac]) from [<7f2587ac>] (brcmf_usb_probe_phase2+0x468/0x4a0 [brcmfmac])
      [ 2730.711601] [<7f2587ac>] (brcmf_usb_probe_phase2 [brcmfmac]) from [<7f252888>] (brcmf_fw_request_done+0x194/0x220 [brcmfmac])
      [ 2730.721795] [<7f252888>] (brcmf_fw_request_done [brcmfmac]) from [<805748e4>] (request_firmware_work_func+0x4c/0x88)
      [ 2730.731125] [<805748e4>] (request_firmware_work_func) from [<80141474>] (process_one_work+0x228/0x808)
      [ 2730.739223] [<80141474>] (process_one_work) from [<80141a80>] (worker_thread+0x2c/0x564)
      [ 2730.746105] [<80141a80>] (worker_thread) from [<80147bcc>] (kthread+0x13c/0x16c)
      [ 2730.752227] [<80147bcc>] (kthread) from [<801010b4>] (ret_from_fork+0x14/0x20)
      
      [ 2733.099695] kworker/0:3     D    0  1065      2 0x00000000
      [ 2733.103926] Workqueue: usb_hub_wq hub_event
      [ 2733.106914] [<809dca20>] (__schedule) from [<809dd164>] (schedule+0x4c/0xac)
      [ 2733.112693] [<809dd164>] (schedule) from [<809e2a8c>] (schedule_timeout+0x214/0x3e4)
      [ 2733.119621] [<809e2a8c>] (schedule_timeout) from [<809dde2c>] (wait_for_common+0xc4/0x1c0)
      [ 2733.126810] [<809dde2c>] (wait_for_common) from [<7f258d00>] (brcmf_usb_disconnect+0x1c/0x4c [brcmfmac])
      [ 2733.135206] [<7f258d00>] (brcmf_usb_disconnect [brcmfmac]) from [<8069e0c8>] (usb_unbind_interface+0x5c/0x1e4)
      [ 2733.143943] [<8069e0c8>] (usb_unbind_interface) from [<8056d3e8>] (device_release_driver_internal+0x164/0x1fc)
      [ 2733.152769] [<8056d3e8>] (device_release_driver_internal) from [<8056c078>] (bus_remove_device+0xd0/0xfc)
      [ 2733.161138] [<8056c078>] (bus_remove_device) from [<8056977c>] (device_del+0x11c/0x310)
      [ 2733.167939] [<8056977c>] (device_del) from [<8069cba8>] (usb_disable_device+0xa0/0x1cc)
      [ 2733.174743] [<8069cba8>] (usb_disable_device) from [<8069507c>] (usb_disconnect+0x74/0x1dc)
      [ 2733.181823] [<8069507c>] (usb_disconnect) from [<80695e88>] (hub_event+0x478/0xf88)
      [ 2733.188278] [<80695e88>] (hub_event) from [<80141474>] (process_one_work+0x228/0x808)
      [ 2733.194905] [<80141474>] (process_one_work) from [<80141a80>] (worker_thread+0x2c/0x564)
      [ 2733.201724] [<80141a80>] (worker_thread) from [<80147bcc>] (kthread+0x13c/0x16c)
      [ 2733.207913] [<80147bcc>] (kthread) from [<801010b4>] (ret_from_fork+0x14/0x20)
      
      It was traced down to a case where usb_kill_urb would be called on an URB
      structure containing more or less random data, including large number in
      its use_count. During the debugging it appeared that in brcmf_usb_free_q()
      the traversal over URBs' lists is not synchronized with operations on those
      lists in brcmf_usb_rx_complete() leading to handling
      brcmf_usbdev_info structure (holding lists' head) as lists' element and in
      result causing above problem.
      
      Fix it by walking through all URBs during brcmf_cancel_all_urbs using the
      arrays of requests instead of linked lists.
      Signed-off-by: NPiotr Figiel <p.figiel@camlintechnologies.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      8a412ed9
    • P
      brcmfmac: fix WARNING during USB disconnect in case of unempty psq · ce55a594
      Piotr Figiel 提交于
      [ Upstream commit c80d26e81ef1802f30364b4ad1955c1443a592b9 ]
      
      brcmu_pkt_buf_free_skb emits WARNING when attempting to free a sk_buff
      which is part of any queue. After USB disconnect this may have happened
      when brcmf_fws_hanger_cleanup() is called as per-interface psq was never
      cleaned when removing the interface.
      Change brcmf_fws_macdesc_cleanup() in a way that it removes the
      corresponding packets from hanger table (to avoid double-free when
      brcmf_fws_hanger_cleanup() is called) and add a call to clean-up the
      interface specific packet queue.
      
      Below is a WARNING during USB disconnect with Raspberry Pi WiFi dongle
      running in AP mode. This was reproducible when the interface was
      transmitting during the disconnect and is fixed with this commit.
      
      ------------[ cut here ]------------
      WARNING: CPU: 0 PID: 1171 at drivers/net/wireless/broadcom/brcm80211/brcmutil/utils.c:49 brcmu_pkt_buf_free_skb+0x3c/0x40
      Modules linked in: nf_log_ipv4 nf_log_common xt_LOG xt_limit iptable_mangle xt_connmark xt_tcpudp xt_conntrack nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 iptable_filter ip_tables x_tables usb_f_mass_storage usb_f_rndis u_ether cdc_acm smsc95xx usbnet ci_hdrc_imx ci_hdrc ulpi usbmisc_imx 8250_exar 8250_pci 8250 8250_base libcomposite configfs udc_core
      CPU: 0 PID: 1171 Comm: kworker/0:0 Not tainted 4.19.23-00075-gde33ed8 #99
      Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
      Workqueue: usb_hub_wq hub_event
      [<8010ff84>] (unwind_backtrace) from [<8010bb64>] (show_stack+0x10/0x14)
      [<8010bb64>] (show_stack) from [<80840278>] (dump_stack+0x88/0x9c)
      [<80840278>] (dump_stack) from [<8011f5ec>] (__warn+0xfc/0x114)
      [<8011f5ec>] (__warn) from [<8011f71c>] (warn_slowpath_null+0x40/0x48)
      [<8011f71c>] (warn_slowpath_null) from [<805a476c>] (brcmu_pkt_buf_free_skb+0x3c/0x40)
      [<805a476c>] (brcmu_pkt_buf_free_skb) from [<805bb6c4>] (brcmf_fws_cleanup+0x1e4/0x22c)
      [<805bb6c4>] (brcmf_fws_cleanup) from [<805bc854>] (brcmf_fws_del_interface+0x58/0x68)
      [<805bc854>] (brcmf_fws_del_interface) from [<805b66ac>] (brcmf_remove_interface+0x40/0x150)
      [<805b66ac>] (brcmf_remove_interface) from [<805b6870>] (brcmf_detach+0x6c/0xb0)
      [<805b6870>] (brcmf_detach) from [<805bdbb8>] (brcmf_usb_disconnect+0x30/0x4c)
      [<805bdbb8>] (brcmf_usb_disconnect) from [<805e5d64>] (usb_unbind_interface+0x5c/0x1e0)
      [<805e5d64>] (usb_unbind_interface) from [<804aab10>] (device_release_driver_internal+0x154/0x1ec)
      [<804aab10>] (device_release_driver_internal) from [<804a97f4>] (bus_remove_device+0xcc/0xf8)
      [<804a97f4>] (bus_remove_device) from [<804a6fc0>] (device_del+0x118/0x308)
      [<804a6fc0>] (device_del) from [<805e488c>] (usb_disable_device+0xa0/0x1c8)
      [<805e488c>] (usb_disable_device) from [<805dcf98>] (usb_disconnect+0x70/0x1d8)
      [<805dcf98>] (usb_disconnect) from [<805ddd84>] (hub_event+0x464/0xf50)
      [<805ddd84>] (hub_event) from [<80135a70>] (process_one_work+0x138/0x3f8)
      [<80135a70>] (process_one_work) from [<80135d5c>] (worker_thread+0x2c/0x554)
      [<80135d5c>] (worker_thread) from [<8013b1a0>] (kthread+0x124/0x154)
      [<8013b1a0>] (kthread) from [<801010e8>] (ret_from_fork+0x14/0x2c)
      Exception stack(0xecf8dfb0 to 0xecf8dff8)
      dfa0:                                     00000000 00000000 00000000 00000000
      dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      dfe0: 00000000 00000000 00000000 00000000 00000013 00000000
      ---[ end trace 38d234018e9e2a90 ]---
      ------------[ cut here ]------------
      Signed-off-by: NPiotr Figiel <p.figiel@camlintechnologies.com>
      Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      ce55a594