09 Nov, 2022

8 commits

  • commit ff05d4b45dd89b922578dac497dcabf57cf771c6

    When we parse a multi-BSSID element, we might point some
    element pointers into the allocated nontransmitted_profile.
    However, we free this before returning, causing UAF when the
    relevant pointers in the parsed elements are accessed.

    Fix this by not allocating the scratch buffer separately but
    as part of the returned structure instead, that way, there
    are no lifetime issues with it.

    The scratch buffer introduction as part of the returned data
    here is taken from MLO feature work done by Ilan.

    This fixes CVE-2022-42719.

    Fixes: 5023b14cf4df ("mac80211: support profile split between elements")
    Co-developed-by: Ilan Peer
    Signed-off-by: Ilan Peer
    Reviewed-by: Kees Cook
    Signed-off-by: Johannes Berg
    Cc: Felix Fietkau
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit de124365a7d2deed22cf706583930f28d537ff0f)

    Johannes Berg
     
  • commit 8223ac199a3849257e86ec27865dc63f034b1cf1 upstream.

    My previous commit 5d24828d05f3 ("mac80211: always allocate
    struct ieee802_11_elems") had a few bugs and leaked the new
    allocated struct in a few error cases, fix that.

    Fixes: 5d24828d05f3 ("mac80211: always allocate struct ieee802_11_elems")
    Signed-off-by: Johannes Berg
    Link: https://lore.kernel.org/r/20211001211108.9839928e42e0.Ib81ca187d3d3af7ed1bfeac2e00d08a4637c8025@changeid
    Signed-off-by: Johannes Berg
    Cc: Felix Fietkau
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit 7d998f6b7365d50a9905bf57fd28b41c7ebe8e9d)

    Johannes Berg
     
  • As the 802.11 spec evolves, we need to parse more and more
    elements. This is causing the struct to grow, and we can no
    longer get away with putting it on the stack.

    Change the API to always dynamically allocate and return an
    allocated pointer that must be kfree()d later.

    As an alternative, I contemplated a scheme whereby we'd say
    in the code which elements we needed, e.g.

    DECLARE_ELEMENT_PARSER(elems,
    SUPPORTED_CHANNELS,
    CHANNEL_SWITCH,
    EXT(KEY_DELIVERY));

    ieee802_11_parse_elems(..., &elems, ...);

    and while I think this is possible and will save us a lot
    since most individual places only care about a small subset
    of the elements, it ended up being a bit more work since a
    lot of places do the parsing and then pass the struct to
    other functions, sometimes with multiple levels.

    Link: https://lore.kernel.org/r/20210920154009.26caff6b5998.I05ae58768e990e611aee8eca8abefd9d7bc15e05@changeid
    Signed-off-by: Johannes Berg
    Cc: Felix Fietkau
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit fee48f3bdd7516bb63da507213916227cf147211)

    Johannes Berg
     
  • commit 49a765d6785e99157ff5091cc37485732496864e upstream.

    There's no need to parse all elements etc. just to find the
    authentication challenge - use cfg80211_find_elem() instead.
    This also allows us to remove WLAN_EID_CHALLENGE handling
    from the element parsing entirely.

    Link: https://lore.kernel.org/r/20210920154009.45f9b3a15722.Ice3159ffad03a007d6154cbf1fb3a8c48489e86f@changeid
    Signed-off-by: Johannes Berg
    Cc: Felix Fietkau
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit 630060f1175676b9cb3a032767f20dbce93616c9)

    Johannes Berg
     
  • commit c6e37ed498f958254b5459253199e816b6bfc52f upstream.

    We're currently returning this value, but to prepare for
    returning the allocated structure, move it into there.

    Link: https://lore.kernel.org/r/20210920154009.479b8ebf999d.If0d4ba75ee38998dc3eeae25058aa748efcb2fc9@changeid
    Signed-off-by: Johannes Berg
    Cc: Felix Fietkau
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit 21df3a583e8e03d8f74fa2eedbcd7a2b3f5cabc1)

    Johannes Berg
     
  • commit a5b983c6073140b624f64e79fea6d33c3e4315a0 upstream.

    We currently pass the entire elements to the rx_bcn_presp()
    method, but only need mesh_config. Additionally, we use the
    length of the elements to calculate back the entire frame's
    length, but that's confusing - just pass the length of the
    frame instead.

    Link: https://lore.kernel.org/r/20210920154009.a18ed3d2da6c.I1824b773a0fbae4453e1433c184678ca14e8df45@changeid
    Signed-off-by: Johannes Berg
    Cc: Felix Fietkau
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit 864f2d3482f4bd0c62b355e35ee8300be8ef488e)

    Johannes Berg
     
  • commit b2d03cabe2b2e150ff5a381731ea0355459be09f upstream.

    If beacon protection is active but the beacon cannot be
    decrypted or is otherwise malformed, we call the cfg80211
    API to report this to userspace, but that uses a netdev
    pointer, which isn't present for P2P-Device. Fix this to
    call it only conditionally to ensure cfg80211 won't crash
    in the case of P2P-Device.

    This fixes CVE-2022-42722.

    Reported-by: Sönke Huster
    Fixes: 9eaf183af741 ("mac80211: Report beacon protection failures to user space")
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit 93a3a32554079432b49cf87f326607b2a2fab4f2)

    Johannes Berg
     
  • commit 8f033d2becc24aa6bfd2a5c104407963560caabc upstream.

    Per spec, the maximum value for the MaxBSSID ('n') indicator is 8,
    and the minimum is 1 since a multiple BSSID set with just one BSSID
    doesn't make sense (the # of BSSIDs is limited by 2^n).

    Limit this in the parsing in both cfg80211 and mac80211, rejecting
    any elements with an invalid value.

    This fixes potentially bad shifts in the processing of these inside
    the cfg80211_gen_new_bssid() function later.

    I found this during the investigation of CVE-2022-41674 fixed by the
    previous patch.

    Fixes: 0b8fb8235be8 ("cfg80211: Parsing of Multiple BSSID information in scanning")
    Fixes: 78ac51f81532 ("mac80211: support multi-bssid")
    Reviewed-by: Kees Cook
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman
    (cherry picked from commit 0a861bd25dad508e492c48169509d8c6b9246895)

    Johannes Berg
     

