Commit Graph

292 Commits

Author SHA1 Message Date
Jose Ignacio Tornos Martinez 52137e5b63 wifi: cfg80211: clear link ID from bitmap during link delete after clean up
JIRA: https://issues.redhat.com/browse/RHEL-73817
JIRA: https://issues.redhat.com/browse/RHEL-74089
CVE: CVE-2024-57898

commit b5c32ff6a3a38c74facdd1fe34c0d709a55527fd
Author: Aditya Kumar Singh <quic_adisi@quicinc.com>
Date:   Thu Nov 21 09:45:30 2024 +0530

    wifi: cfg80211: clear link ID from bitmap during link delete after clean up
    
    Currently, during link deletion, the link ID is first removed from the
    valid_links bitmap before performing any clean-up operations. However, some
    functions require the link ID to remain in the valid_links bitmap. One
    such example is cfg80211_cac_event(). The flow is -
    
    nl80211_remove_link()
        cfg80211_remove_link()
            ieee80211_del_intf_link()
                ieee80211_vif_set_links()
                    ieee80211_vif_update_links()
                        ieee80211_link_stop()
                            cfg80211_cac_event()
    
    cfg80211_cac_event() requires link ID to be present but it is cleared
    already in cfg80211_remove_link(). Ultimately, WARN_ON() is hit.
    
    Therefore, clear the link ID from the bitmap only after completing the link
    clean-up.
    
    Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
    Link: https://patch.msgid.link/20241121-mlo_dfs_fix-v2-1-92c3bf7ab551@quicinc.com
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2025-01-15 17:26:26 +01:00
Jose Ignacio Tornos Martinez ca651d9c82 wifi: cfg80211: fix bug of mapping AF3x to incorrect User Priority
JIRA: https://issues.redhat.com/browse/RHEL-67113

commit a68b22e2905b04f376e2fa116be5e48b948f81c8
Author: hhorace <hhoracehsu@gmail.com>
Date:   Wed Aug 7 16:22:05 2024 +0800

    wifi: cfg80211: fix bug of mapping AF3x to incorrect User Priority
    
    According to RFC8325 4.3, Multimedia Streaming: AF31(011010, 26),
    AF32(011100, 28), AF33(011110, 30) maps to User Priority = 4
    and AC_VI (Video).
    
    However, the original code remain the default three Most Significant
    Bits (MSBs) of the DSCP, which makes AF3x map to User Priority = 3
    and AC_BE (Best Effort).
    
    Fixes: 6fdb8b8781d5 ("wifi: cfg80211: Update the default DSCP-to-UP mapping")
    Signed-off-by: hhorace <hhoracehsu@gmail.com>
    Reviewed-by: Guillaume Nault <gnault@redhat.com>
    Reviewed-by: Ido Schimmel <idosch@nvidia.com>
    Link: https://patch.msgid.link/20240807082205.1369-1-hhoracehsu@gmail.com
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-11-22 10:57:58 +01:00
Jose Ignacio Tornos Martinez bcce9a074a wifi: cfg80211: add helper for checking if a chandef is valid on a radio
JIRA: https://issues.redhat.com/browse/RHEL-50013

commit 510dba80ed669d6123901ccf0476706122b008b1
Author: Felix Fietkau <nbd@nbd.name>
Date:   Tue Jul 9 10:38:32 2024 +0200

    wifi: cfg80211: add helper for checking if a chandef is valid on a radio
    
    Check if the full channel width is in the radio's frequency range.
    
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Link: https://patch.msgid.link/7c8ea146feb6f37cee62e5ba6be5370403695797.1720514221.git-series.nbd@nbd.name
    [add missing Return: documentation]
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-10-29 08:18:27 +01:00
Jose Ignacio Tornos Martinez d8cfd0ab06 wifi: cfg80211: extend interface combination check for multi-radio
JIRA: https://issues.redhat.com/browse/RHEL-50013

commit abb4cfe3661aa05426916b21164f88ca5a405a3a
Author: Felix Fietkau <nbd@nbd.name>
Date:   Tue Jul 9 10:38:31 2024 +0200

    wifi: cfg80211: extend interface combination check for multi-radio
    
    Add a field in struct iface_combination_params to check per-radio
    interface combinations instead of per-wiphy ones.
    
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Link: https://patch.msgid.link/32b28da89c2d759b0324deeefe2be4cee91de18e.1720514221.git-series.nbd@nbd.name
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-10-29 08:18:27 +01:00
Jose Ignacio Tornos Martinez b7fe5280a8 wifi: cfg80211: fix typo in cfg80211_calculate_bitrate_he()
JIRA: https://issues.redhat.com/browse/RHEL-50013

commit 9ee0d44f055276fe2802b2f65058e920853f4f99
Author: Baochen Qiang <quic_bqiang@quicinc.com>
Date:   Thu Jun 6 10:06:52 2024 +0800

    wifi: cfg80211: fix typo in cfg80211_calculate_bitrate_he()
    
    rates_996 is mistakenly written as rates_969, fix it.
    
    Fixes: c4cbaf7973 ("cfg80211: Add support for HE")
    Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com>
    Link: https://msgid.link/20240606020653.33205-2-quic_bqiang@quicinc.com
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-10-29 08:18:00 +01:00
Jose Ignacio Tornos Martinez c35366d049 wifi: cfg80211: handle 2x996 RU allocation in cfg80211_calculate_bitrate_he()
JIRA: https://issues.redhat.com/browse/RHEL-55579
CVE: CVE-2024-43879

commit bcbd771cd5d68c0c52567556097d75f9fc4e7cd6
Author: Baochen Qiang <quic_bqiang@quicinc.com>
Date:   Thu Jun 6 10:06:53 2024 +0800

    wifi: cfg80211: handle 2x996 RU allocation in cfg80211_calculate_bitrate_he()
    
    Currently NL80211_RATE_INFO_HE_RU_ALLOC_2x996 is not handled in
    cfg80211_calculate_bitrate_he(), leading to below warning:
    
    kernel: invalid HE MCS: bw:6, ru:6
    kernel: WARNING: CPU: 0 PID: 2312 at net/wireless/util.c:1501 cfg80211_calculate_bitrate_he+0x22b/0x270 [cfg80211]
    
    Fix it by handling 2x996 RU allocation in the same way as 160 MHz bandwidth.
    
    Fixes: c4cbaf7973 ("cfg80211: Add support for HE")
    Signed-off-by: Baochen Qiang <quic_bqiang@quicinc.com>
    Link: https://msgid.link/20240606020653.33205-3-quic_bqiang@quicinc.com
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-09-17 13:25:14 +02:00
CKI Backport Bot 6b4fa0120d wifi: cfg80211: Lock wiphy in cfg80211_get_station
JIRA: https://issues.redhat.com/browse/RHEL-47768
CVE: CVE-2024-40911

