24 Feb, 2016

2 commits

  • Since the PNs of all the tx keys are now tracked in the public
    part of the key struct (with atomic counter), we no longer
    need these functions.

    dvm and vt665{5,6} are currently the only users of these functions,
    so update them accordingly.

    Signed-off-by: Eliad Peller
    Signed-off-by: Emmanuel Grumbach
    Signed-off-by: Johannes Berg

    Eliad Peller
     
  • Some drivers/devices might want to set the IVs by
    themselves (and still let mac80211 generate MMIC).

    Specifically, this is needed when the device does
    offloading at certain times, and the driver has
    to make sure that the IVs of new tx frames (from
    the host) are synchronized with IVs that were
    potentially used during the offloading.

    Similarly to CCMP, move the TX IVs of TKIP keys to the
    public part of the key struct, and export a function
    to add the IV right into the crypto header.

    The public tx_pn field is defined as atomic64, so define
    TKIP_PN_TO_IV16/32 helper macros to convert it to iv16/32
    when needed.

    Since the iv32 used for the p1k cache is taken
    directly from the frame, we can safely remove
    iv16/32 from being protected by tkip.txlock.

    Signed-off-by: Eliad Peller
    Signed-off-by: Emmanuel Grumbach
    Signed-off-by: Johannes Berg

    Eliad Peller
     

04 Dec, 2015

1 commit

  • add ieee80211_iter_keys_rcu() to iterate over uploaded
    keys in atomic context (when rcu is locked)

    The station removal code removes the keys only after
    calling synchronize_net(), so it's not safe to iterate
    the keys at this point (and postponing the actual key
    deletion with call_rcu() might result in some
    badly-ordered ops calls).

    Add a flag to indicate a station is being removed,
    and skip the configured keys if it's set.

    Signed-off-by: Eliad Peller
    Signed-off-by: Emmanuel Grumbach
    Signed-off-by: Johannes Berg

    Eliad Peller
     

17 Jul, 2015

1 commit


24 Jun, 2015

1 commit


22 Jun, 2015

1 commit

  • Unfortunately, Michal's change to fix AP_VLAN crypto tailroom
    caused a locking issue that was reported by lockdep, but only
    in a few cases - the issue was a classic ABBA deadlock caused
    by taking the mtx after the key_mtx, where normally they're
    taken the other way around.

    As the key mutex protects the field in question (I'm adding a
    few annotations to make that clear) only the iteration needs
    to be protected, but we can also iterate the interface list
    with just RCU protection while holding the key mutex.

    Fixes: f9dca80b98ca ("mac80211: fix AP_VLAN crypto tailroom calculation")
    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

10 Jun, 2015

2 commits


02 Jun, 2015

2 commits

  • For drivers supporting TSO or similar features, but that still have
    PN assignment in software, there's a need to have some memory to
    store the current PN value. As mac80211 already stores this and it's
    somewhat complicated to add a per-driver area to the key struct (due
    to the dynamic sizing thereof) it makes sense to just move the TX PN
    to the keyconf, i.e. the public part of the key struct.

    As TKIP is more complicated and we won't able to offload it in this
    way right now (fast-xmit is skipped for TKIP unless the HW does it
    all, and our hardware needs MMIC calculation in software) I've not
    moved that for now - it's possible but requires exposing a lot of
    the internal TKIP state.

    As an bonus side effect, we can remove a lot of code by assuming the
    keyseq struct has a certain layout - with BUILD_BUG_ON to verify it.

    This might also improve performance, since now TX and RX no longer
    share a cacheline.

    Reviewed-by: Emmanuel Grumbach
    Signed-off-by: Johannes Berg

    Johannes Berg
     
  • Conflicts:
    drivers/net/phy/amd-xgbe-phy.c
    drivers/net/wireless/iwlwifi/Kconfig
    include/net/mac80211.h

    iwlwifi/Kconfig and mac80211.h were both trivial overlapping
    changes.

    The drivers/net/phy/amd-xgbe-phy.c file got removed in 'net-next' and
    the bug fix that happened on the 'net' side is already integrated
    into the rest of the amd-xgbe driver.

    Signed-off-by: David S. Miller

    David S. Miller
     

