summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajeev Kumar Sirasanagandla <rsirasan@codeaurora.org>2016-11-04 13:10:14 +0530
committerAnjaneedevi Kapparapu <akappa@codeaurora.org>2016-11-11 20:08:26 +0530
commit0a84b287ee0dfb7dfca705d73814fb335b49537e (patch)
tree2970492f91fae1545e5f5297cb4d6f3ed214869c
parente265a1fc5ad17dcdebc7fba9954db334b3d37f64 (diff)
qcacld-2.0: Add support to randomize probe req SA and Seq number
Randomize probe request's source address and sequence number to improve user's privacy. Change-Id: Ic367ce4578e65faf49e8092f0f8cce057eead728 CRs-Fixed: 1085995
-rw-r--r--CORE/HDD/inc/wlan_hdd_cfg80211.h14
-rw-r--r--CORE/HDD/src/wlan_hdd_cfg80211.c114
-rw-r--r--CORE/MAC/inc/sirApi.h16
-rw-r--r--CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c9
-rw-r--r--CORE/SERVICES/WMA/wma.c26
-rw-r--r--CORE/SME/inc/csrApi.h4
-rw-r--r--CORE/SME/src/csr/csrApiScan.c8
7 files changed, 188 insertions, 3 deletions
diff --git a/CORE/HDD/inc/wlan_hdd_cfg80211.h b/CORE/HDD/inc/wlan_hdd_cfg80211.h
index 3f48cd0e9608..797b39abcd8c 100644
--- a/CORE/HDD/inc/wlan_hdd_cfg80211.h
+++ b/CORE/HDD/inc/wlan_hdd_cfg80211.h
@@ -2298,4 +2298,18 @@ static inline void wlan_hdd_cfg80211_indicate_disconnect(struct net_device *dev,
GFP_KERNEL);
}
#endif
+
+/**
+ * enum wlan_hdd_scan_type_for_randomization - type of scan
+ * @WLAN_HDD_HOST_SCAN: refers to scan request from cfg80211_ops "scan"
+ * @WLAN_HDD_PNO_SCAN: refers to scan request is from "sched_scan_start"
+ *
+ * driver uses this enum to identify source of scan
+ *
+ */
+enum wlan_hdd_scan_type_for_randomization {
+ WLAN_HDD_HOST_SCAN,
+ WLAN_HDD_PNO_SCAN,
+};
+
#endif
diff --git a/CORE/HDD/src/wlan_hdd_cfg80211.c b/CORE/HDD/src/wlan_hdd_cfg80211.c
index ce8043d7223a..b61bbdbca76f 100644
--- a/CORE/HDD/src/wlan_hdd_cfg80211.c
+++ b/CORE/HDD/src/wlan_hdd_cfg80211.c
@@ -1599,6 +1599,8 @@ __wlan_hdd_cfg80211_set_scanning_mac_oui(struct wiphy *wiphy,
struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
eHalStatus status;
int ret;
+ struct net_device *ndev = wdev->netdev;
+ hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(ndev);
ENTER();
@@ -1628,6 +1630,7 @@ __wlan_hdd_cfg80211_set_scanning_mac_oui(struct wiphy *wiphy,
hddLog(LOGE, FL("vos_mem_malloc failed"));
return -ENOMEM;
}
+ vos_mem_zero(pReqMsg, sizeof(*pReqMsg));
/* Parse and fetch oui */
if (!tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI]) {
@@ -1639,8 +1642,12 @@ __wlan_hdd_cfg80211_set_scanning_mac_oui(struct wiphy *wiphy,
tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI],
sizeof(pReqMsg->oui));
- hddLog(LOG1, FL("Oui (%02x:%02x:%02x)"), pReqMsg->oui[0], pReqMsg->oui[1],
- pReqMsg->oui[2]);
+ /* populate pReqMsg for mac addr randomization */
+ pReqMsg->vdev_id = pAdapter->sessionId;
+ pReqMsg->enb_probe_req_sno_randomization = 1;
+
+ hddLog(LOG1, FL("Oui (%02x:%02x:%02x), vdev_id = %d"), pReqMsg->oui[0],
+ pReqMsg->oui[1], pReqMsg->oui[2], pReqMsg->vdev_id);
status = sme_SetScanningMacOui(pHddCtx->hHal, pReqMsg);
if (!HAL_STATUS_SUCCESS(status)) {
@@ -12619,6 +12626,19 @@ static void hdd_config_sched_scan_plans_to_wiphy(struct wiphy *wiphy,
}
#endif
+#ifdef CFG80211_SCAN_RANDOM_MAC_ADDR
+static void wlan_hdd_cfg80211_scan_randomization_init(struct wiphy *wiphy)
+{
+ wiphy->features |= NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR;
+ wiphy->features |= NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR;
+}
+#else
+static void wlan_hdd_cfg80211_scan_randomization_init(struct wiphy *wiphy)
+{
+ return;
+}
+#endif
+
/*
* FUNCTION: wlan_hdd_cfg80211_init
* This function is called by hdd_wlan_startup()
@@ -12865,6 +12885,7 @@ int wlan_hdd_cfg80211_init(struct device *dev,
wiphy->features |= NL80211_FEATURE_INACTIVITY_TIMER;
hdd_config_sched_scan_plans_to_wiphy(wiphy, pCfg);
+ wlan_hdd_cfg80211_scan_randomization_init(wiphy);
EXIT();
return 0;
@@ -18309,6 +18330,89 @@ static void wlan_hdd_cfg80211_scan_block_cb(struct work_struct *work)
}
}
+#ifdef CFG80211_SCAN_RANDOM_MAC_ADDR
+/**
+ * wlan_hdd_update_scan_rand_attrs - fill the host/pno scan rand attrs
+ * @scan_req: pointer for destination mac addr and mac mask
+ * @cfg_scan_req: pointer for source mac addr and mac mask
+ * @scan_type: type of scan from enum wlan_hdd_scan_type_for_randomization
+ *
+ * If scan randomize flag is set in cfg scan request flags, this function
+ * copies mac addr and mac mask in cfg80211 scan/sched scan request to
+ * randomization attributes in tCsrScanRequest (normal scan) or
+ * tpSirPNOScanReq (sched scan). Based on the type of scan, scan_req and
+ * cfg_scan_req are type casted accordingly.
+ *
+ * Return: Return none
+ */
+static void wlan_hdd_update_scan_rand_attrs(void *scan_req,
+ void *cfg_scan_req,
+ uint32_t scan_type)
+{
+ uint32_t flags = 0;
+ uint8_t *cfg_mac_addr = NULL;
+ uint8_t *cfg_mac_addr_mask = NULL;
+ uint32_t *scan_randomization = NULL;
+ uint8_t *scan_mac_addr = NULL;
+ uint8_t *scan_mac_addr_mask = NULL;
+
+ if (scan_type == WLAN_HDD_HOST_SCAN) {
+ tCsrScanRequest *csr_scan_req = NULL;
+ struct cfg80211_scan_request *request = NULL;
+
+ csr_scan_req = (tCsrScanRequest *)scan_req;
+ request = (struct cfg80211_scan_request *)cfg_scan_req;
+
+ flags = request->flags;
+ if (!(flags & NL80211_SCAN_FLAG_RANDOM_ADDR))
+ return;
+
+ cfg_mac_addr = request->mac_addr;
+ cfg_mac_addr_mask = request->mac_addr_mask;
+ scan_randomization = &csr_scan_req->enable_scan_randomization;
+ scan_mac_addr = csr_scan_req->mac_addr;
+ scan_mac_addr_mask = csr_scan_req->mac_addr_mask;
+ } else if (scan_type == WLAN_HDD_PNO_SCAN) {
+ tpSirPNOScanReq pno_scan_req = NULL;
+ struct cfg80211_sched_scan_request *request = NULL;
+
+ pno_scan_req = (tpSirPNOScanReq)scan_req;
+ request = (struct cfg80211_sched_scan_request *)cfg_scan_req;
+
+ flags = request->flags;
+ if (!(flags & NL80211_SCAN_FLAG_RANDOM_ADDR))
+ return;
+
+ cfg_mac_addr = request->mac_addr;
+ cfg_mac_addr_mask = request->mac_addr_mask;
+ scan_randomization =
+ &pno_scan_req->enable_pno_scan_randomization;
+ scan_mac_addr = pno_scan_req->mac_addr;
+ scan_mac_addr_mask = pno_scan_req->mac_addr_mask;
+ } else {
+ hddLog(LOGE, FL("invalid scan type for randomization"));
+ return;
+ }
+
+ /* enable mac randomization */
+ *scan_randomization = 1;
+ memcpy(scan_mac_addr, cfg_mac_addr, VOS_MAC_ADDR_SIZE);
+ memcpy(scan_mac_addr_mask, cfg_mac_addr_mask, VOS_MAC_ADDR_SIZE);
+
+ hddLog(LOG1, FL("Mac Addr: "MAC_ADDRESS_STR
+ " and Mac Mask: " MAC_ADDRESS_STR),
+ MAC_ADDR_ARRAY(scan_mac_addr),
+ MAC_ADDR_ARRAY(scan_mac_addr_mask));
+}
+#else
+static void wlan_hdd_update_scan_rand_attrs(void *scan_req,
+ void *cfg_scan_req,
+ uint32_t scan_type)
+{
+ return;
+}
+#endif
+
/*
* FUNCTION: __wlan_hdd_cfg80211_scan
* this scan respond to scan trigger and update cfg80211 scan database
@@ -18698,6 +18802,9 @@ int __wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
pAdapter->sessionId);
#endif
+ wlan_hdd_update_scan_rand_attrs((void *)&scanRequest, (void *)request,
+ WLAN_HDD_HOST_SCAN);
+
vos_runtime_pm_prevent_suspend(pHddCtx->runtime_context.scan);
status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
pAdapter->sessionId, &scanRequest, &scanId,
@@ -22875,6 +22982,9 @@ static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
"SessionId %d, enable %d, modePNO %d",
pAdapter->sessionId, pPnoRequest->enable, pPnoRequest->modePNO);
+ wlan_hdd_update_scan_rand_attrs((void *)pPnoRequest, (void *)request,
+ WLAN_HDD_PNO_SCAN);
+
status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
pPnoRequest, pAdapter->sessionId,
hdd_cfg80211_sched_scan_done_callback, pAdapter);
diff --git a/CORE/MAC/inc/sirApi.h b/CORE/MAC/inc/sirApi.h
index c9f5829fb6be..83d53bec4ba3 100644
--- a/CORE/MAC/inc/sirApi.h
+++ b/CORE/MAC/inc/sirApi.h
@@ -942,6 +942,10 @@ typedef struct sSirSmeScanReq
tANI_U16 uIEFieldLen;
tANI_U16 uIEFieldOffset;
+ uint32_t enable_scan_randomization;
+ uint8_t mac_addr[VOS_MAC_ADDR_SIZE];
+ uint8_t mac_addr_mask[VOS_MAC_ADDR_SIZE];
+
//channelList MUST be the last field of this structure
tSirChannelList channelList;
/*-----------------------------
@@ -3801,6 +3805,11 @@ typedef struct sSirPNOScanReq {
uint8_t p24GProbeTemplate[SIR_PNO_MAX_PB_REQ_SIZE];
uint16_t us5GProbeTemplateLen;
uint8_t p5GProbeTemplate[SIR_PNO_MAX_PB_REQ_SIZE];
+
+ /* mac address randomization attributes */
+ uint32_t enable_pno_scan_randomization;
+ uint8_t mac_addr[VOS_MAC_ADDR_SIZE];
+ uint8_t mac_addr_mask[VOS_MAC_ADDR_SIZE];
} tSirPNOScanReq, *tpSirPNOScanReq;
typedef struct sSirSetRSSIFilterReq
@@ -4523,6 +4532,11 @@ typedef struct sSirScanOffloadReq {
tSirP2pScanType p2pScanType;
tANI_U16 uIEFieldLen;
tANI_U16 uIEFieldOffset;
+
+ uint32_t enable_scan_randomization;
+ uint8_t mac_addr[VOS_MAC_ADDR_SIZE];
+ uint8_t mac_addr_mask[VOS_MAC_ADDR_SIZE];
+
tSirChannelList channelList;
/*-----------------------------
sSirScanOffloadReq....
@@ -5812,6 +5826,8 @@ typedef struct
typedef struct
{
tANI_U8 oui[WIFI_SCANNING_MAC_OUI_LENGTH];
+ uint32_t vdev_id;
+ uint32_t enb_probe_req_sno_randomization;
} tSirScanMacOui, *tpSirScanMacOui;
enum {
diff --git a/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c b/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c
index 90fa6d1316cf..a6a7879b61a3 100644
--- a/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c
+++ b/CORE/MAC/src/pe/lim/limProcessSmeReqMessages.c
@@ -1386,6 +1386,15 @@ static eHalStatus limSendHalStartScanOffloadReq(tpAniSirGlobal pMac,
pScanOffloadReq->uIEFieldLen += DOT11F_IE_WFATPC_MAX_LEN + 2;
}
+ pScanOffloadReq->enable_scan_randomization =
+ pScanReq->enable_scan_randomization;
+ if (pScanOffloadReq->enable_scan_randomization) {
+ vos_mem_copy(pScanOffloadReq->mac_addr, pScanReq->mac_addr,
+ VOS_MAC_ADDR_SIZE);
+ vos_mem_copy(pScanOffloadReq->mac_addr_mask, pScanReq->mac_addr_mask,
+ VOS_MAC_ADDR_SIZE);
+ }
+
rc = wdaPostCtrlMsg(pMac, &msg);
if (rc != eSIR_SUCCESS)
{
diff --git a/CORE/SERVICES/WMA/wma.c b/CORE/SERVICES/WMA/wma.c
index a6ac363484db..c89f31bff5e3 100644
--- a/CORE/SERVICES/WMA/wma.c
+++ b/CORE/SERVICES/WMA/wma.c
@@ -10002,6 +10002,16 @@ VOS_STATUS wma_get_buf_start_scan_cmd(tp_wma_handle wma_handle,
*/
cmd->burst_duration = 0;
+ /* mac randomization attributes */
+ if (scan_req->enable_scan_randomization) {
+ cmd->scan_ctrl_flags |= WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
+ WMI_SCAN_RANDOM_SEQ_NO_IN_PROBE_REQ;
+ WMI_CHAR_ARRAY_TO_MAC_ADDR(scan_req->mac_addr, &cmd->mac_addr);
+ WMI_CHAR_ARRAY_TO_MAC_ADDR(scan_req->mac_addr_mask,
+ &cmd->mac_mask);
+ }
+ WMA_LOGI("scan_ctrl_flags = %x", cmd->scan_ctrl_flags);
+
if (!scan_req->p2pScanType) {
WMA_LOGD("Normal Scan request");
cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
@@ -20562,6 +20572,14 @@ static VOS_STATUS wma_pno_start(tp_wma_handle wma, tpSirPNOScanReq pno)
cmd->fast_scan_period, cmd->slow_scan_period);
WMA_LOGD("fast_scan_max_cycles: %d", cmd->fast_scan_max_cycles);
+ if (pno->enable_pno_scan_randomization) {
+ cmd->flags |= WMI_NLO_CONFIG_SPOOFED_MAC_IN_PROBE_REQ |
+ WMI_NLO_CONFIG_RANDOM_SEQ_NO_IN_PROBE_REQ;
+ WMI_CHAR_ARRAY_TO_MAC_ADDR(pno->mac_addr, &cmd->mac_addr);
+ WMI_CHAR_ARRAY_TO_MAC_ADDR(pno->mac_addr_mask, &cmd->mac_mask);
+ }
+ WMA_LOGI("pno flags = %x", cmd->flags);
+
buf_ptr += sizeof(wmi_nlo_config_cmd_fixed_param);
cmd->no_of_ssids = MIN(pno->ucNetworksCount, WMI_NLO_MAX_SSIDS);
@@ -28006,7 +28024,6 @@ static VOS_STATUS wma_process_ll_stats_getReq
cmd->scan_ctrl_flags = WMI_SCAN_ADD_BCAST_PROBE_REQ |
WMI_SCAN_ADD_CCK_RATES |
WMI_SCAN_ADD_OFDM_RATES |
- WMI_SCAN_ADD_SPOOFED_MAC_IN_PROBE_REQ |
WMI_SCAN_ADD_DS_IE_IN_PROBE_REQ;
cmd->scan_priority = WMI_SCAN_PRIORITY_VERY_LOW;
cmd->num_ssids = 0;
@@ -29367,6 +29384,13 @@ VOS_STATUS wma_scan_probe_setoui(tp_wma_handle wma,
WMA_LOGD("%s: wma:oui received from hdd %08x", __func__,
cmd->prob_req_oui);
+ cmd->vdev_id = psetoui->vdev_id;
+ cmd->flags = WMI_SCAN_PROBE_OUI_SPOOFED_MAC_IN_PROBE_REQ;
+ if (psetoui->enb_probe_req_sno_randomization)
+ cmd->flags |= WMI_SCAN_PROBE_OUI_RANDOM_SEQ_NO_IN_PROBE_REQ;
+ WMA_LOGI(FL("vdev_id = %d, flags = %x"), cmd->vdev_id, cmd->flags);
+
+
if (wmi_unified_cmd_send(wma->wmi_handle, wmi_buf, len,
WMI_SCAN_PROB_REQ_OUI_CMDID)) {
WMA_LOGE("%s: failed to send command", __func__);
diff --git a/CORE/SME/inc/csrApi.h b/CORE/SME/inc/csrApi.h
index faef3b1e111e..5c03abe8c50c 100644
--- a/CORE/SME/inc/csrApi.h
+++ b/CORE/SME/inc/csrApi.h
@@ -310,6 +310,10 @@ typedef struct tagCsrScanRequest
eCsrRequestType requestType; //11d scan or full scan
tANI_BOOLEAN p2pSearch;
tANI_BOOLEAN skipDfsChnlInP2pSearch;
+
+ uint32_t enable_scan_randomization;
+ uint8_t mac_addr[VOS_MAC_ADDR_SIZE];
+ uint8_t mac_addr_mask[VOS_MAC_ADDR_SIZE];
}tCsrScanRequest;
typedef struct tagCsrBGScanRequest
diff --git a/CORE/SME/src/csr/csrApiScan.c b/CORE/SME/src/csr/csrApiScan.c
index a1dfb33aafd5..37e5a0f4ee77 100644
--- a/CORE/SME/src/csr/csrApiScan.c
+++ b/CORE/SME/src/csr/csrApiScan.c
@@ -5991,6 +5991,14 @@ eHalStatus csrSendMBScanReq( tpAniSirGlobal pMac, tANI_U16 sessionId,
pMsg->backgroundScanMode = eSIR_ROAMING_SCAN;
}
+ pMsg->enable_scan_randomization =
+ pScanReq->enable_scan_randomization;
+ if (pMsg->enable_scan_randomization) {
+ vos_mem_copy(pMsg->mac_addr, pScanReq->mac_addr,
+ VOS_MAC_ADDR_SIZE);
+ vos_mem_copy(pMsg->mac_addr_mask, pScanReq->mac_addr_mask,
+ VOS_MAC_ADDR_SIZE);
+ }
}while(0);
smsLog(pMac, LOG1, FL("domainIdCurrent %s (%d) scanType %s (%d)"
"bssType %s (%d), requestType %s(%d)"