08 Sep, 2022

3 commits

  • commit 278d3ba61563ceed3cb248383ced19e14ec7bc1f upstream.

    On 32bit-UP u64_stats_fetch_begin() disables only preemption. If the
    reader is in preemptible context and the writer side
    (u64_stats_update_begin*()) runs in an interrupt context (IRQ or
    softirq) then the writer can update the stats during the read operation.
    This update remains undetected.

    Use u64_stats_fetch_begin_irq() to ensure the stats fetch on 32bit-UP
    are not interrupted by a writer. 32bit-SMP remains unaffected by this
    change.

    Cc: "David S. Miller"
    Cc: Catherine Sullivan
    Cc: David Awogbemila
    Cc: Dimitris Michailidis
    Cc: Eric Dumazet
    Cc: Hans Ulli Kroll
    Cc: Jakub Kicinski
    Cc: Jeroen de Borst
    Cc: Johannes Berg
    Cc: Linus Walleij
    Cc: Paolo Abeni
    Cc: Simon Horman
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: linux-wireless@vger.kernel.org
    Cc: netdev@vger.kernel.org
    Cc: oss-drivers@corigine.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Sebastian Andrzej Siewior
    Reviewed-by: Simon Horman
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Sebastian Andrzej Siewior
     
  • commit 60deb9f10eec5c6a20252ed36238b55d8b614a2c upstream.

    ieee80211_scan_rx() tries to access scan_req->flags after a
    null check, but a UAF is observed when the scan is completed
    and __ieee80211_scan_completed() executes, which then calls
    cfg80211_scan_done() leading to the freeing of scan_req.

    Since scan_req is rcu_dereference()'d, prevent the racing in
    __ieee80211_scan_completed() by ensuring that from mac80211's
    POV it is no longer accessed from an RCU read critical section
    before we call cfg80211_scan_done().

    Cc: stable@vger.kernel.org
    Link: https://syzkaller.appspot.com/bug?extid=f9acff9bf08a845f225d
    Reported-by: syzbot+f9acff9bf08a845f225d@syzkaller.appspotmail.com
    Suggested-by: Johannes Berg
    Signed-off-by: Siddh Raman Pant
    Link: https://lore.kernel.org/r/20220819200340.34826-1-code@siddh.me
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Siddh Raman Pant
     
  • commit 15bc8966b6d3a5b9bfe4c9facfa02f2b69b1e5f0 upstream.

    When we are not connected to a channel, sending channel "switch"
    announcement doesn't make any sense.

    The BSS list is empty in that case. This causes the for loop in
    cfg80211_get_bss() to be bypassed, so the function returns NULL
    (check line 1424 of net/wireless/scan.c), causing the WARN_ON()
    in ieee80211_ibss_csa_beacon() to get triggered (check line 500
    of net/mac80211/ibss.c), which was consequently reported on the
    syzkaller dashboard.

    Thus, check if we have an existing connection before generating
    the CSA beacon in ieee80211_ibss_finish_csa().

    Cc: stable@vger.kernel.org
    Fixes: cd7760e62c2a ("mac80211: add support for CSA in IBSS mode")
    Link: https://syzkaller.appspot.com/bug?id=05603ef4ae8926761b678d2939a3b2ad28ab9ca6
    Reported-by: syzbot+b6c9fe29aefe68e4ad34@syzkaller.appspotmail.com
    Signed-off-by: Siddh Raman Pant
    Tested-by: syzbot+b6c9fe29aefe68e4ad34@syzkaller.appspotmail.com
    Link: https://lore.kernel.org/r/20220814151512.9985-1-code@siddh.me
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Siddh Raman Pant
     

17 Aug, 2022

