You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
Merge tag 'mac80211-next-for-davem-2015-02-03' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next
Last round of updates for net-next: * revert a patch that caused a regression with mesh userspace (Bob) * fix a number of suspend/resume related races (from Emmanuel, Luca and myself - we'll look at backporting later) * add software implementations for new ciphers (Jouni) * add a new ACPI ID for Broadcom's rfkill (Mika) * allow using netns FD for wireless (Vadim) * some other cleanups (various) Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@@ -446,6 +446,7 @@ struct net *get_net_ns_by_fd(int fd)
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
#endif
|
||||
EXPORT_SYMBOL_GPL(get_net_ns_by_fd);
|
||||
|
||||
struct net *get_net_ns_by_pid(pid_t pid)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ config MAC80211
|
||||
select CRYPTO_ARC4
|
||||
select CRYPTO_AES
|
||||
select CRYPTO_CCM
|
||||
select CRYPTO_GCM
|
||||
select CRC32
|
||||
select AVERAGE
|
||||
---help---
|
||||
|
||||
@@ -15,7 +15,9 @@ mac80211-y := \
|
||||
michael.o \
|
||||
tkip.o \
|
||||
aes_ccm.o \
|
||||
aes_gcm.o \
|
||||
aes_cmac.o \
|
||||
aes_gmac.o \
|
||||
cfg.o \
|
||||
ethtool.o \
|
||||
rx.o \
|
||||
|
||||
+12
-9
@@ -20,7 +20,8 @@
|
||||
#include "aes_ccm.h"
|
||||
|
||||
void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
|
||||
u8 *data, size_t data_len, u8 *mic)
|
||||
u8 *data, size_t data_len, u8 *mic,
|
||||
size_t mic_len)
|
||||
{
|
||||
struct scatterlist assoc, pt, ct[2];
|
||||
|
||||
@@ -35,7 +36,7 @@ void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
|
||||
sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad));
|
||||
sg_init_table(ct, 2);
|
||||
sg_set_buf(&ct[0], data, data_len);
|
||||
sg_set_buf(&ct[1], mic, IEEE80211_CCMP_MIC_LEN);
|
||||
sg_set_buf(&ct[1], mic, mic_len);
|
||||
|
||||
aead_request_set_tfm(aead_req, tfm);
|
||||
aead_request_set_assoc(aead_req, &assoc, assoc.length);
|
||||
@@ -45,7 +46,8 @@ void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
|
||||
}
|
||||
|
||||
int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
|
||||
u8 *data, size_t data_len, u8 *mic)
|
||||
u8 *data, size_t data_len, u8 *mic,
|
||||
size_t mic_len)
|
||||
{
|
||||
struct scatterlist assoc, pt, ct[2];
|
||||
char aead_req_data[sizeof(struct aead_request) +
|
||||
@@ -62,17 +64,18 @@ int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
|
||||
sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad));
|
||||
sg_init_table(ct, 2);
|
||||
sg_set_buf(&ct[0], data, data_len);
|
||||
sg_set_buf(&ct[1], mic, IEEE80211_CCMP_MIC_LEN);
|
||||
sg_set_buf(&ct[1], mic, mic_len);
|
||||
|
||||
aead_request_set_tfm(aead_req, tfm);
|
||||
aead_request_set_assoc(aead_req, &assoc, assoc.length);
|
||||
aead_request_set_crypt(aead_req, ct, &pt,
|
||||
data_len + IEEE80211_CCMP_MIC_LEN, b_0);
|
||||
aead_request_set_crypt(aead_req, ct, &pt, data_len + mic_len, b_0);
|
||||
|
||||
return crypto_aead_decrypt(aead_req);
|
||||
}
|
||||
|
||||
struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[])
|
||||
struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[],
|
||||
size_t key_len,
|
||||
size_t mic_len)
|
||||
{
|
||||
struct crypto_aead *tfm;
|
||||
int err;
|
||||
@@ -81,9 +84,9 @@ struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[])
|
||||
if (IS_ERR(tfm))
|
||||
return tfm;
|
||||
|
||||
err = crypto_aead_setkey(tfm, key, WLAN_KEY_LEN_CCMP);
|
||||
err = crypto_aead_setkey(tfm, key, key_len);
|
||||
if (!err)
|
||||
err = crypto_aead_setauthsize(tfm, IEEE80211_CCMP_MIC_LEN);
|
||||
err = crypto_aead_setauthsize(tfm, mic_len);
|
||||
if (!err)
|
||||
return tfm;
|
||||
|
||||
|
||||
@@ -12,11 +12,15 @@
|
||||
|
||||
#include <linux/crypto.h>
|
||||
|
||||
struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[]);
|
||||
struct crypto_aead *ieee80211_aes_key_setup_encrypt(const u8 key[],
|
||||
size_t key_len,
|
||||
size_t mic_len);
|
||||
void ieee80211_aes_ccm_encrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
|
||||
u8 *data, size_t data_len, u8 *mic);
|
||||
u8 *data, size_t data_len, u8 *mic,
|
||||
size_t mic_len);
|
||||
int ieee80211_aes_ccm_decrypt(struct crypto_aead *tfm, u8 *b_0, u8 *aad,
|
||||
u8 *data, size_t data_len, u8 *mic);
|
||||
u8 *data, size_t data_len, u8 *mic,
|
||||
size_t mic_len);
|
||||
void ieee80211_aes_key_free(struct crypto_aead *tfm);
|
||||
|
||||
#endif /* AES_CCM_H */
|
||||
|
||||
+26
-8
@@ -18,8 +18,8 @@
|
||||
#include "key.h"
|
||||
#include "aes_cmac.h"
|
||||
|
||||
#define AES_CMAC_KEY_LEN 16
|
||||
#define CMAC_TLEN 8 /* CMAC TLen = 64 bits (8 octets) */
|
||||
#define CMAC_TLEN_256 16 /* CMAC TLen = 128 bits (16 octets) */
|
||||
#define AAD_LEN 20
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ static void gf_mulx(u8 *pad)
|
||||
pad[AES_BLOCK_SIZE - 1] ^= 0x87;
|
||||
}
|
||||
|
||||
|
||||
static void aes_128_cmac_vector(struct crypto_cipher *tfm, size_t num_elem,
|
||||
const u8 *addr[], const size_t *len, u8 *mac)
|
||||
static void aes_cmac_vector(struct crypto_cipher *tfm, size_t num_elem,
|
||||
const u8 *addr[], const size_t *len, u8 *mac,
|
||||
size_t mac_len)
|
||||
{
|
||||
u8 cbc[AES_BLOCK_SIZE], pad[AES_BLOCK_SIZE];
|
||||
const u8 *pos, *end;
|
||||
@@ -88,7 +88,7 @@ static void aes_128_cmac_vector(struct crypto_cipher *tfm, size_t num_elem,
|
||||
for (i = 0; i < AES_BLOCK_SIZE; i++)
|
||||
pad[i] ^= cbc[i];
|
||||
crypto_cipher_encrypt_one(tfm, pad, pad);
|
||||
memcpy(mac, pad, CMAC_TLEN);
|
||||
memcpy(mac, pad, mac_len);
|
||||
}
|
||||
|
||||
|
||||
@@ -107,17 +107,35 @@ void ieee80211_aes_cmac(struct crypto_cipher *tfm, const u8 *aad,
|
||||
addr[2] = zero;
|
||||
len[2] = CMAC_TLEN;
|
||||
|
||||
aes_128_cmac_vector(tfm, 3, addr, len, mic);
|
||||
aes_cmac_vector(tfm, 3, addr, len, mic, CMAC_TLEN);
|
||||
}
|
||||
|
||||
void ieee80211_aes_cmac_256(struct crypto_cipher *tfm, const u8 *aad,
|
||||
const u8 *data, size_t data_len, u8 *mic)
|
||||
{
|
||||
const u8 *addr[3];
|
||||
size_t len[3];
|
||||
u8 zero[CMAC_TLEN_256];
|
||||
|
||||
struct crypto_cipher *ieee80211_aes_cmac_key_setup(const u8 key[])
|
||||
memset(zero, 0, CMAC_TLEN_256);
|
||||
addr[0] = aad;
|
||||
len[0] = AAD_LEN;
|
||||
addr[1] = data;
|
||||
len[1] = data_len - CMAC_TLEN_256;
|
||||
addr[2] = zero;
|
||||
len[2] = CMAC_TLEN_256;
|
||||
|
||||
aes_cmac_vector(tfm, 3, addr, len, mic, CMAC_TLEN_256);
|
||||
}
|
||||
|
||||
struct crypto_cipher *ieee80211_aes_cmac_key_setup(const u8 key[],
|
||||
size_t key_len)
|
||||
{
|
||||
struct crypto_cipher *tfm;
|
||||
|
||||
tfm = crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
|
||||
if (!IS_ERR(tfm))
|
||||
crypto_cipher_setkey(tfm, key, AES_CMAC_KEY_LEN);
|
||||
crypto_cipher_setkey(tfm, key, key_len);
|
||||
|
||||
return tfm;
|
||||
}
|
||||
|
||||
@@ -11,9 +11,12 @@
|
||||
|
||||
#include <linux/crypto.h>
|
||||
|
||||
struct crypto_cipher *ieee80211_aes_cmac_key_setup(const u8 key[]);
|
||||
struct crypto_cipher *ieee80211_aes_cmac_key_setup(const u8 key[],
|
||||
size_t key_len);
|
||||
void ieee80211_aes_cmac(struct crypto_cipher *tfm, const u8 *aad,
|
||||
const u8 *data, size_t data_len, u8 *mic);
|
||||
void ieee80211_aes_cmac_256(struct crypto_cipher *tfm, const u8 *aad,
|
||||
const u8 *data, size_t data_len, u8 *mic);
|
||||
void ieee80211_aes_cmac_key_free(struct crypto_cipher *tfm);
|
||||
|
||||
#endif /* AES_CMAC_H */
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2014-2015, Qualcomm Atheros, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/err.h>
|
||||
#include <crypto/aes.h>
|
||||
|
||||
#include <net/mac80211.h>
|
||||
#include "key.h"
|
||||
#include "aes_gcm.h"
|
||||
|
||||
void ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
|
||||
u8 *data, size_t data_len, u8 *mic)
|
||||
{
|
||||
struct scatterlist assoc, pt, ct[2];
|
||||
|
||||
char aead_req_data[sizeof(struct aead_request) +
|
||||
crypto_aead_reqsize(tfm)]
|
||||
__aligned(__alignof__(struct aead_request));
|
||||
struct aead_request *aead_req = (void *)aead_req_data;
|
||||
|
||||
memset(aead_req, 0, sizeof(aead_req_data));
|
||||
|
||||
sg_init_one(&pt, data, data_len);
|
||||
sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad));
|
||||
sg_init_table(ct, 2);
|
||||
sg_set_buf(&ct[0], data, data_len);
|
||||
sg_set_buf(&ct[1], mic, IEEE80211_GCMP_MIC_LEN);
|
||||
|
||||
aead_request_set_tfm(aead_req, tfm);
|
||||
aead_request_set_assoc(aead_req, &assoc, assoc.length);
|
||||
aead_request_set_crypt(aead_req, &pt, ct, data_len, j_0);
|
||||
|
||||
crypto_aead_encrypt(aead_req);
|
||||
}
|
||||
|
||||
int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
|
||||
u8 *data, size_t data_len, u8 *mic)
|
||||
{
|
||||
struct scatterlist assoc, pt, ct[2];
|
||||
char aead_req_data[sizeof(struct aead_request) +
|
||||
crypto_aead_reqsize(tfm)]
|
||||
__aligned(__alignof__(struct aead_request));
|
||||
struct aead_request *aead_req = (void *)aead_req_data;
|
||||
|
||||
if (data_len == 0)
|
||||
return -EINVAL;
|
||||
|
||||
memset(aead_req, 0, sizeof(aead_req_data));
|
||||
|
||||
sg_init_one(&pt, data, data_len);
|
||||
sg_init_one(&assoc, &aad[2], be16_to_cpup((__be16 *)aad));
|
||||
sg_init_table(ct, 2);
|
||||
sg_set_buf(&ct[0], data, data_len);
|
||||
sg_set_buf(&ct[1], mic, IEEE80211_GCMP_MIC_LEN);
|
||||
|
||||
aead_request_set_tfm(aead_req, tfm);
|
||||
aead_request_set_assoc(aead_req, &assoc, assoc.length);
|
||||
aead_request_set_crypt(aead_req, ct, &pt,
|
||||
data_len + IEEE80211_GCMP_MIC_LEN, j_0);
|
||||
|
||||
return crypto_aead_decrypt(aead_req);
|
||||
}
|
||||
|
||||
struct crypto_aead *ieee80211_aes_gcm_key_setup_encrypt(const u8 key[],
|
||||
size_t key_len)
|
||||
{
|
||||
struct crypto_aead *tfm;
|
||||
int err;
|
||||
|
||||
tfm = crypto_alloc_aead("gcm(aes)", 0, CRYPTO_ALG_ASYNC);
|
||||
if (IS_ERR(tfm))
|
||||
return tfm;
|
||||
|
||||
err = crypto_aead_setkey(tfm, key, key_len);
|
||||
if (!err)
|
||||
err = crypto_aead_setauthsize(tfm, IEEE80211_GCMP_MIC_LEN);
|
||||
if (!err)
|
||||
return tfm;
|
||||
|
||||
crypto_free_aead(tfm);
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
void ieee80211_aes_gcm_key_free(struct crypto_aead *tfm)
|
||||
{
|
||||
crypto_free_aead(tfm);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2014-2015, Qualcomm Atheros, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef AES_GCM_H
|
||||
#define AES_GCM_H
|
||||
|
||||
#include <linux/crypto.h>
|
||||
|
||||
void ieee80211_aes_gcm_encrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
|
||||
u8 *data, size_t data_len, u8 *mic);
|
||||
int ieee80211_aes_gcm_decrypt(struct crypto_aead *tfm, u8 *j_0, u8 *aad,
|
||||
u8 *data, size_t data_len, u8 *mic);
|
||||
struct crypto_aead *ieee80211_aes_gcm_key_setup_encrypt(const u8 key[],
|
||||
size_t key_len);
|
||||
void ieee80211_aes_gcm_key_free(struct crypto_aead *tfm);
|
||||
|
||||
#endif /* AES_GCM_H */
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* AES-GMAC for IEEE 802.11 BIP-GMAC-128 and BIP-GMAC-256
|
||||
* Copyright 2015, Qualcomm Atheros, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/crypto.h>
|
||||
#include <linux/err.h>
|
||||
#include <crypto/aes.h>
|
||||
|
||||
#include <net/mac80211.h>
|
||||
#include "key.h"
|
||||
#include "aes_gmac.h"
|
||||
|
||||
#define GMAC_MIC_LEN 16
|
||||
#define GMAC_NONCE_LEN 12
|
||||
#define AAD_LEN 20
|
||||
|
||||
int ieee80211_aes_gmac(struct crypto_aead *tfm, const u8 *aad, u8 *nonce,
|
||||
const u8 *data, size_t data_len, u8 *mic)
|
||||
{
|
||||
struct scatterlist sg[3], ct[1];
|
||||
char aead_req_data[sizeof(struct aead_request) +
|
||||
crypto_aead_reqsize(tfm)]
|
||||
__aligned(__alignof__(struct aead_request));
|
||||
struct aead_request *aead_req = (void *)aead_req_data;
|
||||
u8 zero[GMAC_MIC_LEN], iv[AES_BLOCK_SIZE];
|
||||
|
||||
if (data_len < GMAC_MIC_LEN)
|
||||
return -EINVAL;
|
||||
|
||||
memset(aead_req, 0, sizeof(aead_req_data));
|
||||
|
||||
memset(zero, 0, GMAC_MIC_LEN);
|
||||
sg_init_table(sg, 3);
|
||||
sg_set_buf(&sg[0], aad, AAD_LEN);
|
||||
sg_set_buf(&sg[1], data, data_len - GMAC_MIC_LEN);
|
||||
sg_set_buf(&sg[2], zero, GMAC_MIC_LEN);
|
||||
|
||||
memcpy(iv, nonce, GMAC_NONCE_LEN);
|
||||
memset(iv + GMAC_NONCE_LEN, 0, sizeof(iv) - GMAC_NONCE_LEN);
|
||||
iv[AES_BLOCK_SIZE - 1] = 0x01;
|
||||
|
||||
sg_init_table(ct, 1);
|
||||
sg_set_buf(&ct[0], mic, GMAC_MIC_LEN);
|
||||
|
||||
aead_request_set_tfm(aead_req, tfm);
|
||||
aead_request_set_assoc(aead_req, sg, AAD_LEN + data_len);
|
||||
aead_request_set_crypt(aead_req, NULL, ct, 0, iv);
|
||||
|
||||
crypto_aead_encrypt(aead_req);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct crypto_aead *ieee80211_aes_gmac_key_setup(const u8 key[],
|
||||
size_t key_len)
|
||||
{
|
||||
struct crypto_aead *tfm;
|
||||
int err;
|
||||
|
||||
tfm = crypto_alloc_aead("gcm(aes)", 0, CRYPTO_ALG_ASYNC);
|
||||
if (IS_ERR(tfm))
|
||||
return tfm;
|
||||
|
||||
err = crypto_aead_setkey(tfm, key, key_len);
|
||||
if (!err)
|
||||
return tfm;
|
||||
if (!err)
|
||||
err = crypto_aead_setauthsize(tfm, GMAC_MIC_LEN);
|
||||
|
||||
crypto_free_aead(tfm);
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
void ieee80211_aes_gmac_key_free(struct crypto_aead *tfm)
|
||||
{
|
||||
crypto_free_aead(tfm);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2015, Qualcomm Atheros, Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#ifndef AES_GMAC_H
|
||||
#define AES_GMAC_H
|
||||
|
||||
#include <linux/crypto.h>
|
||||
|
||||
struct crypto_aead *ieee80211_aes_gmac_key_setup(const u8 key[],
|
||||
size_t key_len);
|
||||
int ieee80211_aes_gmac(struct crypto_aead *tfm, const u8 *aad, u8 *nonce,
|
||||
const u8 *data, size_t data_len, u8 *mic);
|
||||
void ieee80211_aes_gmac_key_free(struct crypto_aead *tfm);
|
||||
|
||||
#endif /* AES_GMAC_H */
|
||||
+47
-3
@@ -162,8 +162,13 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
return -EINVAL;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
case WLAN_CIPHER_SUITE_CCMP_256:
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
case WLAN_CIPHER_SUITE_BIP_CMAC_256:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
|
||||
case WLAN_CIPHER_SUITE_GCMP:
|
||||
case WLAN_CIPHER_SUITE_GCMP_256:
|
||||
break;
|
||||
default:
|
||||
cs = ieee80211_cs_get(local, params->cipher, sdata->vif.type);
|
||||
@@ -348,6 +353,7 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
params.seq_len = 6;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
case WLAN_CIPHER_SUITE_CCMP_256:
|
||||
pn64 = atomic64_read(&key->u.ccmp.tx_pn);
|
||||
seq[0] = pn64;
|
||||
seq[1] = pn64 >> 8;
|
||||
@@ -359,6 +365,7 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
params.seq_len = 6;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
case WLAN_CIPHER_SUITE_BIP_CMAC_256:
|
||||
pn64 = atomic64_read(&key->u.aes_cmac.tx_pn);
|
||||
seq[0] = pn64;
|
||||
seq[1] = pn64 >> 8;
|
||||
@@ -369,6 +376,30 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
params.seq = seq;
|
||||
params.seq_len = 6;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
|
||||
pn64 = atomic64_read(&key->u.aes_gmac.tx_pn);
|
||||
seq[0] = pn64;
|
||||
seq[1] = pn64 >> 8;
|
||||
seq[2] = pn64 >> 16;
|
||||
seq[3] = pn64 >> 24;
|
||||
seq[4] = pn64 >> 32;
|
||||
seq[5] = pn64 >> 40;
|
||||
params.seq = seq;
|
||||
params.seq_len = 6;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_GCMP:
|
||||
case WLAN_CIPHER_SUITE_GCMP_256:
|
||||
pn64 = atomic64_read(&key->u.gcmp.tx_pn);
|
||||
seq[0] = pn64;
|
||||
seq[1] = pn64 >> 8;
|
||||
seq[2] = pn64 >> 16;
|
||||
seq[3] = pn64 >> 24;
|
||||
seq[4] = pn64 >> 32;
|
||||
seq[5] = pn64 >> 40;
|
||||
params.seq = seq;
|
||||
params.seq_len = 6;
|
||||
break;
|
||||
}
|
||||
|
||||
params.key = key->conf.key;
|
||||
@@ -2110,6 +2141,8 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
|
||||
{
|
||||
struct ieee80211_local *local = wiphy_priv(wiphy);
|
||||
struct ieee80211_sub_if_data *sdata;
|
||||
enum nl80211_tx_power_setting txp_type = type;
|
||||
bool update_txp_type = false;
|
||||
|
||||
if (wdev) {
|
||||
sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
|
||||
@@ -2117,6 +2150,7 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
|
||||
switch (type) {
|
||||
case NL80211_TX_POWER_AUTOMATIC:
|
||||
sdata->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
|
||||
txp_type = NL80211_TX_POWER_LIMITED;
|
||||
break;
|
||||
case NL80211_TX_POWER_LIMITED:
|
||||
case NL80211_TX_POWER_FIXED:
|
||||
@@ -2126,7 +2160,12 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
|
||||
break;
|
||||
}
|
||||
|
||||
ieee80211_recalc_txpower(sdata);
|
||||
if (txp_type != sdata->vif.bss_conf.txpower_type) {
|
||||
update_txp_type = true;
|
||||
sdata->vif.bss_conf.txpower_type = txp_type;
|
||||
}
|
||||
|
||||
ieee80211_recalc_txpower(sdata, update_txp_type);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2134,6 +2173,7 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
|
||||
switch (type) {
|
||||
case NL80211_TX_POWER_AUTOMATIC:
|
||||
local->user_power_level = IEEE80211_UNSET_POWER_LEVEL;
|
||||
txp_type = NL80211_TX_POWER_LIMITED;
|
||||
break;
|
||||
case NL80211_TX_POWER_LIMITED:
|
||||
case NL80211_TX_POWER_FIXED:
|
||||
@@ -2144,10 +2184,14 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy,
|
||||
}
|
||||
|
||||
mutex_lock(&local->iflist_mtx);
|
||||
list_for_each_entry(sdata, &local->interfaces, list)
|
||||
list_for_each_entry(sdata, &local->interfaces, list) {
|
||||
sdata->user_power_level = local->user_power_level;
|
||||
if (txp_type != sdata->vif.bss_conf.txpower_type)
|
||||
update_txp_type = true;
|
||||
sdata->vif.bss_conf.txpower_type = txp_type;
|
||||
}
|
||||
list_for_each_entry(sdata, &local->interfaces, list)
|
||||
ieee80211_recalc_txpower(sdata);
|
||||
ieee80211_recalc_txpower(sdata, update_txp_type);
|
||||
mutex_unlock(&local->iflist_mtx);
|
||||
|
||||
return 0;
|
||||
|
||||
+2
-2
@@ -655,7 +655,7 @@ out:
|
||||
}
|
||||
|
||||
if (new_ctx && ieee80211_chanctx_num_assigned(local, new_ctx) > 0) {
|
||||
ieee80211_recalc_txpower(sdata);
|
||||
ieee80211_recalc_txpower(sdata, false);
|
||||
ieee80211_recalc_chanctx_min_def(local, new_ctx);
|
||||
}
|
||||
|
||||
@@ -1387,7 +1387,7 @@ static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local)
|
||||
ieee80211_bss_info_change_notify(sdata,
|
||||
changed);
|
||||
|
||||
ieee80211_recalc_txpower(sdata);
|
||||
ieee80211_recalc_txpower(sdata, false);
|
||||
}
|
||||
|
||||
ieee80211_recalc_chanctx_chantype(local, ctx);
|
||||
|
||||
@@ -94,17 +94,33 @@ static ssize_t key_tx_spec_read(struct file *file, char __user *userbuf,
|
||||
key->u.tkip.tx.iv16);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
case WLAN_CIPHER_SUITE_CCMP_256:
|
||||
pn = atomic64_read(&key->u.ccmp.tx_pn);
|
||||
len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n",
|
||||
(u8)(pn >> 40), (u8)(pn >> 32), (u8)(pn >> 24),
|
||||
(u8)(pn >> 16), (u8)(pn >> 8), (u8)pn);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
case WLAN_CIPHER_SUITE_BIP_CMAC_256:
|
||||
pn = atomic64_read(&key->u.aes_cmac.tx_pn);
|
||||
len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n",
|
||||
(u8)(pn >> 40), (u8)(pn >> 32), (u8)(pn >> 24),
|
||||
(u8)(pn >> 16), (u8)(pn >> 8), (u8)pn);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
|
||||
pn = atomic64_read(&key->u.aes_gmac.tx_pn);
|
||||
len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n",
|
||||
(u8)(pn >> 40), (u8)(pn >> 32), (u8)(pn >> 24),
|
||||
(u8)(pn >> 16), (u8)(pn >> 8), (u8)pn);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_GCMP:
|
||||
case WLAN_CIPHER_SUITE_GCMP_256:
|
||||
pn = atomic64_read(&key->u.gcmp.tx_pn);
|
||||
len = scnprintf(buf, sizeof(buf), "%02x%02x%02x%02x%02x%02x\n",
|
||||
(u8)(pn >> 40), (u8)(pn >> 32), (u8)(pn >> 24),
|
||||
(u8)(pn >> 16), (u8)(pn >> 8), (u8)pn);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -134,6 +150,7 @@ static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
|
||||
len = p - buf;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
case WLAN_CIPHER_SUITE_CCMP_256:
|
||||
for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) {
|
||||
rpn = key->u.ccmp.rx_pn[i];
|
||||
p += scnprintf(p, sizeof(buf)+buf-p,
|
||||
@@ -144,6 +161,7 @@ static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
|
||||
len = p - buf;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
case WLAN_CIPHER_SUITE_BIP_CMAC_256:
|
||||
rpn = key->u.aes_cmac.rx_pn;
|
||||
p += scnprintf(p, sizeof(buf)+buf-p,
|
||||
"%02x%02x%02x%02x%02x%02x\n",
|
||||
@@ -151,6 +169,26 @@ static ssize_t key_rx_spec_read(struct file *file, char __user *userbuf,
|
||||
rpn[3], rpn[4], rpn[5]);
|
||||
len = p - buf;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
|
||||
rpn = key->u.aes_gmac.rx_pn;
|
||||
p += scnprintf(p, sizeof(buf)+buf-p,
|
||||
"%02x%02x%02x%02x%02x%02x\n",
|
||||
rpn[0], rpn[1], rpn[2],
|
||||
rpn[3], rpn[4], rpn[5]);
|
||||
len = p - buf;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_GCMP:
|
||||
case WLAN_CIPHER_SUITE_GCMP_256:
|
||||
for (i = 0; i < IEEE80211_NUM_TIDS + 1; i++) {
|
||||
rpn = key->u.gcmp.rx_pn[i];
|
||||
p += scnprintf(p, sizeof(buf)+buf-p,
|
||||
"%02x%02x%02x%02x%02x%02x\n",
|
||||
rpn[0], rpn[1], rpn[2],
|
||||
rpn[3], rpn[4], rpn[5]);
|
||||
}
|
||||
len = p - buf;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -167,12 +205,23 @@ static ssize_t key_replays_read(struct file *file, char __user *userbuf,
|
||||
|
||||
switch (key->conf.cipher) {
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
case WLAN_CIPHER_SUITE_CCMP_256:
|
||||
len = scnprintf(buf, sizeof(buf), "%u\n", key->u.ccmp.replays);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
case WLAN_CIPHER_SUITE_BIP_CMAC_256:
|
||||
len = scnprintf(buf, sizeof(buf), "%u\n",
|
||||
key->u.aes_cmac.replays);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
|
||||
len = scnprintf(buf, sizeof(buf), "%u\n",
|
||||
key->u.aes_gmac.replays);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_GCMP:
|
||||
case WLAN_CIPHER_SUITE_GCMP_256:
|
||||
len = scnprintf(buf, sizeof(buf), "%u\n", key->u.gcmp.replays);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -189,9 +238,15 @@ static ssize_t key_icverrors_read(struct file *file, char __user *userbuf,
|
||||
|
||||
switch (key->conf.cipher) {
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
case WLAN_CIPHER_SUITE_BIP_CMAC_256:
|
||||
len = scnprintf(buf, sizeof(buf), "%u\n",
|
||||
key->u.aes_cmac.icverrors);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
|
||||
len = scnprintf(buf, sizeof(buf), "%u\n",
|
||||
key->u.aes_gmac.icverrors);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1621,7 +1621,8 @@ int ieee80211_add_virtual_monitor(struct ieee80211_local *local);
|
||||
void ieee80211_del_virtual_monitor(struct ieee80211_local *local);
|
||||
|
||||
bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
|
||||
void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata);
|
||||
void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata,
|
||||
bool update_bss);
|
||||
|
||||
static inline bool ieee80211_sdata_running(struct ieee80211_sub_if_data *sdata)
|
||||
{
|
||||
@@ -1751,7 +1752,8 @@ static inline int __ieee80211_resume(struct ieee80211_hw *hw)
|
||||
{
|
||||
struct ieee80211_local *local = hw_to_local(hw);
|
||||
|
||||
WARN(test_bit(SCAN_HW_SCANNING, &local->scanning),
|
||||
WARN(test_bit(SCAN_HW_SCANNING, &local->scanning) &&
|
||||
!test_bit(SCAN_COMPLETED, &local->scanning),
|
||||
"%s: resume with hardware scan still in progress\n",
|
||||
wiphy_name(hw->wiphy));
|
||||
|
||||
@@ -1885,6 +1887,36 @@ void __ieee80211_flush_queues(struct ieee80211_local *local,
|
||||
struct ieee80211_sub_if_data *sdata,
|
||||
unsigned int queues, bool drop);
|
||||
|
||||
static inline bool ieee80211_can_run_worker(struct ieee80211_local *local)
|
||||
{
|
||||
/*
|
||||
* If quiescing is set, we are racing with __ieee80211_suspend.
|
||||
* __ieee80211_suspend flushes the workers after setting quiescing,
|
||||
* and we check quiescing / suspended before enqueing new workers.
|
||||
* We should abort the worker to avoid the races below.
|
||||
*/
|
||||
if (local->quiescing)
|
||||
return false;
|
||||
|
||||
/*
|
||||
* We might already be suspended if the following scenario occurs:
|
||||
* __ieee80211_suspend Control path
|
||||
*
|
||||
* if (local->quiescing)
|
||||
* return;
|
||||
* local->quiescing = true;
|
||||
* flush_workqueue();
|
||||
* queue_work(...);
|
||||
* local->suspended = true;
|
||||
* local->quiescing = false;
|
||||
* worker starts running...
|
||||
*/
|
||||
if (local->suspended)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
|
||||
u16 transaction, u16 auth_alg, u16 status,
|
||||
const u8 *extra, size_t extra_len, const u8 *bssid,
|
||||
|
||||
@@ -73,9 +73,10 @@ bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata)
|
||||
return false;
|
||||
}
|
||||
|
||||
void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata)
|
||||
void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata,
|
||||
bool update_bss)
|
||||
{
|
||||
if (__ieee80211_recalc_txpower(sdata))
|
||||
if (__ieee80211_recalc_txpower(sdata) || update_bss)
|
||||
ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_TXPOWER);
|
||||
}
|
||||
|
||||
@@ -1169,12 +1170,7 @@ static void ieee80211_iface_work(struct work_struct *work)
|
||||
if (local->scanning)
|
||||
return;
|
||||
|
||||
/*
|
||||
* ieee80211_queue_work() should have picked up most cases,
|
||||
* here we'll pick the rest.
|
||||
*/
|
||||
if (WARN(local->suspended,
|
||||
"interface work scheduled while going to suspend\n"))
|
||||
if (!ieee80211_can_run_worker(local))
|
||||
return;
|
||||
|
||||
/* first process frames */
|
||||
|
||||
+177
-8
@@ -24,6 +24,8 @@
|
||||
#include "debugfs_key.h"
|
||||
#include "aes_ccm.h"
|
||||
#include "aes_cmac.h"
|
||||
#include "aes_gmac.h"
|
||||
#include "aes_gcm.h"
|
||||
|
||||
|
||||
/**
|
||||
@@ -90,7 +92,7 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
|
||||
{
|
||||
struct ieee80211_sub_if_data *sdata;
|
||||
struct sta_info *sta;
|
||||
int ret;
|
||||
int ret = -EOPNOTSUPP;
|
||||
|
||||
might_sleep();
|
||||
|
||||
@@ -150,7 +152,7 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ret != -ENOSPC && ret != -EOPNOTSUPP)
|
||||
if (ret != -ENOSPC && ret != -EOPNOTSUPP && ret != 1)
|
||||
sdata_err(sdata,
|
||||
"failed to set key (%d, %pM) to hardware (%d)\n",
|
||||
key->conf.keyidx,
|
||||
@@ -162,8 +164,18 @@ static int ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
|
||||
case WLAN_CIPHER_SUITE_WEP104:
|
||||
case WLAN_CIPHER_SUITE_TKIP:
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
case WLAN_CIPHER_SUITE_CCMP_256:
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
/* all of these we can do in software */
|
||||
case WLAN_CIPHER_SUITE_BIP_CMAC_256:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
|
||||
case WLAN_CIPHER_SUITE_GCMP:
|
||||
case WLAN_CIPHER_SUITE_GCMP_256:
|
||||
/* all of these we can do in software - if driver can */
|
||||
if (ret == 1)
|
||||
return 0;
|
||||
if (key->local->hw.flags & IEEE80211_HW_SW_CRYPTO_CONTROL)
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
default:
|
||||
return -EINVAL;
|
||||
@@ -382,7 +394,26 @@ ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
|
||||
* Initialize AES key state here as an optimization so that
|
||||
* it does not need to be initialized for every packet.
|
||||
*/
|
||||
key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt(key_data);
|
||||
key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt(
|
||||
key_data, key_len, IEEE80211_CCMP_MIC_LEN);
|
||||
if (IS_ERR(key->u.ccmp.tfm)) {
|
||||
err = PTR_ERR(key->u.ccmp.tfm);
|
||||
kfree(key);
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_CCMP_256:
|
||||
key->conf.iv_len = IEEE80211_CCMP_256_HDR_LEN;
|
||||
key->conf.icv_len = IEEE80211_CCMP_256_MIC_LEN;
|
||||
for (i = 0; seq && i < IEEE80211_NUM_TIDS + 1; i++)
|
||||
for (j = 0; j < IEEE80211_CCMP_256_PN_LEN; j++)
|
||||
key->u.ccmp.rx_pn[i][j] =
|
||||
seq[IEEE80211_CCMP_256_PN_LEN - j - 1];
|
||||
/* Initialize AES key state here as an optimization so that
|
||||
* it does not need to be initialized for every packet.
|
||||
*/
|
||||
key->u.ccmp.tfm = ieee80211_aes_key_setup_encrypt(
|
||||
key_data, key_len, IEEE80211_CCMP_256_MIC_LEN);
|
||||
if (IS_ERR(key->u.ccmp.tfm)) {
|
||||
err = PTR_ERR(key->u.ccmp.tfm);
|
||||
kfree(key);
|
||||
@@ -390,8 +421,12 @@ ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
|
||||
}
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
case WLAN_CIPHER_SUITE_BIP_CMAC_256:
|
||||
key->conf.iv_len = 0;
|
||||
key->conf.icv_len = sizeof(struct ieee80211_mmie);
|
||||
if (cipher == WLAN_CIPHER_SUITE_AES_CMAC)
|
||||
key->conf.icv_len = sizeof(struct ieee80211_mmie);
|
||||
else
|
||||
key->conf.icv_len = sizeof(struct ieee80211_mmie_16);
|
||||
if (seq)
|
||||
for (j = 0; j < IEEE80211_CMAC_PN_LEN; j++)
|
||||
key->u.aes_cmac.rx_pn[j] =
|
||||
@@ -401,13 +436,51 @@ ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
|
||||
* it does not need to be initialized for every packet.
|
||||
*/
|
||||
key->u.aes_cmac.tfm =
|
||||
ieee80211_aes_cmac_key_setup(key_data);
|
||||
ieee80211_aes_cmac_key_setup(key_data, key_len);
|
||||
if (IS_ERR(key->u.aes_cmac.tfm)) {
|
||||
err = PTR_ERR(key->u.aes_cmac.tfm);
|
||||
kfree(key);
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
|
||||
key->conf.iv_len = 0;
|
||||
key->conf.icv_len = sizeof(struct ieee80211_mmie_16);
|
||||
if (seq)
|
||||
for (j = 0; j < IEEE80211_GMAC_PN_LEN; j++)
|
||||
key->u.aes_gmac.rx_pn[j] =
|
||||
seq[IEEE80211_GMAC_PN_LEN - j - 1];
|
||||
/* Initialize AES key state here as an optimization so that
|
||||
* it does not need to be initialized for every packet.
|
||||
*/
|
||||
key->u.aes_gmac.tfm =
|
||||
ieee80211_aes_gmac_key_setup(key_data, key_len);
|
||||
if (IS_ERR(key->u.aes_gmac.tfm)) {
|
||||
err = PTR_ERR(key->u.aes_gmac.tfm);
|
||||
kfree(key);
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_GCMP:
|
||||
case WLAN_CIPHER_SUITE_GCMP_256:
|
||||
key->conf.iv_len = IEEE80211_GCMP_HDR_LEN;
|
||||
key->conf.icv_len = IEEE80211_GCMP_MIC_LEN;
|
||||
for (i = 0; seq && i < IEEE80211_NUM_TIDS + 1; i++)
|
||||
for (j = 0; j < IEEE80211_GCMP_PN_LEN; j++)
|
||||
key->u.gcmp.rx_pn[i][j] =
|
||||
seq[IEEE80211_GCMP_PN_LEN - j - 1];
|
||||
/* Initialize AES key state here as an optimization so that
|
||||
* it does not need to be initialized for every packet.
|
||||
*/
|
||||
key->u.gcmp.tfm = ieee80211_aes_gcm_key_setup_encrypt(key_data,
|
||||
key_len);
|
||||
if (IS_ERR(key->u.gcmp.tfm)) {
|
||||
err = PTR_ERR(key->u.gcmp.tfm);
|
||||
kfree(key);
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (cs) {
|
||||
size_t len = (seq_len > MAX_PN_LEN) ?
|
||||
@@ -429,10 +502,24 @@ ieee80211_key_alloc(u32 cipher, int idx, size_t key_len,
|
||||
|
||||
static void ieee80211_key_free_common(struct ieee80211_key *key)
|
||||
{
|
||||
if (key->conf.cipher == WLAN_CIPHER_SUITE_CCMP)
|
||||
switch (key->conf.cipher) {
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
case WLAN_CIPHER_SUITE_CCMP_256:
|
||||
ieee80211_aes_key_free(key->u.ccmp.tfm);
|
||||
if (key->conf.cipher == WLAN_CIPHER_SUITE_AES_CMAC)
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
case WLAN_CIPHER_SUITE_BIP_CMAC_256:
|
||||
ieee80211_aes_cmac_key_free(key->u.aes_cmac.tfm);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
|
||||
ieee80211_aes_gmac_key_free(key->u.aes_gmac.tfm);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_GCMP:
|
||||
case WLAN_CIPHER_SUITE_GCMP_256:
|
||||
ieee80211_aes_gcm_key_free(key->u.gcmp.tfm);
|
||||
break;
|
||||
}
|
||||
kzfree(key);
|
||||
}
|
||||
|
||||
@@ -739,6 +826,7 @@ void ieee80211_get_key_tx_seq(struct ieee80211_key_conf *keyconf,
|
||||
seq->tkip.iv16 = key->u.tkip.tx.iv16;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
case WLAN_CIPHER_SUITE_CCMP_256:
|
||||
pn64 = atomic64_read(&key->u.ccmp.tx_pn);
|
||||
seq->ccmp.pn[5] = pn64;
|
||||
seq->ccmp.pn[4] = pn64 >> 8;
|
||||
@@ -748,6 +836,7 @@ void ieee80211_get_key_tx_seq(struct ieee80211_key_conf *keyconf,
|
||||
seq->ccmp.pn[0] = pn64 >> 40;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
case WLAN_CIPHER_SUITE_BIP_CMAC_256:
|
||||
pn64 = atomic64_read(&key->u.aes_cmac.tx_pn);
|
||||
seq->ccmp.pn[5] = pn64;
|
||||
seq->ccmp.pn[4] = pn64 >> 8;
|
||||
@@ -756,6 +845,26 @@ void ieee80211_get_key_tx_seq(struct ieee80211_key_conf *keyconf,
|
||||
seq->ccmp.pn[1] = pn64 >> 32;
|
||||
seq->ccmp.pn[0] = pn64 >> 40;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
|
||||
pn64 = atomic64_read(&key->u.aes_gmac.tx_pn);
|
||||
seq->ccmp.pn[5] = pn64;
|
||||
seq->ccmp.pn[4] = pn64 >> 8;
|
||||
seq->ccmp.pn[3] = pn64 >> 16;
|
||||
seq->ccmp.pn[2] = pn64 >> 24;
|
||||
seq->ccmp.pn[1] = pn64 >> 32;
|
||||
seq->ccmp.pn[0] = pn64 >> 40;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_GCMP:
|
||||
case WLAN_CIPHER_SUITE_GCMP_256:
|
||||
pn64 = atomic64_read(&key->u.gcmp.tx_pn);
|
||||
seq->gcmp.pn[5] = pn64;
|
||||
seq->gcmp.pn[4] = pn64 >> 8;
|
||||
seq->gcmp.pn[3] = pn64 >> 16;
|
||||
seq->gcmp.pn[2] = pn64 >> 24;
|
||||
seq->gcmp.pn[1] = pn64 >> 32;
|
||||
seq->gcmp.pn[0] = pn64 >> 40;
|
||||
break;
|
||||
default:
|
||||
WARN_ON(1);
|
||||
}
|
||||
@@ -778,6 +887,7 @@ void ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf,
|
||||
seq->tkip.iv16 = key->u.tkip.rx[tid].iv16;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
case WLAN_CIPHER_SUITE_CCMP_256:
|
||||
if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS))
|
||||
return;
|
||||
if (tid < 0)
|
||||
@@ -787,11 +897,29 @@ void ieee80211_get_key_rx_seq(struct ieee80211_key_conf *keyconf,
|
||||
memcpy(seq->ccmp.pn, pn, IEEE80211_CCMP_PN_LEN);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
case WLAN_CIPHER_SUITE_BIP_CMAC_256:
|
||||
if (WARN_ON(tid != 0))
|
||||
return;
|
||||
pn = key->u.aes_cmac.rx_pn;
|
||||
memcpy(seq->aes_cmac.pn, pn, IEEE80211_CMAC_PN_LEN);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
|
||||
if (WARN_ON(tid != 0))
|
||||
return;
|
||||
pn = key->u.aes_gmac.rx_pn;
|
||||
memcpy(seq->aes_gmac.pn, pn, IEEE80211_GMAC_PN_LEN);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_GCMP:
|
||||
case WLAN_CIPHER_SUITE_GCMP_256:
|
||||
if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS))
|
||||
return;
|
||||
if (tid < 0)
|
||||
pn = key->u.gcmp.rx_pn[IEEE80211_NUM_TIDS];
|
||||
else
|
||||
pn = key->u.gcmp.rx_pn[tid];
|
||||
memcpy(seq->gcmp.pn, pn, IEEE80211_GCMP_PN_LEN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(ieee80211_get_key_rx_seq);
|
||||
@@ -810,6 +938,7 @@ void ieee80211_set_key_tx_seq(struct ieee80211_key_conf *keyconf,
|
||||
key->u.tkip.tx.iv16 = seq->tkip.iv16;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
case WLAN_CIPHER_SUITE_CCMP_256:
|
||||
pn64 = (u64)seq->ccmp.pn[5] |
|
||||
((u64)seq->ccmp.pn[4] << 8) |
|
||||
((u64)seq->ccmp.pn[3] << 16) |
|
||||
@@ -819,6 +948,7 @@ void ieee80211_set_key_tx_seq(struct ieee80211_key_conf *keyconf,
|
||||
atomic64_set(&key->u.ccmp.tx_pn, pn64);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
case WLAN_CIPHER_SUITE_BIP_CMAC_256:
|
||||
pn64 = (u64)seq->aes_cmac.pn[5] |
|
||||
((u64)seq->aes_cmac.pn[4] << 8) |
|
||||
((u64)seq->aes_cmac.pn[3] << 16) |
|
||||
@@ -827,6 +957,26 @@ void ieee80211_set_key_tx_seq(struct ieee80211_key_conf *keyconf,
|
||||
((u64)seq->aes_cmac.pn[0] << 40);
|
||||
atomic64_set(&key->u.aes_cmac.tx_pn, pn64);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
|
||||
pn64 = (u64)seq->aes_gmac.pn[5] |
|
||||
((u64)seq->aes_gmac.pn[4] << 8) |
|
||||
((u64)seq->aes_gmac.pn[3] << 16) |
|
||||
((u64)seq->aes_gmac.pn[2] << 24) |
|
||||
((u64)seq->aes_gmac.pn[1] << 32) |
|
||||
((u64)seq->aes_gmac.pn[0] << 40);
|
||||
atomic64_set(&key->u.aes_gmac.tx_pn, pn64);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_GCMP:
|
||||
case WLAN_CIPHER_SUITE_GCMP_256:
|
||||
pn64 = (u64)seq->gcmp.pn[5] |
|
||||
((u64)seq->gcmp.pn[4] << 8) |
|
||||
((u64)seq->gcmp.pn[3] << 16) |
|
||||
((u64)seq->gcmp.pn[2] << 24) |
|
||||
((u64)seq->gcmp.pn[1] << 32) |
|
||||
((u64)seq->gcmp.pn[0] << 40);
|
||||
atomic64_set(&key->u.gcmp.tx_pn, pn64);
|
||||
break;
|
||||
default:
|
||||
WARN_ON(1);
|
||||
break;
|
||||
@@ -850,6 +1000,7 @@ void ieee80211_set_key_rx_seq(struct ieee80211_key_conf *keyconf,
|
||||
key->u.tkip.rx[tid].iv16 = seq->tkip.iv16;
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_CCMP:
|
||||
case WLAN_CIPHER_SUITE_CCMP_256:
|
||||
if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS))
|
||||
return;
|
||||
if (tid < 0)
|
||||
@@ -859,11 +1010,29 @@ void ieee80211_set_key_rx_seq(struct ieee80211_key_conf *keyconf,
|
||||
memcpy(pn, seq->ccmp.pn, IEEE80211_CCMP_PN_LEN);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_AES_CMAC:
|
||||
case WLAN_CIPHER_SUITE_BIP_CMAC_256:
|
||||
if (WARN_ON(tid != 0))
|
||||
return;
|
||||
pn = key->u.aes_cmac.rx_pn;
|
||||
memcpy(pn, seq->aes_cmac.pn, IEEE80211_CMAC_PN_LEN);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_128:
|
||||
case WLAN_CIPHER_SUITE_BIP_GMAC_256:
|
||||
if (WARN_ON(tid != 0))
|
||||
return;
|
||||
pn = key->u.aes_gmac.rx_pn;
|
||||
memcpy(pn, seq->aes_gmac.pn, IEEE80211_GMAC_PN_LEN);
|
||||
break;
|
||||
case WLAN_CIPHER_SUITE_GCMP:
|
||||
case WLAN_CIPHER_SUITE_GCMP_256:
|
||||
if (WARN_ON(tid < -1 || tid >= IEEE80211_NUM_TIDS))
|
||||
return;
|
||||
if (tid < 0)
|
||||
pn = key->u.gcmp.rx_pn[IEEE80211_NUM_TIDS];
|
||||
else
|
||||
pn = key->u.gcmp.rx_pn[tid];
|
||||
memcpy(pn, seq->gcmp.pn, IEEE80211_GCMP_PN_LEN);
|
||||
break;
|
||||
default:
|
||||
WARN_ON(1);
|
||||
break;
|
||||
|
||||
@@ -94,6 +94,24 @@ struct ieee80211_key {
|
||||
u32 replays; /* dot11RSNAStatsCMACReplays */
|
||||
u32 icverrors; /* dot11RSNAStatsCMACICVErrors */
|
||||
} aes_cmac;
|
||||
struct {
|
||||
atomic64_t tx_pn;
|
||||
u8 rx_pn[IEEE80211_GMAC_PN_LEN];
|
||||
struct crypto_aead *tfm;
|
||||
u32 replays; /* dot11RSNAStatsCMACReplays */
|
||||
u32 icverrors; /* dot11RSNAStatsCMACICVErrors */
|
||||
} aes_gmac;
|
||||
struct {
|
||||
atomic64_t tx_pn;
|
||||
/* Last received packet number. The first
|
||||
* IEEE80211_NUM_TIDS counters are used with Data
|
||||
* frames and the last counter is used with Robust
|
||||
* Management frames.
|
||||
*/
|
||||
u8 rx_pn[IEEE80211_NUM_TIDS + 1][IEEE80211_GCMP_PN_LEN];
|
||||
struct crypto_aead *tfm;
|
||||
u32 replays; /* dot11RSNAStatsGCMPReplays */
|
||||
} gcmp;
|
||||
struct {
|
||||
/* generic cipher scheme */
|
||||
u8 rx_pn[IEEE80211_NUM_TIDS + 1][MAX_PN_LEN];
|
||||
|
||||
+86
-57
@@ -658,7 +658,6 @@ static int ieee80211_init_cipher_suites(struct ieee80211_local *local)
|
||||
bool have_wep = !(IS_ERR(local->wep_tx_tfm) ||
|
||||
IS_ERR(local->wep_rx_tfm));
|
||||
bool have_mfp = local->hw.flags & IEEE80211_HW_MFP_CAPABLE;
|
||||
const struct ieee80211_cipher_scheme *cs = local->hw.cipher_schemes;
|
||||
int n_suites = 0, r = 0, w = 0;
|
||||
u32 *suites;
|
||||
static const u32 cipher_suites[] = {
|
||||
@@ -667,64 +666,29 @@ static int ieee80211_init_cipher_suites(struct ieee80211_local *local)
|
||||
WLAN_CIPHER_SUITE_WEP104,
|
||||
WLAN_CIPHER_SUITE_TKIP,
|
||||
WLAN_CIPHER_SUITE_CCMP,
|
||||
WLAN_CIPHER_SUITE_CCMP_256,
|
||||
WLAN_CIPHER_SUITE_GCMP,
|
||||
WLAN_CIPHER_SUITE_GCMP_256,
|
||||
|
||||
/* keep last -- depends on hw flags! */
|
||||
WLAN_CIPHER_SUITE_AES_CMAC
|
||||
WLAN_CIPHER_SUITE_AES_CMAC,
|
||||
WLAN_CIPHER_SUITE_BIP_CMAC_256,
|
||||
WLAN_CIPHER_SUITE_BIP_GMAC_128,
|
||||
WLAN_CIPHER_SUITE_BIP_GMAC_256,
|
||||
};
|
||||
|
||||
/* Driver specifies the ciphers, we have nothing to do... */
|
||||
if (local->hw.wiphy->cipher_suites && have_wep)
|
||||
return 0;
|
||||
|
||||
/* Set up cipher suites if driver relies on mac80211 cipher defs */
|
||||
if (!local->hw.wiphy->cipher_suites && !cs) {
|
||||
local->hw.wiphy->cipher_suites = cipher_suites;
|
||||
local->hw.wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
|
||||
|
||||
if (!have_mfp)
|
||||
local->hw.wiphy->n_cipher_suites--;
|
||||
|
||||
if (!have_wep) {
|
||||
local->hw.wiphy->cipher_suites += 2;
|
||||
local->hw.wiphy->n_cipher_suites -= 2;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!local->hw.wiphy->cipher_suites) {
|
||||
/*
|
||||
* Driver specifies cipher schemes only
|
||||
* We start counting ciphers defined by schemes, TKIP and CCMP
|
||||
if (local->hw.flags & IEEE80211_HW_SW_CRYPTO_CONTROL ||
|
||||
local->hw.wiphy->cipher_suites) {
|
||||
/* If the driver advertises, or doesn't support SW crypto,
|
||||
* we only need to remove WEP if necessary.
|
||||
*/
|
||||
n_suites = local->hw.n_cipher_schemes + 2;
|
||||
|
||||
/* check if we have WEP40 and WEP104 */
|
||||
if (have_wep)
|
||||
n_suites += 2;
|
||||
return 0;
|
||||
|
||||
/* check if we have AES_CMAC */
|
||||
if (have_mfp)
|
||||
n_suites++;
|
||||
/* well if it has _no_ ciphers ... fine */
|
||||
if (!local->hw.wiphy->n_cipher_suites)
|
||||
return 0;
|
||||
|
||||
suites = kmalloc(sizeof(u32) * n_suites, GFP_KERNEL);
|
||||
if (!suites)
|
||||
return -ENOMEM;
|
||||
|
||||
suites[w++] = WLAN_CIPHER_SUITE_CCMP;
|
||||
suites[w++] = WLAN_CIPHER_SUITE_TKIP;
|
||||
|
||||
if (have_wep) {
|
||||
suites[w++] = WLAN_CIPHER_SUITE_WEP40;
|
||||
suites[w++] = WLAN_CIPHER_SUITE_WEP104;
|
||||
}
|
||||
|
||||
if (have_mfp)
|
||||
suites[w++] = WLAN_CIPHER_SUITE_AES_CMAC;
|
||||
|
||||
for (r = 0; r < local->hw.n_cipher_schemes; r++)
|
||||
suites[w++] = cs[r].cipher;
|
||||
} else {
|
||||
/* Driver provides cipher suites, but we need to exclude WEP */
|
||||
suites = kmemdup(local->hw.wiphy->cipher_suites,
|
||||
sizeof(u32) * local->hw.wiphy->n_cipher_suites,
|
||||
@@ -740,6 +704,71 @@ static int ieee80211_init_cipher_suites(struct ieee80211_local *local)
|
||||
continue;
|
||||
suites[w++] = suite;
|
||||
}
|
||||
} else if (!local->hw.cipher_schemes) {
|
||||
/* If the driver doesn't have cipher schemes, there's nothing
|
||||
* else to do other than assign the (software supported and
|
||||
* perhaps offloaded) cipher suites.
|
||||
*/
|
||||
local->hw.wiphy->cipher_suites = cipher_suites;
|
||||
local->hw.wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
|
||||
|
||||
if (!have_mfp)
|
||||
local->hw.wiphy->n_cipher_suites -= 4;
|
||||
|
||||
if (!have_wep) {
|
||||
local->hw.wiphy->cipher_suites += 2;
|
||||
local->hw.wiphy->n_cipher_suites -= 2;
|
||||
}
|
||||
|
||||
/* not dynamically allocated, so just return */
|
||||
return 0;
|
||||
} else {
|
||||
const struct ieee80211_cipher_scheme *cs;
|
||||
|
||||
cs = local->hw.cipher_schemes;
|
||||
|
||||
/* Driver specifies cipher schemes only (but not cipher suites
|
||||
* including the schemes)
|
||||
*
|
||||
* We start counting ciphers defined by schemes, TKIP, CCMP,
|
||||
* CCMP-256, GCMP, and GCMP-256
|
||||
*/
|
||||
n_suites = local->hw.n_cipher_schemes + 5;
|
||||
|
||||
/* check if we have WEP40 and WEP104 */
|
||||
if (have_wep)
|
||||
n_suites += 2;
|
||||
|
||||
/* check if we have AES_CMAC, BIP-CMAC-256, BIP-GMAC-128,
|
||||
* BIP-GMAC-256
|
||||
*/
|
||||
if (have_mfp)
|
||||
n_suites += 4;
|
||||
|
||||
suites = kmalloc(sizeof(u32) * n_suites, GFP_KERNEL);
|
||||
if (!suites)
|
||||
return -ENOMEM;
|
||||
|
||||
suites[w++] = WLAN_CIPHER_SUITE_CCMP;
|
||||
suites[w++] = WLAN_CIPHER_SUITE_CCMP_256;
|
||||
suites[w++] = WLAN_CIPHER_SUITE_TKIP;
|
||||
suites[w++] = WLAN_CIPHER_SUITE_GCMP;
|
||||
suites[w++] = WLAN_CIPHER_SUITE_GCMP_256;
|
||||
|
||||
if (have_wep) {
|
||||
suites[w++] = WLAN_CIPHER_SUITE_WEP40;
|
||||
suites[w++] = WLAN_CIPHER_SUITE_WEP104;
|
||||
}
|
||||
|
||||
if (have_mfp) {
|
||||
suites[w++] = WLAN_CIPHER_SUITE_AES_CMAC;
|
||||
suites[w++] = WLAN_CIPHER_SUITE_BIP_CMAC_256;
|
||||
suites[w++] = WLAN_CIPHER_SUITE_BIP_GMAC_128;
|
||||
suites[w++] = WLAN_CIPHER_SUITE_BIP_GMAC_256;
|
||||
}
|
||||
|
||||
for (r = 0; r < local->hw.n_cipher_schemes; r++)
|
||||
suites[w++] = cs[r].cipher;
|
||||
}
|
||||
|
||||
local->hw.wiphy->cipher_suites = suites;
|
||||
@@ -1041,10 +1070,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
|
||||
ieee80211_max_network_latency;
|
||||
result = pm_qos_add_notifier(PM_QOS_NETWORK_LATENCY,
|
||||
&local->network_latency_notifier);
|
||||
if (result) {
|
||||
rtnl_lock();
|
||||
if (result)
|
||||
goto fail_pm_qos;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_INET
|
||||
local->ifa_notifier.notifier_call = ieee80211_ifa_changed;
|
||||
@@ -1072,15 +1099,15 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
|
||||
fail_ifa:
|
||||
pm_qos_remove_notifier(PM_QOS_NETWORK_LATENCY,
|
||||
&local->network_latency_notifier);
|
||||
rtnl_lock();
|
||||
#endif
|
||||
fail_pm_qos:
|
||||
ieee80211_led_exit(local);
|
||||
rtnl_lock();
|
||||
rate_control_deinitialize(local);
|
||||
ieee80211_remove_interfaces(local);
|
||||
fail_rate:
|
||||
rtnl_unlock();
|
||||
ieee80211_led_exit(local);
|
||||
ieee80211_wep_free(local);
|
||||
sta_info_stop(local);
|
||||
destroy_workqueue(local->workqueue);
|
||||
fail_workqueue:
|
||||
wiphy_unregister(local->hw.wiphy);
|
||||
@@ -1176,6 +1203,8 @@ void ieee80211_free_hw(struct ieee80211_hw *hw)
|
||||
|
||||
kfree(rcu_access_pointer(local->tx_latency));
|
||||
|
||||
sta_info_stop(local);
|
||||
|
||||
wiphy_free(local->hw.wiphy);
|
||||
}
|
||||
EXPORT_SYMBOL(ieee80211_free_hw);
|
||||
|
||||
@@ -523,13 +523,6 @@ void mesh_neighbour_update(struct ieee80211_sub_if_data *sdata,
|
||||
sdata->u.mesh.mshcfg.auto_open_plinks &&
|
||||
rssi_threshold_check(sdata, sta))
|
||||
changed = mesh_plink_open(sta);
|
||||
else if (sta->plink_state == NL80211_PLINK_LISTEN &&
|
||||
(sdata->u.mesh.user_mpm ||
|
||||
sdata->u.mesh.security & IEEE80211_MESH_SEC_AUTHED))
|
||||
cfg80211_notify_new_peer_candidate(sdata->dev, hw_addr,
|
||||
elems->ie_start,
|
||||
elems->total_len,
|
||||
GFP_ATOMIC);
|
||||
|
||||
ieee80211_mps_frame_release(sta, elems);
|
||||
out:
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user