20 May, 2015

1 commit

  • Some splats I was seeing:

    (a) WARNING: CPU: 1 PID: 0 at /devel/src/linux/net/mac80211/wep.c:102 ieee80211_wep_add_iv
    (b) WARNING: CPU: 1 PID: 0 at /devel/src/linux/net/mac80211/wpa.c:73 ieee80211_tx_h_michael_mic_add
    (c) WARNING: CPU: 3 PID: 0 at /devel/src/linux/net/mac80211/wpa.c:433 ieee80211_crypto_ccmp_encrypt

    I've seen (a) and (b) with ath9k hw crypto and (c)
    with ath9k sw crypto. All of them were related to
    insufficient skb tailroom and I was able to
    trigger these with ping6 program.

    AP_VLANs may inherit crypto keys from parent AP.
    This wasn't considered and yielded problems in
    some setups resulting in inability to transmit
    data because mac80211 wouldn't resize skbs when
    necessary and subsequently drop some packets due
    to insufficient tailroom.

    For efficiency purposes don't inspect both AP_VLAN
    and AP sdata looking for tailroom counter. Instead
    update AP_VLAN tailroom counters whenever their
    master AP tailroom counter changes.

    Signed-off-by: Michal Kazior
    Signed-off-by: Johannes Berg

    Michal Kazior
     

06 May, 2015

2 commits

  • Currently, a cipher scheme can advertise an arbitrarily long
    sequence counter, but mac80211 only supports up to 16 bytes
    and the initial value from userspace will be truncated.

    Fix two things:
    * don't allow the driver to register anything longer than
    the 16 bytes that mac80211 reserves space for
    * require userspace to specify a starting value with the
    correct length (or none at all)

    Signed-off-by: Johannes Berg

    Johannes Berg
     
  • For ciphers not supported by mac80211, the function currently
    doesn't return any PN data. Fix this by extending the driver's
    get_key_seq() a little more to allow moving arbitrary PN data.

    Signed-off-by: Johannes Berg

    Johannes Berg
     

22 Apr, 2015

1 commit

  • In order to speed up mac80211's TX path, add the "fast-xmit" cache
    that will cache the data frame 802.11 header and other data to be
    able to build the frame more quickly. This cache is rebuilt when
    external triggers imply changes, but a lot of the checks done per
    packet today are simplified away to the check for the cache.

    There's also a more detailed description in the code.

    Signed-off-by: Johannes Berg

    Johannes Berg
     

17 Mar, 2015

1 commit

  • When a key is installed using a cipher scheme, set a new
    internal key flag (KEY_FLAG_CIPHER_SCHEME) on it, to allow
    distinguishing such keys more easily.

    In particular, use this flag on the TX path instead of
    testing the sta->cipher_scheme pointer, as the station is
    NULL for broad-/multicast message, and use the key's iv_len
    instead of the cipher scheme information.

    Signed-off-by: Cedric Izoard
    [add missing documentation, rewrite commit message]
    Signed-off-by: Johannes Berg

    Cedric Izoard
     

27 Jan, 2015

4 commits

  • This allows mac80211 to configure BIP-GMAC-128 and BIP-GMAC-256 to the
    driver and also use software-implementation within mac80211 when the
    driver does not support this with hardware accelaration.

    Signed-off-by: Jouni Malinen
    Signed-off-by: Johannes Berg

    Jouni Malinen
     
  • This allows mac80211 to configure BIP-CMAC-256 to the driver and also
    use software-implementation within mac80211 when the driver does not
    support this with hardware accelaration.

    Signed-off-by: Jouni Malinen
    Signed-off-by: Johannes Berg

    Jouni Malinen
     
  • This allows mac80211 to configure CCMP-256 to the driver and also use
    software-implementation within mac80211 when the driver does not support
    this with hardware accelaration.

    Signed-off-by: Jouni Malinen
    [squash ccmp256 -> mic_len argument change]
    Signed-off-by: Johannes Berg

    Jouni Malinen
     
  • This allows mac80211 to configure GCMP and GCMP-256 to the driver and
    also use software-implementation within mac80211 when the driver does
    not support this with hardware accelaration.

    Signed-off-by: Jouni Malinen
    [remove a spurious newline]
    Signed-off-by: Johannes Berg

    Jouni Malinen
     