2 commits

  • commit 8f9dcc29566626f683843ccac6113a12208315ca upstream.

    The following is from a system that went OOM due to a memory leak:

    wlan0: Allocated STA 74:83:c2:64:0b:87
    wlan0: Allocated STA 74:83:c2:64:0b:87
    wlan0: IBSS finish 74:83:c2:64:0b:87 (---from ieee80211_ibss_add_sta)
    wlan0: Adding new IBSS station 74:83:c2:64:0b:87
    wlan0: moving STA 74:83:c2:64:0b:87 to state 2
    wlan0: moving STA 74:83:c2:64:0b:87 to state 3
    wlan0: Inserted STA 74:83:c2:64:0b:87
    wlan0: IBSS finish 74:83:c2:64:0b:87 (---from ieee80211_ibss_work)
    wlan0: Adding new IBSS station 74:83:c2:64:0b:87
    wlan0: moving STA 74:83:c2:64:0b:87 to state 2
    wlan0: moving STA 74:83:c2:64:0b:87 to state 3
    .
    .
    wlan0: expiring inactive not authorized STA 74:83:c2:64:0b:87
    wlan0: moving STA 74:83:c2:64:0b:87 to state 2
    wlan0: moving STA 74:83:c2:64:0b:87 to state 1
    wlan0: Removed STA 74:83:c2:64:0b:87
    wlan0: Destroyed STA 74:83:c2:64:0b:87

    The ieee80211_ibss_finish_sta() is called twice on the same STA from 2
    different locations. On the second attempt, the allocated STA is not
    destroyed creating a kernel memory leak.

    This is happening because sta_info_insert_finish() does not call
    sta_info_free() the second time when the STA already exists (returns
    -EEXIST). Note that the caller sta_info_insert_rcu() assumes STA is
    destroyed upon errors.

    Same fix is applied to -ENOMEM.

    Signed-off-by: Ahmed Zaki
    Link: https://lore.kernel.org/r/20211002145329.3125293-1-anzaki@gmail.com
    [change the error path label to use the existing code]
    Signed-off-by: Johannes Berg
    Signed-off-by: Viacheslav Sablin
    Signed-off-by: Greg Kroah-Hartman

    Ahmed Zaki
     
  • [ Upstream commit 2a2c86f15e17c5013b9897b67d895e64a25ae3cb ]

    We add the fields for parsing extended ADDBA request/respond,
    and new max 1K aggregation for limit ADDBA request/respond.

    Adjust drivers to use the proper macro, IEEE80211_MAX_AMPDU_BUF ->
    IEEE80211_MAX_AMPDU_BUF_HE.

    Signed-off-by: Mordechay Goodstein
    Link: https://lore.kernel.org/r/20220214173004.b8b447ce95b7.I0ee2554c94e89abc7a752b0f7cc7fd79c273efea@changeid
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Mordechay Goodstein
     

22 Jul, 2022

1 commit

  • commit 50e2ab39291947b6c6c7025cf01707c270fcde59 upstream.

    When using iTXQ, the code assumes that there is only one vif queue for
    broadcast packets, using the BE queue. Allowing non-BE queue marking
    violates that assumption and txq->ac == skb_queue_mapping is no longer
    guaranteed. This can cause issues with queue handling in the driver and
    also causes issues with the recent ATF change, resulting in an AQL
    underflow warning.

    Cc: stable@vger.kernel.org
    Signed-off-by: Felix Fietkau
    Link: https://lore.kernel.org/r/20220702145227.39356-1-nbd@nbd.name
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Felix Fietkau
     

09 Jun, 2022