commit 642f89daa34567d02f312d03e41523a894906dae
Author: Remi Pommarel <repk@triplefau.lt>
Date:   Tue May 21 21:47:26 2024 +0200

    wifi: cfg80211: Lock wiphy in cfg80211_get_station

    Wiphy should be locked before calling rdev_get_station() (see lockdep
    assert in ieee80211_get_station()).

    This fixes the following kernel NULL dereference:

     Unable to handle kernel NULL pointer dereference at virtual address 0000000000000050
     Mem abort info:
       ESR = 0x0000000096000006
       EC = 0x25: DABT (current EL), IL = 32 bits
       SET = 0, FnV = 0
       EA = 0, S1PTW = 0
       FSC = 0x06: level 2 translation fault
     Data abort info:
       ISV = 0, ISS = 0x00000006
       CM = 0, WnR = 0
     user pgtable: 4k pages, 48-bit VAs, pgdp=0000000003001000
     [0000000000000050] pgd=0800000002dca003, p4d=0800000002dca003, pud=08000000028e9003, pmd=0000000000000000
     Internal error: Oops: 0000000096000006 [#1] SMP
     Modules linked in: netconsole dwc3_meson_g12a dwc3_of_simple dwc3 ip_gre gre ath10k_pci ath10k_core ath9k ath9k_common ath9k_hw ath
     CPU: 0 PID: 1091 Comm: kworker/u8:0 Not tainted 6.4.0-02144-g565f9a3a7911-dirty #705
     Hardware name: RPT (r1) (DT)
     Workqueue: bat_events batadv_v_elp_throughput_metric_update
     pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
     pc : ath10k_sta_statistics+0x10/0x2dc [ath10k_core]
     lr : sta_set_sinfo+0xcc/0xbd4
     sp : ffff000007b43ad0
     x29: ffff000007b43ad0 x28: ffff0000071fa900 x27: ffff00000294ca98
     x26: ffff000006830880 x25: ffff000006830880 x24: ffff00000294c000
     x23: 0000000000000001 x22: ffff000007b43c90 x21: ffff800008898acc
     x20: ffff00000294c6e8 x19: ffff000007b43c90 x18: 0000000000000000
     x17: 445946354d552d78 x16: 62661f7200000000 x15: 57464f445946354d
     x14: 0000000000000000 x13: 00000000000000e3 x12: d5f0acbcebea978e
     x11: 00000000000000e3 x10: 000000010048fe41 x9 : 0000000000000000
     x8 : ffff000007b43d90 x7 : 000000007a1e2125 x6 : 0000000000000000
     x5 : ffff0000024e0900 x4 : ffff800000a0250c x3 : ffff000007b43c90
     x2 : ffff00000294ca98 x1 : ffff000006831920 x0 : 0000000000000000
     Call trace:
      ath10k_sta_statistics+0x10/0x2dc [ath10k_core]
      sta_set_sinfo+0xcc/0xbd4
      ieee80211_get_station+0x2c/0x44
      cfg80211_get_station+0x80/0x154
      batadv_v_elp_get_throughput+0x138/0x1fc
      batadv_v_elp_throughput_metric_update+0x1c/0xa4
      process_one_work+0x1ec/0x414
      worker_thread+0x70/0x46c
      kthread+0xdc/0xe0
      ret_from_fork+0x10/0x20
     Code: a9bb7bfd 910003fd a90153f3 f9411c40 (f9402814)

    This happens because STA has time to disconnect and reconnect before
    batadv_v_elp_throughput_metric_update() delayed work gets scheduled. In
    this situation, ath10k_sta_state() can be in the middle of resetting
    arsta data when the work queue get chance to be scheduled and ends up
    accessing it. Locking wiphy prevents that.

    Fixes: 7406353d43 ("cfg80211: implement cfg80211_get_station cfg80211 API")
    Signed-off-by: Remi Pommarel <repk@triplefau.lt>
    Reviewed-by: Nicolas Escande <nico.escande@gmail.com>
    Acked-by: Antonio Quartulli <a@unstable.cc>
    Link: https://msgid.link/983b24a6a176e0800c01aedcd74480d9b551cb13.1716046653.git.repk@triplefau.lt
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>
2024-07-15 10:37:12 +00:00
Jose Ignacio Tornos Martinez 15f6a05405 wifi: cfg80211: check A-MSDU format more carefully
JIRA: https://issues.redhat.com/browse/RHEL-34696
JIRA: https://issues.redhat.com/browse/RHEL-37345
CVE: CVE-2024-35937

commit 9ad7974856926129f190ffbe3beea78460b3b7cc
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Mon Feb 26 20:34:06 2024 +0100

    wifi: cfg80211: check A-MSDU format more carefully
    
    If it looks like there's another subframe in the A-MSDU
    but the header isn't fully there, we can end up reading
    data out of bounds, only to discard later. Make this a
    bit more careful and check if the subframe header can
    even be present.
    
    Reported-by: syzbot+d050d437fe47d479d210@syzkaller.appspotmail.com
    Link: https://msgid.link/20240226203405.a731e2c95e38.I82ce7d8c0cc8970ce29d0a39fdc07f1ffc425be4@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-06-17 09:19:53 +02:00
Jose Ignacio Tornos Martinez eaf57d3acf wifi: cfg80211: Add utility for converting op_class into chandef
JIRA: https://issues.redhat.com/browse/RHEL-34696

commit 68de13028b94572fc570b7eb1e0e2de1d751fe7e
Author: Michael-CY Lee <michael-cy.lee@mediatek.com>
Date:   Fri Dec 22 09:09:13 2023 +0800

    wifi: cfg80211: Add utility for converting op_class into chandef
    
    This utility is used in STA CSA handling. The op_class in the ECSA
    Element can be converted into chandef.
    
    Co-developed-by: Money Wang <money.wang@mediatek.com>
    Signed-off-by: Michael-CY Lee <michael-cy.lee@mediatek.com>
    Link: https://msgid.link/20231222010914.6521-2-michael-cy.lee@mediatek.com
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-06-17 09:19:20 +02:00
Jose Ignacio Tornos Martinez d0a8f506eb wifi: cfg80211: Update the default DSCP-to-UP mapping
JIRA: https://issues.redhat.com/browse/RHEL-28754

commit 6fdb8b8781d59796324efa25909f3e2112833f01
Author: Ilan Peer <ilan.peer@intel.com>
Date:   Mon Dec 18 11:30:05 2023 +0200

    wifi: cfg80211: Update the default DSCP-to-UP mapping
    
    The default DSCP-to-UP mapping method defined in RFC8325
    applied to packets marked per recommendations in RFC4594 and
    destined to 802.11 WLAN clients will yield a number of inconsistent
    QoS mappings.
    
    To handle this, modify the mapping of specific DSCP values for
    which the default mapping will create inconsistencies, based on
    the recommendations in section 4 in RFC8325.
    
    Note: RFC8235 is used as it referenced by both IEEE802.11Revme_D4.0
    and WFA QoS Management Specification.
    
    Signed-off-by: Ilan Peer <ilan.peer@intel.com>
    Reviewed-by: Gregory Greenman <gregory.greenman@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://msgid.link/20231218093005.3064013-1-ilan.peer@intel.com
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-03-18 17:58:14 +01:00
Jose Ignacio Tornos Martinez c70a5e74e9 wifi: cfg80211: Allow AP/P2PGO to indicate port authorization to peer STA/P2PClient
JIRA: https://issues.redhat.com/browse/RHEL-19746

commit e4e7e3af73694380f0d9a742d13b80598a3393e9
Author: Vinayak Yadawad <vinayak.yadawad@broadcom.com>
Date:   Tue Sep 26 16:02:22 2023 +0530

    wifi: cfg80211: Allow AP/P2PGO to indicate port authorization to peer STA/P2PClient
    
    In 4way handshake offload, cfg80211_port_authorized enables driver
    to indicate successful 4way handshake to cfg80211 layer. Currently
    this path of port authorization is restricted to interface type
    NL80211_IFTYPE_STATION and NL80211_IFTYPE_P2P_CLIENT. This patch
    extends the support for NL80211_IFTYPE_AP and NL80211_IFTYPE_P2P_GO
    interfaces to authorize peer STA/P2P_CLIENT, whenever authentication
    is offloaded on the AP/P2P_GO interface.
    
    Signed-off-by: Vinayak Yadawad <vinayak.yadawad@broadcom.com>
    Link: https://lore.kernel.org/r/dee3b0a2b4f617e932c90bff4504a89389273632.1695721435.git.vinayak.yadawad@broadcom.com
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-02-01 15:29:54 +01:00
Jose Ignacio Tornos Martinez da52c837db wifi: cfg80211: Include operating class 137 in 6GHz band
JIRA: https://issues.redhat.com/browse/RHEL-19746

commit 256caff27874c40c6f02f3e047e47bf4ae7702bc
Author: Ilan Peer <ilan.peer@intel.com>
Date:   Thu Sep 28 17:35:28 2023 +0300

    wifi: cfg80211: Include operating class 137 in 6GHz band
    
    Draft P802.11be_D3.1 added operating class to describe 320 MHz
    operation in the 6GHz band. Include this new operating class in
    ieee80211_operating_class_to_band().
    
    Signed-off-by: Ilan Peer <ilan.peer@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230928172905.bed4a007d81b.I3eb4b8fe39c0c1a988c98a103b11a9f45a92b038@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-02-01 15:29:43 +01:00
Jose Ignacio Tornos Martinez a99e34857e wifi: cfg80211: remove scan_width support
JIRA: https://issues.redhat.com/browse/RHEL-19746

commit 5add321c329b1746589b51359259666ca3dbe219
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Tue Aug 29 12:17:43 2023 +0200

    wifi: cfg80211: remove scan_width support
    
    There really isn't any support for scanning at different
    channel widths than 20 MHz since there's no way to set it.
    Remove this support for now, if somebody wants to maintain
    this whole thing later we can revisit how it should work.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-02-01 15:28:59 +01:00
Jose Ignacio Tornos Martinez db53de8ec9 wifi: cfg80211: add ieee80211_fragment_element to public API
JIRA: https://issues.redhat.com/browse/RHEL-19746

commit 5806ef25bc6e6cf0c04005ff25a4585437d567de
Author: Benjamin Berg <benjamin.berg@intel.com>
Date:   Sun Aug 27 14:05:22 2023 +0300

    wifi: cfg80211: add ieee80211_fragment_element to public API
    
    This function will be used by the kunit tests within cfg80211. As it
    is generally useful, move it from mac80211 to cfg80211.
    
    Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230827135854.5af9391659f5.Ie534ed6591ba02be8572d4d7242394f29e3af04b@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-02-01 15:28:55 +01:00
Jose Ignacio Tornos Martinez 9735b89fb4 wifi: cfg80211: remove wdev mutex
JIRA: https://issues.redhat.com/browse/RHEL-19746

Conflicts:
  - net/wireless/nl80211.c
    this commit was developed in a parallel branch and there were conflicts
    that were resolved when it merged (merge commit 7d6904bf26b96).

commit 076fc8775dafe995e94c106bb732bf2d42dedcea
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Tue Aug 29 12:18:56 2023 +0200

    wifi: cfg80211: remove wdev mutex
    
    Since we're now protecting everything with the wiphy mutex
    (and were really using it for almost everything before),
    there's no longer any real reason to have a separate wdev
    mutex. It may feel better, but really has no value.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-02-01 15:28:54 +01:00
Jose Ignacio Tornos Martinez aa4a28330d wifi: cfg80211: S1G rate information and calculations
JIRA: https://issues.redhat.com/browse/RHEL-2907

commit 2ad66fcb2fded5359a676f7146cf442641d28307
Author: Gilad Itzkovitch <gilad.itzkovitch@morsemicro.com>
Date:   Thu May 18 12:07:23 2023 +1200

    wifi: cfg80211: S1G rate information and calculations
    
    Increase the size of S1G rate_info flags to support S1G and add
    flags for new S1G MCS and the supported bandwidths. Also, include
    S1G rate information to netlink STA rate message. Lastly, add
    rate calculation function for S1G MCS.
    
    Signed-off-by: Gilad Itzkovitch <gilad.itzkovitch@morsemicro.com>
    Link: https://lore.kernel.org/r/20230518000723.991912-1-gilad.itzkovitch@morsemicro.com
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2023-11-27 15:01:26 +01:00
Íñigo Huguet 7d09173284 wifi: cfg80211: fix receiving mesh packets without RFC1042 header
Bugzilla: https://bugzilla.redhat.com/2196821

commit fec3ebb5ed299ac3a998f011c380f2ded47f4866
Author: Felix Fietkau <nbd@nbd.name>
Date:   Tue Jul 11 13:50:52 2023 +0200

    wifi: cfg80211: fix receiving mesh packets without RFC1042 header
    
    Fix ethernet header length field after stripping the mesh header
    
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/all/CT5GNZSK28AI.2K6M69OXM9RW5@syracuse/
    Fixes: 986e43b19ae9 ("wifi: mac80211: fix receiving A-MSDU frames on mesh interfaces")
    Reported-and-tested-by: Nicolas Escande <nico.escande@gmail.com>
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Link: https://lore.kernel.org/r/20230711115052.68430-1-nbd@nbd.name
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2023-07-26 13:16:42 +02:00
Íñigo Huguet c9cf4c2270 wifi: cfg80211: remove links only on AP
Bugzilla: https://bugzilla.redhat.com/2196821

commit 34d4e3eb67fed9c19719bedb748e5a8b6ccc97a5
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Thu Jun 8 16:36:04 2023 +0300

    wifi: cfg80211: remove links only on AP
    
    Since links are only controlled by userspace via cfg80211
    in AP mode, also only remove them from the driver in that
    case.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230608163202.ed65b94916fa.I2458c46888284cc5ce30715fe642bc5fc4340c8f@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2023-07-26 13:16:36 +02:00
Íñigo Huguet 8cddbd8345 wifi: mac80211: implement support for yet another mesh A-MSDU format
Bugzilla: https://bugzilla.redhat.com/2196821

Conflicts: commit from different branch already applied:
a16fc38315f2 ("wifi: mac80211: fix potential null pointer dereference")

commit fe4a6d2db3bad41e9f22c860596f355af8493ebb
Author: Felix Fietkau <nbd@nbd.name>
Date:   Tue Mar 14 10:59:56 2023 +0100

    wifi: mac80211: implement support for yet another mesh A-MSDU format
    
    MT7996 hardware supports mesh A-MSDU subframes in hardware, but uses a
    big-endian length field
    
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
    Link: https://lore.kernel.org/r/20230314095956.62085-7-nbd@nbd.name
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2023-07-26 13:15:00 +02:00
Jose Ignacio Tornos Martinez e79a9c9932 wifi: mac80211: add a workaround for receiving non-standard mesh A-MSDU
Bugzilla: https://bugzilla.redhat.com/2178526

commit 6e4c0d0460bd32ca9244dff3ba2d2da27235de11
Author: Felix Fietkau <nbd@nbd.name>
Date:   Mon Feb 13 11:08:55 2023 +0100

    wifi: mac80211: add a workaround for receiving non-standard mesh A-MSDU
    
    At least ath10k and ath11k supported hardware (maybe more) does not implement
    mesh A-MSDU aggregation in a standard compliant way.
    802.11-2020 9.3.2.2.2 declares that the Mesh Control field is part of the
    A-MSDU header (and little-endian).
    As such, its length must not be included in the subframe length field.
    Hardware affected by this bug treats the mesh control field as part of the
    MSDU data and sets the length accordingly.
    In order to avoid packet loss, keep track of which stations are affected
    by this and take it into account when converting A-MSDU to 802.3 + mesh control
    packets.
    
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Link: https://lore.kernel.org/r/20230213100855.34315-5-nbd@nbd.name
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2023-05-09 08:18:27 +02:00
Jose Ignacio Tornos Martinez 3a02e93a55 wifi: mac80211: fix receiving A-MSDU frames on mesh interfaces
Bugzilla: https://bugzilla.redhat.com/2178526

commit 986e43b19ae9176093da35e0a844e65c8bf9ede7
Author: Felix Fietkau <nbd@nbd.name>
Date:   Mon Feb 13 11:08:54 2023 +0100

    wifi: mac80211: fix receiving A-MSDU frames on mesh interfaces
    
    The current mac80211 mesh A-MSDU receive path fails to parse A-MSDU packets
    on mesh interfaces, because it assumes that the Mesh Control field is always
    directly after the 802.11 header.
    802.11-2020 9.3.2.2.2 Figure 9-70 shows that the Mesh Control field is
    actually part of the A-MSDU subframe header.
    This makes more sense, since it allows packets for multiple different
    destinations to be included in the same A-MSDU, as long as RA and TID are
    still the same.
    Another issue is the fact that the A-MSDU subframe length field was apparently
    accidentally defined as little-endian in the standard.
    
    In order to fix this, the mesh forwarding path needs happen at a different
    point in the receive path.
    
    ieee80211_data_to_8023_exthdr is changed to ignore the mesh control field
    and leave it in after the ethernet header. This also affects the source/dest
    MAC address fields, which now in the case of mesh point to the mesh SA/DA.
    
    ieee80211_amsdu_to_8023s is changed to deal with the endian difference and
    to add the Mesh Control length to the subframe length, since it's not covered
    by the MSDU length field.
    
    With these changes, the mac80211 will get the same packet structure for
    converted regular data packets and unpacked A-MSDU subframes.
    
    The mesh forwarding checks are now only performed after the A-MSDU decap.
    For locally received packets, the Mesh Control header is stripped away.
    For forwarded packets, a new 802.11 header gets added.
    
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Link: https://lore.kernel.org/r/20230213100855.34315-4-nbd@nbd.name
    [fix fortify build error]
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2023-05-09 08:18:27 +02:00
Jose Ignacio Tornos Martinez fda1bf051c wifi: cfg80211: factor out bridge tunnel / RFC1042 header check
Bugzilla: https://bugzilla.redhat.com/2178526

commit 9f718554e7eacea62d3f972cae24d969755bf3b6
Author: Felix Fietkau <nbd@nbd.name>
Date:   Mon Feb 13 11:08:52 2023 +0100

    wifi: cfg80211: factor out bridge tunnel / RFC1042 header check
    
    The same check is done in multiple places, unify it.
    
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Link: https://lore.kernel.org/r/20230213100855.34315-2-nbd@nbd.name
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2023-05-09 08:18:27 +02:00
Jose Ignacio Tornos Martinez bc98da865d wifi: cfg80211: move A-MSDU check in ieee80211_data_to_8023_exthdr
Bugzilla: https://bugzilla.redhat.com/2178526

commit 0f690e6b4dcd7243e2805a76981b252c2d4bdce6
Author: Felix Fietkau <nbd@nbd.name>
Date:   Mon Feb 13 11:08:51 2023 +0100

    wifi: cfg80211: move A-MSDU check in ieee80211_data_to_8023_exthdr
    
    When parsing the outer A-MSDU header, don't check for inner bridge tunnel
    or RFC1042 headers. This is handled by ieee80211_amsdu_to_8023s already.
    
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Link: https://lore.kernel.org/r/20230213100855.34315-1-nbd@nbd.name
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2023-05-09 08:18:27 +02:00
Jose Ignacio Tornos Martinez a59e47e071 wifi: cfg80211: remove support for static WEP
Bugzilla: https://bugzilla.redhat.com/2178526

commit 585b6e1304dcc46e65dc1aaca5973b33abd0c48d
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Mon Jan 16 15:24:11 2023 +0100

    wifi: cfg80211: remove support for static WEP
    
    This reverts commit b8676221f0 ("cfg80211: Add support for
    static WEP in the driver") since no driver ever ended up using
    it.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2023-05-09 08:17:50 +02:00
Jose Ignacio Tornos Martinez 4ff3e117fe cfg80211: Update Transition Disable policy during port authorization
Bugzilla: https://bugzilla.redhat.com/2178526

commit 0ff57171d6d225558c81a69439d5323e35b40549
Author: Vinayak Yadawad <vinayak.yadawad@broadcom.com>
Date:   Wed Sep 7 18:14:48 2022 +0530

    cfg80211: Update Transition Disable policy during port authorization
    
    In case of 4way handshake offload, transition disable policy
    updated by the AP during EAPOL 3/4 is not updated to the upper layer.
    This results in mismatch between transition disable policy
    between the upper layer and the driver. This patch addresses this
    issue by updating transition disable policy as part of port
    authorization indication.
    
    Signed-off-by: Vinayak Yadawad <vinayak.yadawad@broadcom.com>
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2023-05-09 08:15:18 +02:00
Jose Ignacio Tornos Martinez a0762505ab wifi: cfg80211: Fix bitrates overflow issue
Bugzilla: https://bugzilla.redhat.com/2136124

commit 18429c51c7ff6e6bfd627316c54670230967a7e5
Author: Paul Zhang <quic_paulz@quicinc.com>
Date:   Tue Oct 11 21:04:28 2022 +0800

    wifi: cfg80211: Fix bitrates overflow issue
    
    When invoking function cfg80211_calculate_bitrate_eht about
    (320 MHz, EHT-MCS 13, EHT-NSS 2, EHT-GI 0), which means the
    parameters as flags: 0x80, bw: 7, mcs: 13, eht_gi: 0, nss: 2,
    this formula (result * rate->nss) will overflow and causes
    the returned bitrate to be 3959 when it should be 57646.
    
    Here is the explanation:
     u64 tmp;
     u32 result;
     …
     /* tmp = result = 4 * rates_996[0]
      *     = 4 * 480388888 = 0x72889c60
      */
     tmp = result;
    
     /* tmp = 0x72889c60 * 6144 = 0xabccea90000 */
     tmp *= SCALE;
    
     /* tmp = 0xabccea90000 / mcs_divisors[13]
      *     = 0xabccea90000 / 5120 = 0x8970bba6
      */
     do_div(tmp, mcs_divisors[rate->mcs]);
    
     /* result = 0x8970bba6 */
     result = tmp;
    
     /* normally (result * rate->nss) = 0x8970bba6 * 2 = 0x112e1774c,
      * but since result is u32, (result * rate->nss) = 0x12e1774c,
      * overflow happens and it loses the highest bit.
      * Then result =  0x12e1774c / 8 = 39595753,
      */
     result = (result * rate->nss) / 8;
    
    Signed-off-by: Paul Zhang <quic_paulz@quicinc.com>
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2023-01-27 13:42:19 +01:00
Jose Ignacio Tornos Martinez c6161eca15 wifi: cfg80211: fix ieee80211_data_to_8023_exthdr handling of small packets
Bugzilla: https://bugzilla.redhat.com/2136124

commit d9e249704084982ac7581a560ffa284e11621d43
Author: Felix Fietkau <nbd@nbd.name>
Date:   Fri Oct 7 14:56:11 2022 +0200

    wifi: cfg80211: fix ieee80211_data_to_8023_exthdr handling of small packets
    
    STP topology change notification packets only have a payload of 7 bytes,
    so they get dropped due to the skb->len < hdrlen + 8 check.
    Fix this by removing the extra 8 from the skb->len check and checking the
    return code on the skb_copy_bits calls.
    
    Fixes: 2d1c304cb2 ("cfg80211: add function for 802.3 conversion with separate output buffer")
    Reported-by: Chad Monroe <chad.monroe@smartrg.com>
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2023-01-27 13:42:13 +01:00
Jose Ignacio Tornos Martinez 0dfc05c07e wifi: cfg80211: Add link_id parameter to various key operations for MLO
Bugzilla: https://bugzilla.redhat.com/2136124

commit e7a7b84e33178db4a839c5e1773247be17597c1f
Author: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
Date:   Sat Jul 30 10:56:43 2022 +0530

    wifi: cfg80211: Add link_id parameter to various key operations for MLO
    
    Add support for various key operations on MLD by adding new parameter
    link_id. Pass the link_id received from userspace to driver for add_key,
    get_key, del_key, set_default_key, set_default_mgmt_key and
    set_default_beacon_key to support configuring keys specific to each MLO
    link. Userspace must not specify link ID for MLO pairwise key since it
    is common for all the MLO links.
    
    Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
    Link: https://lore.kernel.org/r/20220730052643.1959111-4-quic_vjakkam@quicinc.com
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2023-01-27 13:39:58 +01:00
Íñigo Huguet 41350e1cf1 wifi: cfg80211: fix MCS divisor value
Bugzilla: https://bugzilla.redhat.com/2136122

commit 64e966d1e84b29c9fa916cfeaabbf4013703942e
Author: Tamizh Chelvam Raja <quic_tamizhr@quicinc.com>
Date:   Thu Sep 8 23:40:34 2022 +0530

    wifi: cfg80211: fix MCS divisor value
    
    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: 9c97c88d2f ("cfg80211: Add support to calculate and report 4096-QAM HE rates")
    Signed-off-by: Tamizh Chelvam Raja <quic_tamizhr@quicinc.com>
    Link: https://lore.kernel.org/r/20220908181034.9936-1-quic_tamizhr@quicinc.com
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2022-11-28 12:57:54 +01:00
Íñigo Huguet 99a747faab wifi: cfg80211: add cfg80211_get_iftype_ext_capa()
Bugzilla: https://bugzilla.redhat.com/2136122

commit 7464f665158e09f3f29116d8d0676824c1f1eeda
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Tue Jul 12 18:32:49 2022 +0200

    wifi: cfg80211: add cfg80211_get_iftype_ext_capa()
    
    Add a helper function cfg80211_get_iftype_ext_capa() to
    look up interface type-specific (extended) capabilities.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2022-11-28 12:57:37 +01:00
Íñigo Huguet a449340399 wifi: cfg80211: clean up links appropriately
Bugzilla: https://bugzilla.redhat.com/2136122

commit cdf0a0a80c841cfede6926d417a8756ea4c52d26
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Wed Jul 6 09:57:42 2022 +0200

    wifi: cfg80211: clean up links appropriately
    
    This was missing earlier, we need to remove links when
    interfaces are being destroyed, and we also need to
    stop (AP) operations when a link is being destroyed.
    Address these issues to remove many warnings that will
    otherwise appear in mac80211.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2022-11-28 12:57:32 +01:00
Íñigo Huguet 7cc314edf6 wifi: cfg80211: do some rework towards MLO link APIs
Bugzilla: https://bugzilla.redhat.com/2136122

Conflicts: removed chunk of unsupported driver rtl8723bs

commit 7b0a0e3c3a88260b6fcb017e49f198463aa62ed1
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Thu Apr 14 16:50:57 2022 +0200

    wifi: cfg80211: do some rework towards MLO link APIs
    
    In order to support multi-link operation with multiple links,
    start adding some APIs. The notable addition here is to have
    the link ID in a new nl80211 attribute, that will be used to
    differentiate the links in many nl80211 operations.
    
    So far, this patch adds the netlink NL80211_ATTR_MLO_LINK_ID
    attribute (as well as the NL80211_ATTR_MLO_LINKS attribute)
    and plugs it through the system in some places, checking the
    validity etc. along with other infrastructure needed for it.
    
    For now, I've decided to include only the over-the-air link
    ID in the API. I know we discussed that we eventually need to
    have to have other ways of identifying a link, but for local
    AP mode and auth/assoc commands as well as set_key etc. we'll
    use the OTA ID.
    
    Also included in this patch is some refactoring of the data
    structures in struct wireless_dev, splitting for the first
    time the data into type dependent pieces, to make reasoning
    about these things easier.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2022-11-28 12:56:58 +01:00
Patrick Talbert 23affdb965 Merge: wireless: stack & drivers update to v5.18
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/742

Bugzilla: https://bugzilla.redhat.com/2059999
Depends: https://bugzilla.redhat.com/2077839
Tested: automatic regression testing against a variety of recent hardware

The following are fixes that has been omitted because they will be included in a dedicated MR that will come next:
Omitted-fix: 47eea8ad62a1 mt76: mt7921: honor pm user configuration in mt7921_sniffer_interface_iter
Omitted-fix: 96c777708bca mt76: mt7915: fix DBDC default band selection on MT7915D
Omitted-fix: aa796f12091a mt76: mt7915: fix unbounded shift in mt7915_mcu_beacon_mbss
Omitted-fix: 1f682dc9fb37 ath11k: reduce the wait time of 11d scan and hw scan while add interface
Omitted-fix: 9bd6823f5a64 mt76: mt7915: fix possible uninitialized pointer dereference in mt7986_wmac_gpio_setup
Omitted-fix: badb6ffaa143 mt76: mt7915: do not pass data pointer to mt7915_mcu_muru_debug_set
Omitted-fix: 05268cf1789d mt76: mt7915: report rx mode value in mt7915_mac_fill_rx_rate
Omitted-fix: 21947f3a74d6 brcmfmac: use ISO3166 country code and 0 rev as fallback on brcmfmac43602 chips
Omitted-fix: 9497b7880ffd ath11k: reset 11d state in process of recovery
Omitted-fix: 78488a64aea9 iwlwifi: mei: fix potential NULL-ptr deref
Omitted-fix: fcf690b0b474 wifi: wilc1000: use correct sequence of RESET for chip Power-UP/Down55565

Wireless stack & drivers general update to v5.18. This doesn't include any fixes appeared later because they will all be included in a following MR.

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>

Approved-by: Kamal Heib <kheib@redhat.com>
Approved-by: Jarod Wilson <jarod@redhat.com>
Approved-by: José Ignacio Tornos Martínez <jtornosm@redhat.com>
Approved-by: John W. Linville <linville@redhat.com>

Signed-off-by: Patrick Talbert <ptalbert@redhat.com>
2022-06-24 09:04:05 +02:00
Petr Oros 33a9f8c5cd wireless: Use netif_rx().
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2089703

Upstream commit(s):
commit f9834dbdd322f144f7b51f2fe8017fc6b870b3ec
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date:   Sat Mar 5 23:12:52 2022 +0100

    wireless: Use netif_rx().

    Since commit
       baebdf48c3600 ("net: dev: Makes sure netif_rx() can be invoked in any context.")

    the function netif_rx() can be used in preemptible/thread context as
    well as in interrupt context.

    Use netif_rx().

    Cc: Johannes Berg <johannes@sipsolutions.net>
    Cc: linux-wireless@vger.kernel.org
    Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2022-06-06 11:54:25 +02:00
Íñigo Huguet be257c1d2a nl80211: add EHT MCS support
Bugzilla: https://bugzilla.redhat.com/2059999

commit cfb14110acf87b4db62e07ba08a80429f1749f40
Author: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
Date:   Mon Feb 14 17:29:55 2022 +0100

    nl80211: add EHT MCS support
    
    Add support for reporting and calculating EHT bitrates.
    
    Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
    Link: https://lore.kernel.org/r/1640163883-12696-7-git-send-email-quic_vjakkam@quicinc.com
    Link: https://lore.kernel.org/r/20220214163009.175289-2-johannes@sipsolutions.net
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2022-05-31 14:50:44 +02:00
Íñigo Huguet 548bc2e317 cfg80211/mac80211: assume CHECKSUM_COMPLETE includes SNAP
Bugzilla: https://bugzilla.redhat.com/2059999

commit 667aa7426454154ec1e0922f92625bb33ae9951f
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Wed Feb 2 10:49:36 2022 +0200

    cfg80211/mac80211: assume CHECKSUM_COMPLETE includes SNAP
    
    There's currently only one driver that reports CHECKSUM_COMPLETE,
    that is iwlwifi. The current hardware there calculates checksum
    after the SNAP header, but only RFC 1042 (and some other cases,
    but replicating the exact hardware logic for corner cases in the
    driver seemed awkward.)
    
    Newer generations of hardware will checksum _including_ the SNAP,
    which makes things easier.
    
    To handle that, simply always assume the checksum _includes_ the
    SNAP header, which this patch does, requiring to first add it
    for older iwlwifi hardware, and then remove it again later on
    conversion.
    
    Alternatively, we could have:
    
     1) Always assumed the checksum starts _after_ the SNAP header;
        the problem with this is that we'd have to replace the exact
        "what is the SNAP" check in iwlwifi that cfg80211 has.
    
     2) Made it configurable with some flag, but that seemed like too
        much complexity.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
    Link: https://lore.kernel.org/r/iwlwifi.20220202104617.230736e19e0e.I3e6745873585ad943c152fab9e23b5221f17a95f@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2022-05-31 14:50:36 +02:00