23 Jan, 2015

1 commit

  • Some drivers unfortunately cannot support software crypto, but
    mac80211 currently assumes that they do.

    This has the issue that if the hardware enabling fails for some
    reason, the software fallback is used, which won't work. This
    clearly isn't desirable, the error should be reported and the
    key setting refused.

    Support this in mac80211 by allowing drivers to set a new HW
    flag IEEE80211_HW_SW_CRYPTO_CONTROL, in which case mac80211 will
    only allow software fallback if the set_key() method returns 1.
    The driver will also need to advertise supported cipher suites
    so that mac80211 doesn't advertise any (future) software ciphers
    that the driver can't actually do.

    While at it, to make it easier to support this, refactor the
    ieee80211_init_cipher_suites() code.

    Signed-off-by: Johannes Berg

    Johannes Berg
     

07 Jan, 2015

1 commit

  • When hw acceleration is enabled, the GENERATE_IV or PUT_IV_SPACE flags
    only require headroom space. Therefore, the tailroom-needed counter can
    safely be decremented for most drivers.

    The older incarnation of this patch (ca34e3b5) assumed that the above
    holds true for all drivers. As reported by Christopher Chavez and
    researched by Christian Lamparter and Larry Finger, this isn't a valid
    assumption for p54 and cw1200.

    Drivers that still require tailroom for ICV/MIC even when HW encryption
    is enabled can use IEEE80211_KEY_FLAG_RESERVE_TAILROOM to indicate it.

    Signed-off-by: Ido Yariv
    Cc: Christopher Chavez
    Cc: Christian Lamparter
    Cc: Larry Finger
    Cc: Solomon Peachy
    Signed-off-by: Johannes Berg

    Ido Yariv
     

05 Jan, 2015

1 commit

  • This reverts commit ca34e3b5c808385b175650605faa29e71e91991b.

    It turns out that the p54 and cw2100 drivers assume that there's
    tailroom even when they don't say they really need it. However,
    there's currently no way for them to explicitly say they do need
    it, so for now revert this.

    This fixes https://bugzilla.kernel.org/show_bug.cgi?id=90331.

    Cc: stable@vger.kernel.org
    Fixes: ca34e3b5c808 ("mac80211: Fix accounting of the tailroom-needed counter")
    Reported-by: Christopher Chavez
    Bisected-by: Larry Finger
    Debugged-by: Christian Lamparter
    Signed-off-by: Johannes Berg

    Johannes Berg
     

17 Dec, 2014

1 commit

  • When writing the code to allow per-station GTKs, I neglected to
    take into account the management frame keys (index 4 and 5) when
    freeing the station and only added code to free the first four
    data frame keys.

    Fix this by iterating the array of keys over the right length.

    Cc: stable@vger.kernel.org
    Fixes: e31b82136d1a ("cfg80211/mac80211: allow per-station GTKs")
    Signed-off-by: Johannes Berg

    Johannes Berg
     

22 Oct, 2014

1 commit


11 Sep, 2014

1 commit


05 Sep, 2014

1 commit

  • Our legal structure changed at some point (see wikipedia), but
    we forgot to immediately switch over to the new copyright
    notice.

    For files that we have modified in the time since the change,
    add the proper copyright notice now.

    Signed-off-by: Johannes Berg
    Signed-off-by: Emmanuel Grumbach
    Signed-off-by: Johannes Berg

    Johannes Berg
     

26 Aug, 2014

1 commit


21 Jul, 2014

1 commit

  • sdata can't be NULL, and key being NULL is really not possible
    unless the code is modified.

    The sdata check made a static analyze (klocwork) unhappy because
    we would get pointer to local (sdata->local) and only then check
    if sdata is non-NULL.

    Signed-off-by: Eytan Lifshitz
    Signed-off-by: Emmanuel Grumbach
    [remove !key check as well]
    Signed-off-by: Johannes Berg

    Eytan Lifshitz
     

29 Apr, 2014

