1. 21 Aug, 2023 1 commit
    • Ping-Ke Shih's avatar
      wifi: mac80211: limit reorder_buf_filtered to avoid UBSAN warning · b98c1610
      Ping-Ke Shih authored
      The commit 06470f74 ("mac80211: add API to allow filtering frames in BA sessions")
      added reorder_buf_filtered to mark frames filtered by firmware, and it
      can only work correctly if hw.max_rx_aggregation_subframes <= 64 since
      it stores the bitmap in a u64 variable.
      
      However, new HE or EHT devices can support BlockAck number up to 256 or
      1024, and then using a higher subframe index leads UBSAN warning:
      
       UBSAN: shift-out-of-bounds in net/mac80211/rx.c:1129:39
       shift exponent 215 is too large for 64-bit type 'long long unsigned int'
       Call Trace:
        <IRQ>
        dump_stack_lvl+0x48/0x70
        dump_stack+0x10/0x20
        __ubsan_handle_shift_out_of_bounds+0x1ac/0x360
        ieee80211_release_reorder_frame.constprop.0.cold+0x64/0x69 [mac80211]
        ieee80211_sta_reorder_release+0x9c/0x400 [mac80211]
        ieee80211_prepare_and_rx_handle+0x1234/0x1420 [mac80211]
        ieee80211_rx_list+0xaef/0xf60 [mac80211]
        ieee80211_rx_napi+0x53/0xd0 [mac80211]
      
      Since only old hardware that supports <=64 BlockAck uses
      ieee80211_mark_rx_ba_filtered_frames(), limit the use as it is, so add a
      WARN_ONCE() and comment to note to avoid using this function if hardware
      capability is not suitable.
      Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
      Link: https://lore.kernel.org/r/20230818014004.16177-1-pkshih@realtek.com
      [edit commit message]
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      b98c1610
  2. 15 Aug, 2023 1 commit
    • Randy Dunlap's avatar
      wifi: iwlwifi: mvm: add dependency for PTP clock · 609a1bcd
      Randy Dunlap authored
      When the code to use the PTP HW clock was added, it didn't update
      the Kconfig entry for the PTP dependency, leading to build errors,
      so update the Kconfig entry to depend on PTP_1588_CLOCK_OPTIONAL.
      
      aarch64-linux-ld: drivers/net/wireless/intel/iwlwifi/mvm/ptp.o: in function `iwl_mvm_ptp_init':
      drivers/net/wireless/intel/iwlwifi/mvm/ptp.c:294: undefined reference to `ptp_clock_register'
      drivers/net/wireless/intel/iwlwifi/mvm/ptp.c:294:(.text+0xce8): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `ptp_clock_register'
      aarch64-linux-ld: drivers/net/wireless/intel/iwlwifi/mvm/ptp.c:301: undefined reference to `ptp_clock_index'
      drivers/net/wireless/intel/iwlwifi/mvm/ptp.c:301:(.text+0xd18): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `ptp_clock_index'
      aarch64-linux-ld: drivers/net/wireless/intel/iwlwifi/mvm/ptp.o: in function `iwl_mvm_ptp_remove':
      drivers/net/wireless/intel/iwlwifi/mvm/ptp.c:315: undefined reference to `ptp_clock_index'
      drivers/net/wireless/intel/iwlwifi/mvm/ptp.c:315:(.text+0xe80): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `ptp_clock_index'
      aarch64-linux-ld: drivers/net/wireless/intel/iwlwifi/mvm/ptp.c:319: undefined reference to `ptp_clock_unregister'
      drivers/net/wireless/intel/iwlwifi/mvm/ptp.c:319:(.text+0xeac): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `ptp_clock_unregister'
      
      Fixes: 1595ecce ("wifi: iwlwifi: mvm: add support for PTP HW clock (PHC)")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Link: https://lore.kernel.org/all/202308110447.4QSJHmFH-lkp@intel.com/
      Cc: Krishnanand Prabhu <krishnanand.prabhu@intel.com>
      Cc: Luca Coelho <luciano.coelho@intel.com>
      Cc: Gregory Greenman <gregory.greenman@intel.com>
      Cc: Johannes Berg <johannes.berg@intel.com>
      Cc: Kalle Valo <kvalo@kernel.org>
      Cc: linux-wireless@vger.kernel.org
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Paolo Abeni <pabeni@redhat.com>
      Cc: netdev@vger.kernel.org
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Tested-by: Simon Horman <horms@kernel.org> # build-tested
      Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
      Acked-by: default avatarGregory Greenman <gregory.greenman@intel.com>
      Link: https://lore.kernel.org/r/20230812052947.22913-1-rdunlap@infradead.orgSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      609a1bcd
  3. 09 Aug, 2023 2 commits
    • Wen Gong's avatar
      wifi: ath12k: Fix buffer overflow when scanning with extraie · 06f2ab86
      Wen Gong authored
      If cfg80211 is providing extraie's for a scanning process then ath12k will
      copy that over to the firmware. The extraie.len is a 32 bit value in struct
      element_info and describes the amount of bytes for the vendor information
      elements.
      
      The problem is the allocation of the buffer. It has to align the TLV
      sections by 4 bytes. But the code was using an u8 to store the newly
      calculated length of this section (with alignment). And the new
      calculated length was then used to allocate the skbuff. But the actual
      code to copy in the data is using the extraie.len and not the calculated
      "aligned" length.
      
      The length of extraie with IEEE80211_HW_SINGLE_SCAN_ON_ALL_BANDS enabled
      was 264 bytes during tests with a wifi card. But it only allocated 8
      bytes (264 bytes % 256) for it. As consequence, the code to memcpy the
      extraie into the skb was then just overwriting data after skb->end. Things
      like shinfo were therefore corrupted. This could usually be seen by a crash
      in skb_zcopy_clear which tried to call a ubuf_info callback (using a bogus
      address).
      
      Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.0-03427-QCAHMTSWPL_V1.0_V2.0_SILICONZ-1.15378.4
      Signed-off-by: default avatarWen Gong <quic_wgong@quicinc.com>
      Link: https://lore.kernel.org/r/20230809081241.32765-1-quic_wgong@quicinc.comSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      06f2ab86
    • Keith Yeo's avatar
      wifi: nl80211: fix integer overflow in nl80211_parse_mbssid_elems() · 6311071a
      Keith Yeo authored
      nl80211_parse_mbssid_elems() uses a u8 variable num_elems to count the
      number of MBSSID elements in the nested netlink attribute attrs, which can
      lead to an integer overflow if a user of the nl80211 interface specifies
      256 or more elements in the corresponding attribute in userspace. The
      integer overflow can lead to a heap buffer overflow as num_elems determines
      the size of the trailing array in elems, and this array is thereafter
      written to for each element in attrs.
      
      Note that this vulnerability only affects devices with the
      wiphy->mbssid_max_interfaces member set for the wireless physical device
      struct in the device driver, and can only be triggered by a process with
      CAP_NET_ADMIN capabilities.
      
      Fix this by checking for a maximum of 255 elements in attrs.
      
      Cc: stable@vger.kernel.org
      Fixes: dc1e3cb8 ("nl80211: MBSSID and EMA support in AP mode")
      Signed-off-by: default avatarKeith Yeo <keithyjy@gmail.com>
      Link: https://lore.kernel.org/r/20230731034719.77206-1-keithyjy@gmail.comSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      6311071a
  4. 08 Aug, 2023 5 commits
  5. 02 Aug, 2023 1 commit
    • Hans de Goede's avatar
      wifi: brcmfmac: Fix field-spanning write in brcmf_scan_params_v2_to_v1() · 16e455a4
      Hans de Goede authored
      Using brcmfmac with 6.5-rc3 on a brcmfmac43241b4-sdio triggers
      a backtrace caused by the following field-spanning warning:
      
      memcpy: detected field-spanning write (size 120) of single field
        "&params_le->channel_list[0]" at
        drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:1072 (size 2)
      
      The driver still works after this warning. The warning was introduced by the
      new field-spanning write checks which were enabled recently.
      
      Fix this by replacing the channel_list[1] declaration at the end of
      the struct with a flexible array declaration.
      
      Most users of struct brcmf_scan_params_le calculate the size to alloc
      using the size of the non flex-array part of the struct + needed extra
      space, so they do not care about sizeof(struct brcmf_scan_params_le).
      
      brcmf_notify_escan_complete() however uses the struct on the stack,
      expecting there to be room for at least 1 entry in the channel-list
      to store the special -1 abort channel-id.
      
      To make this work use an anonymous union with a padding member
      added + the actual channel_list flexible array.
      
      Cc: Kees Cook <keescook@chromium.org>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarFranky Lin <franky.lin@broadcom.com>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20230729140500.27892-1-hdegoede@redhat.com
      16e455a4
  6. 01 Aug, 2023 1 commit
    • Kees Cook's avatar
      wifi: ray_cs: Replace 1-element array with flexible array · 1d7dd5aa
      Kees Cook authored
      The trailing array member of struct tx_buf was defined as a 1-element
      array, but used as a flexible array. This was resulting in build warnings:
      
          In function 'fortify_memset_chk',
              inlined from 'memset_io' at /kisskb/src/arch/mips/include/asm/io.h:486:2,
              inlined from 'build_auth_frame' at /kisskb/src/drivers/net/wireless/legacy/ray_cs.c:2697:2:
          /kisskb/src/include/linux/fortify-string.h:493:25: error: call to '__write_overflow_field' declared with attribute warning:
      detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
            493 |                         __write_overflow_field(p_size_field, size);
                |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Replace it with an actual flexible array. Binary difference comparison
      shows a single change in output:
      
      │  drivers/net/wireless/legacy/ray_cs.c:883
      │       lea    0x1c(%rbp),%r13d
      │ -     cmp    $0x7c3,%r13d
      │ +     cmp    $0x7c4,%r13d
      
      This is from:
      
              if (len + TX_HEADER_LENGTH > TX_BUF_SIZE) {
      
      specifically:
      
       #define TX_BUF_SIZE (2048 - sizeof(struct tx_msg))
      
      This appears to have been originally buggy, so the change is correct.
      Reported-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Closes: https://lore.kernel.org/all/88f83d73-781d-bdc-126-aa629cb368c@linux-m68k.org
      Cc: Kalle Valo <kvalo@kernel.org>
      Cc: linux-wireless@vger.kernel.org
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20230728231245.never.309-kees@kernel.org
      1d7dd5aa
  7. 26 Jul, 2023 13 commits
  8. 24 Jul, 2023 2 commits
  9. 20 Jul, 2023 10 commits
  10. 19 Jul, 2023 4 commits