3 commits

  • commit b041b7b9de6e1d4362de855ab90f9d03ef323edd upstream.

    In client mode, we can't connect to hidden SSID APs or SSIDs not advertised
    in beacons on DFS channels, since we're forced to passive scan. Fix this by
    sending out a probe request immediately after the first beacon, if active
    scan was requested by the user.

    Cc: stable@vger.kernel.org
    Reported-by: Catrinel Catrinescu
    Signed-off-by: Felix Fietkau
    Link: https://lore.kernel.org/r/20220420104907.36275-1-nbd@nbd.name
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Felix Fietkau
     
  • commit 2965c4cdf7ad9ce0796fac5e57debb9519ea721e upstream.

    In ieee80211_vif_use_reserved_context(), when we have an
    old context and the new context's replace_state is set to
    IEEE80211_CHANCTX_REPLACE_NONE, we free the old context
    in ieee80211_vif_use_reserved_reassign(). Therefore, we
    cannot check the old_ctx anymore, so we should set it to
    NULL after this point.

    However, since the new_ctx replace state is clearly not
    IEEE80211_CHANCTX_REPLACES_OTHER, we're not going to do
    anything else in this function and can just return to
    avoid accessing the freed old_ctx.

    Cc: stable@vger.kernel.org
    Fixes: 5bcae31d9cb1 ("mac80211: implement multi-vif in-place reservations")
    Signed-off-by: Johannes Berg
    Signed-off-by: Kalle Valo
    Link: https://lore.kernel.org/r/20220601091926.df419d91b165.I17a9b3894ff0b8323ce2afdb153b101124c821e5@changeid
    Signed-off-by: Greg Kroah-Hartman

    Johannes Berg
     
  • [ Upstream commit 5c6dd7bd569b54c0d2904125d7366aa93f077f67 ]

    Using an ath9k card the debugfs output of minstrel_ht looks like the following
    (note the zero values for the first four rates sum-of success/attempts):

    best ____________rate__________ ____statistics___ _____last____ ______sum-of________
    mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]
    OFDM 1 DP 6.0M 272 1640 5.2 3.1 53.8 3 0 0 0 0
    OFDM 1 C 9.0M 273 1104 7.7 4.6 53.8 4 0 0 0 0
    OFDM 1 B 12.0M 274 836 10.0 6.0 53.8 4 0 0 0 0
    OFDM 1 A S 18.0M 275 568 14.3 8.5 53.8 5 0 0 0 0
    OFDM 1 S 24.0M 276 436 18.1 0.0 0.0 5 0 1 80 1778
    OFDM 1 36.0M 277 300 24.9 0.0 0.0 0 0 1 0 107
    OFDM 1 S 48.0M 278 236 30.4 0.0 0.0 0 0 0 0 75
    OFDM 1 54.0M 279 212 33.0 0.0 0.0 0 0 0 0 72

    Total packet count:: ideal 16582 lookaround 885
    Average # of aggregated frames per A-MPDU: 1.0

    Debugging showed that the rate statistics for the first four rates where
    stored in the MINSTREL_CCK_GROUP instead of the MINSTREL_OFDM_GROUP because
    in minstrel_ht_get_stats() the supported check was not honoured as done in
    various other places, e.g net/mac80211/rc80211_minstrel_ht_debugfs.c:

    74 if (!(mi->supported[i] & BIT(j)))
    75 continue;

    With the patch applied the output looks good:

    best ____________rate__________ ____statistics___ _____last____ ______sum-of________
    mode guard # rate [name idx airtime max_tp] [avg(tp) avg(prob)] [retry|suc|att] [#success | #attempts]
    OFDM 1 D 6.0M 272 1640 5.2 5.2 100.0 3 0 0 1 1
    OFDM 1 C 9.0M 273 1104 7.7 7.7 100.0 4 0 0 38 38
    OFDM 1 B 12.0M 274 836 10.0 9.9 89.5 4 2 2 372 395
    OFDM 1 A P 18.0M 275 568 14.3 14.3 97.2 5 52 53 6956 7181
    OFDM 1 S 24.0M 276 436 18.1 0.0 0.0 0 0 1 6 163
    OFDM 1 36.0M 277 300 24.9 0.0 0.0 0 0 1 0 35
    OFDM 1 S 48.0M 278 236 30.4 0.0 0.0 0 0 0 0 38
    OFDM 1 S 54.0M 279 212 33.0 0.0 0.0 0 0 0 0 38

    Total packet count:: ideal 7097 lookaround 287
    Average # of aggregated frames per A-MPDU: 1.0

    Signed-off-by: Peter Seiderer
    Link: https://lore.kernel.org/r/20220404165414.1036-1-ps.report@gmx.net
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Peter Seiderer
     

25 May, 2022

1 commit

  • [ Upstream commit 5e469ed9764d4722c59562da13120bd2dc6834c5 ]

    When the QoS ack policy was set to non explicit / psmp ack, frames are treated
    as not being part of a BA session, which causes extra latency on reordering.
    Fix this by only bypassing reordering for packets with no-ack policy

    Signed-off-by: Felix Fietkau
    Link: https://lore.kernel.org/r/20220420105038.36443-1-nbd@nbd.name
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Felix Fietkau
     

18 May, 2022

1 commit

  • [ Upstream commit 86af062f40a73bf63321694e6bf637144f0383fe ]

    Currently MBSSID parameters in struct ieee80211_bss_conf
    are not reset upon connection. This could be problematic
    with some drivers in a scenario where the device first
    connects to a non-transmit BSS and then connects to a
    transmit BSS of a Multi BSS AP. The MBSSID parameters
    which are set after connecting to a non-transmit BSS will
    not be reset and the same parameters will be passed on to
    the driver during the subsequent connection to a transmit
    BSS of a Multi BSS AP.

    For example, firmware running on the ath11k device uses the
    Multi BSS data for tracking the beacon of a non-transmit BSS
    and reports the driver when there is a beacon miss. If we do
    not reset the MBSSID parameters during the subsequent
    connection to a transmit BSS, then the driver would have
    wrong MBSSID data and FW would be looking for an incorrect
    BSSID in the MBSSID beacon of a Multi BSS AP and reports
    beacon loss leading to an unstable connection.

    Reset the MBSSID parameters upon every connection to solve this
    problem.

    Fixes: 78ac51f81532 ("mac80211: support multi-bssid")
    Signed-off-by: Manikanta Pubbisetty
    Link: https://lore.kernel.org/r/20220428052744.27040-1-quic_mpubbise@quicinc.com
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Manikanta Pubbisetty
     