Íñigo Huguet cca34c924f cfg80211: call cfg80211_stop_ap when switch from P2P_GO type
Bugzilla: http://bugzilla.redhat.com/2043454

commit 563fbefed46ae4c1f70cffb8eb54c02df480b2c2
Author: Nguyen Dinh Phi <phind.uet@gmail.com>
Date:   Thu Oct 28 01:37:22 2021 +0800

    cfg80211: call cfg80211_stop_ap when switch from P2P_GO type
    
    If the userspace tools switch from NL80211_IFTYPE_P2P_GO to
    NL80211_IFTYPE_ADHOC via send_msg(NL80211_CMD_SET_INTERFACE), it
    does not call the cleanup cfg80211_stop_ap(), this leads to the
    initialization of in-use data. For example, this path re-init the
    sdata->assigned_chanctx_list while it is still an element of
    assigned_vifs list, and makes that linked list corrupt.
    
    Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com>
    Reported-by: syzbot+bbf402b783eeb6d908db@syzkaller.appspotmail.com
    Link: https://lore.kernel.org/r/20211027173722.777287-1-phind.uet@gmail.com
    Cc: stable@vger.kernel.org
    Fixes: ac800140c2 ("cfg80211: .stop_ap when interface is going down")
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2022-02-21 11:40:39 +01:00
Íñigo Huguet ac4409cf3a nl80211: Add LC placeholder band definition to nl80211_band
Bugzilla: http://bugzilla.redhat.com/2043454