1 commit

  • These BUG_ON statements should never trigger, but in the unlikely
    event that somebody does manage don't stop everything but simply
    exit the code path with an error.

    Leave the one BUG_ON where changing it would result in a NULL
    pointer dereference.

    Signed-off-by: Johannes Berg

    Johannes Berg
     

16 Dec, 2013

2 commits

  • When the AP interface is stopped, free all AP and VLAN keys at
    once to only require synchronize_net() once. Since that does
    synchronize_net(), also move two such calls into the function
    (using the new force_synchronize parameter) to avoid doing it
    twice.

    Signed-off-by: Johannes Berg

    Johannes Berg
     
  • There's no reason to do this inside the sta key removal
    since the keys can only be reached through the sta (and
    not by the driver at all) so once the sta can no longer
    be reached, the keys are safe.

    This will allow further optimisation opportunities with
    multiple stations.

    Signed-off-by: Johannes Berg

    Johannes Berg
     

26 Nov, 2013

2 commits

  • This adds generic cipher scheme support to mac80211, such schemes
    are fully under control by the driver. On hw registration drivers
    may specify additional HW ciphers with a scheme how these ciphers
    have to be handled by mac80211 TX/RR. A cipher scheme specifies a
    cipher suite value, a size of the security header to be added to
    or stripped from frames and how the PN is to be verified on RX.

    Signed-off-by: Max Stepanov
    Signed-off-by: Johannes Berg

    Max Stepanov
     
  • There's no code calling ieee80211_key_replace() with both
    arguments NULL and it wouldn't make sense, but in the
    interest of maintainability add a warning for it. As a
    side effect, this also shuts up a smatch warning.

    Signed-off-by: Johannes Berg

    Johannes Berg
     

26 Sep, 2013

1 commit


16 Aug, 2013

1 commit

  • In order to be able to (securely) keep connections alive after
    the system was suspended for WoWLAN, we need some additional
    APIs. We already have API (ieee80211_gtk_rekey_notify) to tell
    wpa_supplicant about the new replay counter if GTK rekeying
    was done by the device while the host was asleep, but that's
    not sufficient.

    If GTK rekeying wasn't done, we need to tell the host about
    sequence counters for the GTK (and PTK regardless of rekeying)
    that was used while asleep, add ieee80211_set_key_rx_seq() for
    that.

    If GTK rekeying was done, then we need to be able to disable
    the old keys (with ieee80211_remove_key()) and allocate the
    new GTK key(s) in mac80211 (with ieee80211_gtk_rekey_add()).

    If protocol offload (e.g. ARP) is implemented, then also the
    TX sequence counter for the PTK must be updated, using the new
    ieee80211_set_key_tx_seq() function.

    Signed-off-by: Johannes Berg

    Johannes Berg
     

17 May, 2013

1 commit


11 Mar, 2013

3 commits


06 Mar, 2013

1 commit

  • During roaming, the crypto_tx_tailroom_needed_cnt counter
    will often take values 2,1,0,1,2 because first keys are
    removed and then new keys are added. This is inefficient
    because during the 0->1 transition, synchronize_net must
    be called to avoid packet races, although typically no
    packets would be flowing during that time.

    To avoid that, defer the decrement (2->1, 1->0) when keys
    are removed (by half a second). This means the counter
    will really have the values 2,2,2,3,4 ... 2, thus never
    reaching 0 and having to do the 0->1 transition.

    Note that this patch entirely disregards the drivers for
    which this optimisation was done to start with, for them
    the key removal itself will be expensive because it has
    to synchronize_net() after the counter is incremented to
    remove the key from HW crypto. For them the sequence will
    look like this: 0,1,0,1,0,1,0,1,0 (*) which is clearly a
    lot more inefficient. This could be addressed separately,
    during key removal the 0->1->0 sequence isn't necessary.

    (*) it starts at 0 because HW crypto is on, then goes to
    1 when HW crypto is disabled for a key, then back to
    0 because the key is deleted; this happens for both
    keys in the example. When new keys are added, it goes
    to 1 first because they're added in software; when a
    key is moved to hardware it goes back to 0

    Signed-off-by: Johannes Berg

    Johannes Berg