08 Apr, 2022

2 commits

  • [ Upstream commit 1f2c104448477512fcf7296df54bfbc3a6f9a765 ]

    If we're limiting bandwidth for some reason such as regulatory
    restrictions, then advertise that limitation just like we do
    for VHT today, so the AP is aware we cannot use the higher BW
    it might be using.

    Fixes: 41cbb0f5a295 ("mac80211: add support for HE")
    Signed-off-by: Johannes Berg
    Signed-off-by: Luca Coelho
    Link: https://lore.kernel.org/r/iwlwifi.20220202104617.70c8e3e7ee76.If317630de69ff1146bec7d47f5b83038695eb71d@changeid
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Johannes Berg
     
  • [ Upstream commit cee04f3c3a00ffd2a2a6ed1028e0ab58a3a28d25 ]

    The HE capability IE is an extension IE so remove
    an irrelevant comments.

    Signed-off-by: Ilan Peer
    Signed-off-by: Luca Coelho
    Link: https://lore.kernel.org/r/iwlwifi.20211129152938.550b95b5fca7.Ia31395e880172aefcc0a8c70ed060f84b94bdb83@changeid
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Ilan Peer
     

28 Mar, 2022

1 commit

  • commit 4a2d4496e15ea5bb5c8e83b94ca8ca7fb045e7d3 upstream.

    While commit 6a01afcf8468 ("mac80211: mesh: Free ie data when leaving
    mesh") fixed a memory leak on mesh leave / teardown it introduced a
    potential memory corruption caused by a double free when rejoining the
    mesh:

    ieee80211_leave_mesh()
    -> kfree(sdata->u.mesh.ie);
    ...
    ieee80211_join_mesh()
    -> copy_mesh_setup()
    -> old_ie = ifmsh->ie;
    -> kfree(old_ie);

    This double free / kernel panics can be reproduced by using wpa_supplicant
    with an encrypted mesh (if set up without encryption via "iw" then
    ifmsh->ie is always NULL, which avoids this issue). And then calling:

    $ iw dev mesh0 mesh leave
    $ iw dev mesh0 mesh join my-mesh

    Note that typically these commands are not used / working when using
    wpa_supplicant. And it seems that wpa_supplicant or wpa_cli are going
    through a NETDEV_DOWN/NETDEV_UP cycle between a mesh leave and mesh join
    where the NETDEV_UP resets the mesh.ie to NULL via a memcpy of
    default_mesh_setup in cfg80211_netdev_notifier_call, which then avoids
    the memory corruption, too.

    The issue was first observed in an application which was not using
    wpa_supplicant but "Senf" instead, which implements its own calls to
    nl80211.

    Fixing the issue by removing the kfree()'ing of the mesh IE in the mesh
    join function and leaving it solely up to the mesh leave to free the
    mesh IE.

    Cc: stable@vger.kernel.org
    Fixes: 6a01afcf8468 ("mac80211: mesh: Free ie data when leaving mesh")
    Reported-by: Matthias Kretschmer
    Signed-off-by: Linus Lüssing
    Tested-by: Mathias Kretschmer
    Link: https://lore.kernel.org/r/20220310183513.28589-1-linus.luessing@c0d3.blue
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Linus Lüssing
     

19 Mar, 2022

1 commit

  • [ Upstream commit a6bce78262f5dd4b50510f0aa47f3995f7b185f3 ]

    If an MFP station isn't authorized, the receiver will (or
    at least should) drop the action frame since it's a robust
    management frame, but if we're not authorized we haven't
    installed keys yet. Refuse attempts to start a session as
    they'd just time out.

    Signed-off-by: Johannes Berg
    Link: https://lore.kernel.org/r/20220203201528.ff4d5679dce9.I34bb1f2bc341e161af2d6faf74f91b332ba11285@changeid
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Johannes Berg
     

09 Mar, 2022