commit 63fa04266629b9559d66c4dc18b03e0f9fc04a02
Author: Srinivasan Raju <srini.raju@purelifi.com>
Date:   Mon Oct 18 11:00:54 2021 +0100

    nl80211: Add LC placeholder band definition to nl80211_band
    
    Define LC band which is a draft under IEEE 802.11bb.
    Current NL80211_BAND_LC is a placeholder band and
    will be more defined IEEE 802.11bb progresses.
    
    Signed-off-by: Srinivasan Raju <srini.raju@purelifi.com>
    Link: https://lore.kernel.org/r/20211018100143.7565-2-srini.raju@purelifi.com
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2022-02-21 11:40:31 +01:00
Íñigo Huguet 1ec33a6be6 cfg80211: correct bridge/4addr mode check
Bugzilla: http://bugzilla.redhat.com/2033354

commit 689a0a9f505f7bffdefe6f17fddb41c8ab6344f6
Author: Janusz Dziedzic <janusz.dziedzic@gmail.com>
Date:   Sun Oct 24 22:15:46 2021 +0200

    cfg80211: correct bridge/4addr mode check
    
    Without the patch we fail:
    
    $ sudo brctl addbr br0
    $ sudo brctl addif br0 wlp1s0
    $ sudo iw wlp1s0 set 4addr on
    command failed: Device or resource busy (-16)
    
    Last command failed but iface was already in 4addr mode.
    
    Fixes: ad4bb6f888 ("cfg80211: disallow bridging managed/adhoc interfaces")
    Signed-off-by: Janusz Dziedzic <janusz.dziedzic@gmail.com>
    Link: https://lore.kernel.org/r/20211024201546.614379-1-janusz.dziedzic@gmail.com
    [add fixes tag, fix indentation, edit commit log]
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2021-12-22 13:46:09 +01:00
Du Cheng a64b6a25dd cfg80211: call cfg80211_leave_ocb when switching away from OCB
If the userland switches back-and-forth between NL80211_IFTYPE_OCB and
NL80211_IFTYPE_ADHOC via send_msg(NL80211_CMD_SET_INTERFACE), there is a
chance where the cleanup cfg80211_leave_ocb() is not called. This leads
to initialization of in-use memory (e.g. init u.ibss while in-use by
u.ocb) due to a shared struct/union within ieee80211_sub_if_data:

struct ieee80211_sub_if_data {
    ...
    union {
        struct ieee80211_if_ap ap;
        struct ieee80211_if_vlan vlan;
        struct ieee80211_if_managed mgd;
        struct ieee80211_if_ibss ibss; // <- shares address
        struct ieee80211_if_mesh mesh;
        struct ieee80211_if_ocb ocb; // <- shares address
        struct ieee80211_if_mntr mntr;
        struct ieee80211_if_nan nan;
    } u;
    ...
}

Therefore add handling of otype == NL80211_IFTYPE_OCB, during
cfg80211_change_iface() to perform cleanup when leaving OCB mode.

link to syzkaller bug:
https://syzkaller.appspot.com/bug?id=0612dbfa595bf4b9b680ff7b4948257b8e3732d5

Reported-by: syzbot+105896fac213f26056f9@syzkaller.appspotmail.com
Signed-off-by: Du Cheng <ducheng2@gmail.com>
Link: https://lore.kernel.org/r/20210428063941.105161-1-ducheng2@gmail.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2021-05-31 21:27:15 +02:00
Mathy Vanhoef 2b8a1fee34 cfg80211: mitigate A-MSDU aggregation attacks
Mitigate A-MSDU injection attacks (CVE-2020-24588) by detecting if the
destination address of a subframe equals an RFC1042 (i.e., LLC/SNAP)
header, and if so dropping the complete A-MSDU frame. This mitigates
known attacks, although new (unknown) aggregation-based attacks may
remain possible.

