1. 27 Sep, 2022 5 commits
    • Paweł Lenkow's avatar
      wifi: mac80211: fix memory corruption in minstrel_ht_update_rates() · be92292b
      Paweł Lenkow authored
      During our testing of WFM200 module over SDIO on i.MX6Q-based platform,
      we discovered a memory corruption on the system, tracing back to the wfx
      driver. Using kfence, it was possible to trace it back to the root
      cause, which is hw->max_rates set to 8 in wfx_init_common,
      while the maximum defined by IEEE80211_TX_TABLE_SIZE is 4.
      
      This causes array out-of-bounds writes during updates of the rate table,
      as seen below:
      
      BUG: KFENCE: memory corruption in kfree_rcu_work+0x320/0x36c
      
      Corrupted memory at 0xe0a4ffe0 [ 0x03 0x03 0x03 0x03 0x01 0x00 0x00
      0x02 0x02 0x02 0x09 0x00 0x21 0xbb 0xbb 0xbb ] (in kfence-#81):
      kfree_rcu_work+0x320/0x36c
      process_one_work+0x3ec/0x920
      worker_thread+0x60/0x7a4
      kthread+0x174/0x1b4
      ret_from_fork+0x14/0x2c
      0x0
      
      kfence-#81: 0xe0a4ffc0-0xe0a4ffdf, size=32, cache=kmalloc-64
      
      allocated by task 297 on cpu 0 at 631.039555s:
      minstrel_ht_update_rates+0x38/0x2b0 [mac80211]
      rate_control_tx_status+0xb4/0x148 [mac80211]
      ieee80211_tx_status_ext+0x364/0x1030 [mac80211]
      ieee80211_tx_status+0xe0/0x118 [mac80211]
      ieee80211_tasklet_handler+0xb0/0xe0 [mac80211]
      tasklet_action_common.constprop.0+0x11c/0x148
      __do_softirq+0x1a4/0x61c
      irq_exit+0xcc/0x104
      call_with_stack+0x18/0x20
      __irq_svc+0x80/0xb0
      wq_worker_sleeping+0x10/0x100
      wq_worker_sleeping+0x10/0x100
      schedule+0x50/0xe0
      schedule_timeout+0x2e0/0x474
      wait_for_completion+0xdc/0x1ec
      mmc_wait_for_req_done+0xc4/0xf8
      mmc_io_rw_extended+0x3b4/0x4ec
      sdio_io_rw_ext_helper+0x290/0x384
      sdio_memcpy_toio+0x30/0x38
      wfx_sdio_copy_to_io+0x88/0x108 [wfx]
      wfx_data_write+0x88/0x1f0 [wfx]
      bh_work+0x1c8/0xcc0 [wfx]
      process_one_work+0x3ec/0x920
      worker_thread+0x60/0x7a4
      kthread+0x174/0x1b4
      ret_from_fork+0x14/0x2c 0x0
      
      After discussion on the wireless mailing list it was clarified
      that the issue has been introduced by:
      commit ee0e16ab ("mac80211: minstrel_ht: fill all requested rates")
      and fix shall be in minstrel_ht_update_rates in rc80211_minstrel_ht.c.
      
      Fixes: ee0e16ab ("mac80211: minstrel_ht: fill all requested rates")
      Link: https://lore.kernel.org/all/12e5adcd-8aed-f0f7-70cc-4fb7b656b829@camlingroup.com/
      Link: https://lore.kernel.org/linux-wireless/20220915131445.30600-1-lech.perczak@camlingroup.com/
      Cc: Jérôme Pouiller <jerome.pouiller@silabs.com>
      Cc: Johannes Berg <johannes@sipsolutions.net>
      Cc: Peter Seiderer <ps.report@gmx.net>
      Cc: Kalle Valo <kvalo@kernel.org>
      Cc: Krzysztof Drobiński <krzysztof.drobinski@camlingroup.com>,
      Signed-off-by: default avatarPaweł Lenkow <pawel.lenkow@camlingroup.com>
      Signed-off-by: default avatarLech Perczak <lech.perczak@camlingroup.com>
      Reviewed-by: default avatarPeter Seiderer <ps.report@gmx.net>
      Reviewed-by: default avatarJérôme Pouiller <jerome.pouiller@silabs.com>
      Acked-by: default avatarFelix Fietkau <nbd@nbd.name>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      be92292b
    • Hans de Goede's avatar
      wifi: mac80211: fix regression with non-QoS drivers · d873697e
      Hans de Goede authored
      Commit 10cb8e61 ("mac80211: enable QoS support for nl80211 ctrl port")
      changed ieee80211_tx_control_port() to aways call
      __ieee80211_select_queue() without checking local->hw.queues.
      
      __ieee80211_select_queue() returns a queue-id between 0 and 3, which means
      that now ieee80211_tx_control_port() may end up setting the queue-mapping
      for a skb to a value higher then local->hw.queues if local->hw.queues
      is less then 4.
      
      Specifically this is a problem for ralink rt2500-pci cards where
      local->hw.queues is 2. There this causes rt2x00queue_get_tx_queue() to
      return NULL and the following error to be logged: "ieee80211 phy0:
      rt2x00mac_tx: Error - Attempt to send packet over invalid queue 2",
      after which association with the AP fails.
      
      Other callers of __ieee80211_select_queue() skip calling it when
      local->hw.queues < IEEE80211_NUM_ACS, add the same check to
      ieee80211_tx_control_port(). This fixes ralink rt2500-pci and
      similar cards when less then 4 tx-queues no longer working.
      
      Fixes: 10cb8e61 ("mac80211: enable QoS support for nl80211 ctrl port")
      Cc: Markus Theil <markus.theil@tu-ilmenau.de>
      Suggested-by: default avatarStanislaw Gruszka <stf_xl@wp.pl>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Link: https://lore.kernel.org/r/20220918192052.443529-1-hdegoede@redhat.comSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      d873697e
    • Alexander Wetzel's avatar
      wifi: mac80211: ensure vif queues are operational after start · 527008e5
      Alexander Wetzel authored
      Make sure local->queue_stop_reasons and vif.txqs_stopped stay in sync.
      
      When a new vif is created the queues may end up in an inconsistent state
      and be inoperable:
      Communication not using iTXQ will work, allowing to e.g. complete the
      association. But the 4-way handshake will time out. The sta will not
      send out any skbs queued in iTXQs.
      
      All normal attempts to start the queues will fail when reaching this
      state.
      local->queue_stop_reasons will have marked all queues as operational but
      vif.txqs_stopped will still be set, creating an inconsistent internal
      state.
      
      In reality this seems to be race between the mac80211 function
      ieee80211_do_open() setting SDATA_STATE_RUNNING and the wake_txqs_tasklet:
      Depending on the driver and the timing the queues may end up to be
      operational or not.
      
      Cc: stable@vger.kernel.org
      Fixes: f856373e ("wifi: mac80211: do not wake queues on a vif that is being stopped")
      Signed-off-by: default avatarAlexander Wetzel <alexander@wetzel-home.de>
      Acked-by: default avatarFelix Fietkau <nbd@nbd.name>
      Link: https://lore.kernel.org/r/20220915130946.302803-1-alexander@wetzel-home.deSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      527008e5
    • Alexander Wetzel's avatar
      wifi: mac80211: don't start TX with fq->lock to fix deadlock · b7ce33df
      Alexander Wetzel authored
      ieee80211_txq_purge() calls fq_tin_reset() and
      ieee80211_purge_tx_queue(); Both are then calling
      ieee80211_free_txskb(). Which can decide to TX the skb again.
      
      There are at least two ways to get a deadlock:
      
      1) When we have a TDLS teardown packet queued in either tin or frags
         ieee80211_tdls_td_tx_handle() will call ieee80211_subif_start_xmit()
         while we still hold fq->lock. ieee80211_txq_enqueue() will thus
         deadlock.
      
      2) A variant of the above happens if aggregation is up and running:
         In that case ieee80211_iface_work() will deadlock with the original
         task: The original tasks already holds fq->lock and tries to get
         sta->lock after kicking off ieee80211_iface_work(). But the worker
         can get sta->lock prior to the original task and will then spin for
         fq->lock.
      
      Avoid these deadlocks by not sending out any skbs when called via
      ieee80211_free_txskb().
      Signed-off-by: default avatarAlexander Wetzel <alexander@wetzel-home.de>
      Link: https://lore.kernel.org/r/20220915124120.301918-1-alexander@wetzel-home.deSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      b7ce33df
    • Tamizh Chelvam Raja's avatar
      wifi: cfg80211: fix MCS divisor value · 64e966d1
      Tamizh Chelvam Raja authored
      The Bitrate for HE/EHT MCS6 is calculated wrongly due to the
      incorrect MCS divisor value for mcs6. Fix it with the proper
      value.
      
      previous mcs_divisor value = (11769/6144) = 1.915527
      
      fixed mcs_divisor value = (11377/6144) = 1.851725
      
      Fixes: 9c97c88d ("cfg80211: Add support to calculate and report 4096-QAM HE rates")
      Signed-off-by: default avatarTamizh Chelvam Raja <quic_tamizhr@quicinc.com>
      Link: https://lore.kernel.org/r/20220908181034.9936-1-quic_tamizhr@quicinc.comSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      64e966d1
  2. 12 Sep, 2022 3 commits
  3. 07 Sep, 2022 1 commit
  4. 03 Sep, 2022 5 commits
  5. 30 Aug, 2022 2 commits
  6. 26 Aug, 2022 2 commits
    • Deren Wu's avatar
      wifi: mt76: mt7921e: fix crash in chip reset fail · fa3fbe64
      Deren Wu authored
      In case of drv own fail in reset, we may need to run mac_reset several
      times. The sequence would trigger system crash as the log below.
      
      Because we do not re-enable/schedule "tx_napi" before disable it again,
      the process would keep waiting for state change in napi_diable(). To
      avoid the problem and keep status synchronize for each run, goto final
      resource handling if drv own failed.
      
      [ 5857.353423] mt7921e 0000:3b:00.0: driver own failed
      [ 5858.433427] mt7921e 0000:3b:00.0: Timeout for driver own
      [ 5859.633430] mt7921e 0000:3b:00.0: driver own failed
      [ 5859.633444] ------------[ cut here ]------------
      [ 5859.633446] WARNING: CPU: 6 at kernel/kthread.c:659 kthread_park+0x11d
      [ 5859.633717] Workqueue: mt76 mt7921_mac_reset_work [mt7921_common]
      [ 5859.633728] RIP: 0010:kthread_park+0x11d/0x150
      [ 5859.633736] RSP: 0018:ffff8881b676fc68 EFLAGS: 00010202
      ......
      [ 5859.633766] Call Trace:
      [ 5859.633768]  <TASK>
      [ 5859.633771]  mt7921e_mac_reset+0x176/0x6f0 [mt7921e]
      [ 5859.633778]  mt7921_mac_reset_work+0x184/0x3a0 [mt7921_common]
      [ 5859.633785]  ? mt7921_mac_set_timing+0x520/0x520 [mt7921_common]
      [ 5859.633794]  ? __kasan_check_read+0x11/0x20
      [ 5859.633802]  process_one_work+0x7ee/0x1320
      [ 5859.633810]  worker_thread+0x53c/0x1240
      [ 5859.633818]  kthread+0x2b8/0x370
      [ 5859.633824]  ? process_one_work+0x1320/0x1320
      [ 5859.633828]  ? kthread_complete_and_exit+0x30/0x30
      [ 5859.633834]  ret_from_fork+0x1f/0x30
      [ 5859.633842]  </TASK>
      
      Cc: stable@vger.kernel.org
      Fixes: 0efaf31d ("mt76: mt7921: fix MT7921E reset failure")
      Signed-off-by: default avatarDeren Wu <deren.wu@mediatek.com>
      Link: https://lore.kernel.org/r/727eb5ffd3c7c805245e512da150ecf0a7154020.1659452909.git.deren.wu@mediatek.comSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      fa3fbe64
    • David S. Miller's avatar
      Merge tag 'wireless-2022-08-26' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless · 4ba9d38b
      David S. Miller authored
      Johannes Berg says:
      
      ====================
      pull-request: wireless-2022-08-26
      
      Here are a couple of fixes for the current cycle,
      see the tag description below.
      
      Just a couple of fixes:
       * two potential leaks
       * use-after-free in certain scan races
       * warning in IBSS code
       * error return from a debugfs file was wrong
       * possible NULL-ptr-deref when station lookup fails
      
      Please pull and let me know if there's any problem.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4ba9d38b
  7. 25 Aug, 2022 22 commits