3 commits

  • commit 94d9864cc86f572f881db9b842a78e9d075493ae upstream.

    When we get anti-clogging token required (added by the commit
    mentioned below), or the other status codes added by the later
    commit 4e56cde15f7d ("mac80211: Handle special status codes in
    SAE commit") we currently just pretend (towards the internal
    state machine of authentication) that we didn't receive anything.

    This has the undesirable consequence of retransmitting the prior
    frame, which is not expected, because the timer is still armed.

    If we just disarm the timer at that point, it would result in
    the undesirable side effect of being in this state indefinitely
    if userspace crashes, or so.

    So to fix this, reset the timer and set a new auth_data->waiting
    in order to have no more retransmissions, but to have the data
    destroyed when the timer actually fires, which will only happen
    if userspace didn't continue (i.e. crashed or abandoned it.)

    Fixes: a4055e74a2ff ("mac80211: Don't destroy auth data in case of anti-clogging")
    Reported-by: Jouni Malinen
    Link: https://lore.kernel.org/r/20220224103932.75964e1d7932.Ia487f91556f29daae734bf61f8181404642e1eec@changeid
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Johannes Berg
     
  • commit 859ae7018316daa4adbc496012dcbbb458d7e510 upstream.

    There are two problems with the current code that have been highlighted
    with the AQL feature that is now enbaled by default.

    First problem is in ieee80211_rx_h_mesh_fwding(),
    ieee80211_select_queue_80211() is used on received packets to choose
    the sending AC queue of the forwarding packet although this function
    should only be called on TX packet (it uses ieee80211_tx_info).
    This ends with forwarded mesh packets been sent on unrelated random AC
    queue. To fix that, AC queue can directly be infered from skb->priority
    which has been extracted from QOS info (see ieee80211_parse_qos()).

    Second problem is the value of queue_mapping set on forwarded mesh
    frames via skb_set_queue_mapping() is not the AC of the packet but a
    hardware queue index. This may or may not work depending on AC to HW
    queue mapping which is driver specific.

    Both of these issues lead to improper AC selection while forwarding
    mesh packets but more importantly due to improper airtime accounting
    (which is done on a per STA, per AC basis) caused traffic stall with
    the introduction of AQL.

    Fixes: cf44012810cc ("mac80211: fix unnecessary frame drops in mesh fwding")
    Fixes: d3c1597b8d1b ("mac80211: fix forwarded mesh frame queue mapping")
    Co-developed-by: Remi Pommarel
    Signed-off-by: Remi Pommarel
    Signed-off-by: Nicolas Escande
    Link: https://lore.kernel.org/r/20220214173214.368862-1-nico.escande@gmail.com
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Nicolas Escande
     
  • commit 610d086d6df0b15c3732a7b4a5b0f1c3e1b84d4c upstream.

    mac80211 set capability NL80211_EXT_FEATURE_CONTROL_PORT_OVER_NL80211
    to upper layer by default. That means we should pass EAPoL packets through
    nl80211 path only, and should not send the EAPoL skb to netdevice diretly.
    At the meanwhile, wpa_supplicant would not register sock to listen EAPoL
    skb on the netdevice.

    However, there is no control_port_protocol handler in mac80211 for 802.3 RX
    packets, mac80211 driver would pass up the EAPoL rekey frame to netdevice
    and wpa_supplicant would be never interactive with this kind of packets,
    if SUPPORTS_RX_DECAP_OFFLOAD is enabled. This causes STA always rekey fail
    if EAPoL frame go through 802.3 path.

    To avoid this problem, align the same process as 802.11 type to handle
    this frame before put it into network stack.

    This also addresses a potential security issue in 802.3 RX mode that was
    previously fixed in commit a8c4d76a8dd4 ("mac80211: do not accept/forward
    invalid EAPOL frames").

    Cc: stable@vger.kernel.org # 5.12+
    Fixes: 80a915ec4427 ("mac80211: add rx decapsulation offload support")
    Signed-off-by: Deren Wu
    Link: https://lore.kernel.org/r/6889c9fced5859ebb088564035f84fd0fa792a49.1644680751.git.deren.wu@mediatek.com
    [fix typos, update comment and add note about security issue]
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Deren Wu
     

23 Feb, 2022

1 commit

  • commit a72c01a94f1d285a274219d36e2a17b4846c0615 upstream.

    As the possible failure of the alloc, the ifmgd->assoc_req_ies might be
    NULL pointer returned from kmemdup().
    Therefore it might be better to free the skb and return error in order
    to fail the association, like ieee80211_assoc_success().
    Also, the caller, ieee80211_do_assoc(), needs to deal with the return
    value from ieee80211_send_assoc().

    Fixes: 4d9ec73d2b78 ("cfg80211: Report Association Request frame IEs in association events")
    Signed-off-by: Jiasheng Jiang
    Link: https://lore.kernel.org/r/20220105081559.2387083-1-jiasheng@iscas.ac.cn
    [fix some paths to be errors, not success]
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Jiasheng Jiang
     

27 Jan, 2022

1 commit

  • [ Upstream commit 04be6d337d37400ad5b3d5f27ca87645ee5a18a3 ]

    Some AP can possibly try non-standard VHT rate and mac80211 warns and drops
    packets, and leads low TCP throughput.

    Rate marked as a VHT rate but data is invalid: MCS: 10, NSS: 2
    WARNING: CPU: 1 PID: 7817 at net/mac80211/rx.c:4856 ieee80211_rx_list+0x223/0x2f0 [mac8021

    Since commit c27aa56a72b8 ("cfg80211: add VHT rate entries for MCS-10 and MCS-11")
    has added, mac80211 adds this support as well.

    After this patch, throughput is good and iw can get the bitrate:
    rx bitrate: 975.1 MBit/s VHT-MCS 10 80MHz short GI VHT-NSS 2
    or
    rx bitrate: 1083.3 MBit/s VHT-MCS 11 80MHz short GI VHT-NSS 2

    Buglink: https://bugzilla.suse.com/show_bug.cgi?id=1192891
    Reported-by: Goldwyn Rodrigues
    Signed-off-by: Ping-Ke Shih
    Link: https://lore.kernel.org/r/20220103013623.17052-1-pkshih@realtek.com
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Ping-Ke Shih
     

11 Jan, 2022

2 commits

  • commit 8b5cb7e41d9d77ffca036b0239177de123394a55 upstream.

    Syzbot hit NULL deref in rhashtable_free_and_destroy(). The problem was
    in mesh_paths and mpp_paths being NULL.

    mesh_pathtbl_init() could fail in case of memory allocation failure, but
    nobody cared, since ieee80211_mesh_init_sdata() returns void. It led to
    leaving 2 pointers as NULL. Syzbot has found null deref on exit path,
    but it could happen anywhere else, because code assumes these pointers are
    valid.

    Since all ieee80211_*_setup_sdata functions are void and do not fail,
    let's embedd mesh_paths and mpp_paths into parent struct to avoid
    adding error handling on higher levels and follow the pattern of others
    setup_sdata functions

    Fixes: 60854fd94573 ("mac80211: mesh: convert path table to rhashtable")
    Reported-and-tested-by: syzbot+860268315ba86ea6b96b@syzkaller.appspotmail.com
    Signed-off-by: Pavel Skripkin
    Link: https://lore.kernel.org/r/20211230195547.23977-1-paskripkin@gmail.com
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Pavel Skripkin
     
  • commit 68a18ad71378a56858141c4449e02a30c829763e upstream.

    Clang static analysis reports this warnings

    mlme.c:5332:7: warning: Branch condition evaluates to a
    garbage value
    have_higher_than_11mbit)
    ^~~~~~~~~~~~~~~~~~~~~~~

    have_higher_than_11mbit is only set to true some of the time in
    ieee80211_get_rates() but is checked all of the time. So
    have_higher_than_11mbit needs to be initialized to false.

    Fixes: 5d6a1b069b7f ("mac80211: set basic rates earlier")
    Signed-off-by: Tom Rix
    Reviewed-by: Nick Desaulniers
    Link: https://lore.kernel.org/r/20211223162848.3243702-1-trix@redhat.com
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Tom Rix
     

29 Dec, 2021

1 commit

  • commit 87a270625a89fc841f1a7e21aae6176543d8385c upstream.

    We need to hold the local->mtx to release the channel context,
    as even encoded by the lockdep_assert_held() there. Fix it.

    Cc: stable@vger.kernel.org
    Fixes: 295b02c4be74 ("mac80211: Add FILS discovery support")
    Reported-and-tested-by: syzbot+11c342e5e30e9539cabd@syzkaller.appspotmail.com
    Link: https://lore.kernel.org/r/20211220090836.cee3d59a1915.I36bba9b79dc2ff4d57c3c7aa30dff9a003fe8c5c@changeid
    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Johannes Berg
     

22 Dec, 2021

8 commits

  • [ Upstream commit 511ab0c1dfb260a6b17b8771109e8d63474473a7 ]

    We should be doing the HE capabilities lookup based on the full
    interface type so if P2P doesn't have HE but client has it doesn't
    get confused. Fix that.

    Fixes: 2ab45876756f ("mac80211: add support for the ADDBA extension element")
    Signed-off-by: Johannes Berg
    Signed-off-by: Luca Coelho
    Link: https://lore.kernel.org/r/iwlwifi.20211129152938.010fc1d61137.If3a468145f29d670cb00a693bed559d8290ba693@changeid
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Johannes Berg
     
  • [ Upstream commit 06c41bda0ea14aa7fba932a9613c4ee239682cf0 ]

    When we call ieee80211_agg_start_txq(), that will in turn call
    schedule_and_wake_txq(). Called from ieee80211_stop_tx_ba_cb()
    this is done under sta->lock, which leads to certain circular
    lock dependencies, as reported by Chris Murphy:
    https://lore.kernel.org/r/CAJCQCtSXJ5qA4bqSPY=oLRMbv-irihVvP7A2uGutEbXQVkoNaw@mail.gmail.com

    In general, ieee80211_agg_start_txq() is usually not called
    with sta->lock held, only in this one place. But it's always
    called with sta->ampdu_mlme.mtx held, and that's therefore
    clearly sufficient.

    Change ieee80211_stop_tx_ba_cb() to also call it without the
    sta->lock held, by factoring it out of ieee80211_remove_tid_tx()
    (which is only called in this one place).

    This breaks the locking chain and makes it less likely that
    we'll have similar locking chain problems in the future.

    Fixes: ba8c3d6f16a1 ("mac80211: add an intermediate software queue implementation")
    Reported-by: Chris Murphy
    Signed-off-by: Johannes Berg
    Signed-off-by: Luca Coelho
    Link: https://lore.kernel.org/r/iwlwifi.20211202152554.f519884c8784.I555fef8e67d93fff3d9a304886c4a9f8b322e591@changeid
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Johannes Berg
     
  • [ Upstream commit d5e568c3a4ec2ddd23e7dc5ad5b0c64e4f22981a ]

    For admission control, obviously all of that only works for
    QoS data frames, otherwise we cannot even access the QoS
    field in the header.

    Syzbot reported (see below) an uninitialized value here due
    to a status of a non-QoS nullfunc packet, which isn't even
    long enough to contain the QoS header.

    Fix this to only do anything for QoS data packets.

    Reported-by: syzbot+614e82b88a1a4973e534@syzkaller.appspotmail.com
    Fixes: 02219b3abca5 ("mac80211: add WMM admission control support")
    Link: https://lore.kernel.org/r/20211122124737.dad29e65902a.Ieb04587afacb27c14e0de93ec1bfbefb238cc2a0@changeid
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Johannes Berg
     
  • commit 768c0b19b50665e337c96858aa2b7928d6dcf756 upstream.

    Before attempting to parse an extended element, verify that
    the extended element ID is present.

    Fixes: 41cbb0f5a295 ("mac80211: add support for HE")
    Reported-by: syzbot+59bdff68edce82e393b6@syzkaller.appspotmail.com
    Link: https://lore.kernel.org/r/20211211201023.f30a1b128c07.I5cacc176da94ba316877c6e10fe3ceec8b4dbd7d@changeid
    Cc: stable@vger.kernel.org
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Johannes Berg
     
  • commit 1fe98f5690c4219d419ea9cc190f94b3401cf324 upstream.

    Sending them out on a different queue can cause a race condition where a
    number of packets in the queue may be discarded by the receiver, because
    the ADDBA request is sent too early.
    This affects any driver with software A-MPDU setup which does not allocate
    packet seqno in hardware on tx, regardless of whether iTXQ is used or not.
    The only driver I've seen that explicitly deals with this issue internally
    is mwl8k.

    Cc: stable@vger.kernel.org
    Signed-off-by: Felix Fietkau
    Link: https://lore.kernel.org/r/20211202124533.80388-1-nbd@nbd.name
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Felix Fietkau
     
  • commit db7205af049d230e7e0abf61c1e74c1aab40f390 upstream.

    Mark TXQs as having seen transmit while they were stopped if
    we bail out of drv_wake_tx_queue() due to reconfig, so that
    the queue wake after this will make them catch up. This is
    particularly necessary for when TXQs are used for management
    packets since those TXQs won't see a lot of traffic that'd
    make them catch up later.

    Cc: stable@vger.kernel.org
    Fixes: 4856bfd23098 ("mac80211: do not call driver wake_tx_queue op during reconfig")
    Signed-off-by: Johannes Berg
    Signed-off-by: Luca Coelho
    Link: https://lore.kernel.org/r/iwlwifi.20211129152938.4573a221c0e1.I0d1d5daea3089be3fc0dccc92991b0f8c5677f0c@changeid
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Johannes Berg
     
  • commit 73111efacd3c6d9e644acca1d132566932be8af0 upstream.

    Some drivers that do their own sequence number allocation (e.g. ath9k) rely
    on being able to modify params->ssn on starting tx ampdu sessions.
    This was broken by a change that modified it to use sta->tid_seq[tid] instead.

    Cc: stable@vger.kernel.org
    Fixes: 31d8bb4e07f8 ("mac80211: agg-tx: refactor sending addba")
    Reported-by: Eneas U de Queiroz
    Signed-off-by: Felix Fietkau
    Link: https://lore.kernel.org/r/20211124094024.43222-1-nbd@nbd.name
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Felix Fietkau
     
  • commit 18688c80ad8a8dd50523dc9276e929932cac86d4 upstream.

    Since retransmission clears info->control, rate control needs to be called
    again, otherwise the driver might crash due to invalid rates.

    Cc: stable@vger.kernel.org # 5.14+
    Reported-by: Aaro Koskinen
    Reported-by: Robert W
    Fixes: 03c3911d2d67 ("mac80211: call ieee80211_tx_h_rate_ctrl() when dequeue")
    Signed-off-by: Felix Fietkau
    Tested-by: Aaro Koskinen
    Link: https://lore.kernel.org/r/20211122204323.9787-1-nbd@nbd.name
    Signed-off-by: Johannes Berg
    Signed-off-by: Greg Kroah-Hartman

    Felix Fietkau
     

08 Dec, 2021

1 commit

  • [ Upstream commit 30f6cf96912b638d0ddfc325204b598f94efddc2 ]

    The codepaths for rx with decap offload and tx with itxq were not updating
    the counters for the throughput led trigger.

    Signed-off-by: Felix Fietkau
    Link: https://lore.kernel.org/r/20211113063415.55147-1-nbd@nbd.name
    Signed-off-by: Johannes Berg
    Signed-off-by: Sasha Levin

    Felix Fietkau