This defense works because in A-MSDU aggregation injection attacks, a
normal encrypted Wi-Fi frame is turned into an A-MSDU frame. This means
the first 6 bytes of the first A-MSDU subframe correspond to an RFC1042
header. In other words, the destination MAC address of the first A-MSDU
subframe contains the start of an RFC1042 header during an aggregation
attack. We can detect this and thereby prevent this specific attack.
For details, see Section 7.2 of "Fragment and Forge: Breaking Wi-Fi
Through Frame Aggregation and Fragmentation".

Note that for kernel 4.9 and above this patch depends on "mac80211:
properly handle A-MSDUs that start with a rfc1042 header". Otherwise
this patch has no impact and attacks will remain possible.

Cc: stable@vger.kernel.org
Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
Link: https://lore.kernel.org/r/20210511200110.25d93176ddaf.I9e265b597f2cd23eb44573f35b625947b386a9de@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2021-05-11 20:13:13 +02:00
Mathy Vanhoef a1d5ff5651 mac80211: properly handle A-MSDUs that start with an RFC 1042 header
Properly parse A-MSDUs whose first 6 bytes happen to equal a rfc1042
header. This can occur in practice when the destination MAC address
equals AA:AA:03:00:00:00. More importantly, this simplifies the next
patch to mitigate A-MSDU injection attacks.

Cc: stable@vger.kernel.org
Signed-off-by: Mathy Vanhoef <Mathy.Vanhoef@kuleuven.be>
Link: https://lore.kernel.org/r/20210511200110.0b2b886492f0.I23dd5d685fe16d3b0ec8106e8f01b59f499dffed@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2021-05-11 20:13:03 +02:00
Joe Perches 623b988f2d cfg80211: constify ieee80211_get_response_rate return
It's not modified so make it const with the eventual goal of moving
data to text for various static struct ieee80211_rate arrays.

Signed-off-by: Joe Perches <joe@perches.com>
Link: https://lore.kernel.org/r/8b210b5f5972e39eded269b35a1297cf824c4181.camel@perches.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2021-04-19 11:59:33 +02:00
Johannes Berg a05829a722 cfg80211: avoid holding the RTNL when calling the driver
Currently, _everything_ in cfg80211 holds the RTNL, and if you
have a slow USB device (or a few) you can get some bad lock
contention on that.

Fix that by re-adding a mutex to each wiphy/rdev as we had at
some point, so we have locking for the wireless_dev lists and
all the other things in there, and also so that drivers still
don't have to worry too much about it (they still won't get
parallel calls for a single device).

Then, we can restrict the RTNL to a few cases where we add or
remove interfaces and really need the added protection. Some
of the global list management still also uses the RTNL, since
we need to have it anyway for netdev management, but we only
hold the RTNL for very short periods of time here.

Link: https://lore.kernel.org/r/20210122161942.81df9f5e047a.I4a8e1a60b18863ea8c5e6d3a0faeafb2d45b2f40@changeid
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> [marvell driver issues]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2021-01-26 11:55:50 +01:00
Max Chen d9c85e2472 cfg80211: Add phyrate conversion support for extended MCS in 60GHz band
The current phyrate conversion does not include extended MCS and provides
incorrect rates. Add a flag for extended MCS in DMG and add corresponding
phyrate table for the correct conversions using base MCS in DMG specs.

Signed-off-by: Max Chen <mxchen@codeaurora.org>
Link: https://lore.kernel.org/r/1609977050-7089-2-git-send-email-mxchen@codeaurora.org
[reduce data size, make a single WARN]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2021-01-22 09:11:36 +01:00
Arend van Spriel c27aa56a72 cfg80211: add VHT rate entries for MCS-10 and MCS-11
Observed the warning in cfg80211_calculate_bitrate_vht() using an
11ac chip reporting MCS-11. Since devices reporting non-standard
MCS-9 is already supported add similar entries for MCS-10 and MCS-11.
Actually, the value of MCS-9@20MHz is slightly off so corrected that.

Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Link: https://lore.kernel.org/r/20210105105839.3795-1-arend.vanspriel@broadcom.com
[fix array size]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2021-01-22 09:11:36 +01:00
Anant Thazhemadam 2d9463083c nl80211: validate key indexes for cfg80211_registered_device
syzbot discovered a bug in which an OOB access was being made because
an unsuitable key_idx value was wrongly considered to be acceptable
while deleting a key in nl80211_del_key().

Since we don't know the cipher at the time of deletion, if
cfg80211_validate_key_settings() were to be called directly in
nl80211_del_key(), even valid keys would be wrongly determined invalid,
and deletion wouldn't occur correctly.
For this reason, a new function - cfg80211_valid_key_idx(), has been
created, to determine if the key_idx value provided is valid or not.
cfg80211_valid_key_idx() is directly called in 2 places -
nl80211_del_key(), and cfg80211_validate_key_settings().

Reported-by: syzbot+49d4cab497c2142ee170@syzkaller.appspotmail.com
Tested-by: syzbot+49d4cab497c2142ee170@syzkaller.appspotmail.com
Suggested-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Anant Thazhemadam <anant.thazhemadam@gmail.com>
Link: https://lore.kernel.org/r/20201204215825.129879-1-anant.thazhemadam@gmail.com
Cc: stable@vger.kernel.org
[also disallow IGTK key IDs if no IGTK cipher is supported]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2020-12-11 13:20:04 +01:00
Gustavo A. R. Silva 01c9c0ab35 cfg80211: Fix fall-through warnings for Clang
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning
by explicitly adding a break statement instead of letting the code fall
through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/ed94a115106fa9c6df94d09b2a6c5791c618c4f2.1605896059.git.gustavoars@kernel.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2020-12-11 12:50:52 +01:00
Johannes Berg e7e0517c10 cfg80211: remove WDS code
Remove all the code that was there to configure WDS interfaces,
now that there's no way to reach it anymore.

Link: https://lore.kernel.org/r/20201109105103.8f5b98e4068d.I5f5129041649ef2862b69683574bb3344743727b@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2020-11-11 08:39:13 +01:00
Vamsi Krishna 9c97c88d2f cfg80211: Add support to calculate and report 4096-QAM HE rates
Drivers supporting 4096-QAM rates as a vendor extension in HE mode need
to update the correct rate info to userspace while using 4096-QAM (MCS12
and MCS13) in HE mode. Add support to calculate bitrates of HE-MCS12 and
HE-MCS13 which represent the 4096-QAM modulation schemes. The MCS12 and
MCS13 bitrates are defined in IEEE P802.11be/D0.1.

In addition, scale up the bitrates by 3*2048 in order to accommodate
calculations for the new MCS12 and MCS13 rates without losing fraction
values.

Signed-off-by: Vamsi Krishna <vamsin@codeaurora.org>
Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
Link: https://lore.kernel.org/r/20201029183457.7005-1-jouni@codeaurora.org
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
2020-11-06 10:00:47 +01:00