summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRajeev Kumar Sirasanagandla <rsirasan@codeaurora.org>2016-12-23 18:48:30 +0530
committerqcabuildsw <qcabuildsw@localhost>2017-01-25 16:00:05 -0800
commit2b61d7cf1513c7ef10dbde7c8fb80d66b9bd895f (patch)
tree82ea83e29552b70f9aacc02426837573ee0671be
parent4048e5cf54eb239c99953467e319e36c288462c0 (diff)
qcacld-3.0: Add support to randomize probe req SA and Seq number
qcacld-2.0 to qcacld-3.0 propagation 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/src/wlan_hdd_cfg80211.c28
-rw-r--r--core/hdd/src/wlan_hdd_scan.c154
-rw-r--r--core/hdd/src/wlan_hdd_scan.h13
-rw-r--r--core/mac/inc/sir_api.h18
-rw-r--r--core/mac/src/pe/lim/lim_process_sme_req_messages.c9
-rw-r--r--core/sme/inc/csr_api.h4
-rw-r--r--core/sme/src/csr/csr_api_scan.c9
-rw-r--r--core/wma/src/wma_scan_roam.c16
8 files changed, 248 insertions, 3 deletions
diff --git a/core/hdd/src/wlan_hdd_cfg80211.c b/core/hdd/src/wlan_hdd_cfg80211.c
index 54416d94318a..d2a7697578a9 100644
--- a/core/hdd/src/wlan_hdd_cfg80211.c
+++ b/core/hdd/src/wlan_hdd_cfg80211.c
@@ -1940,7 +1940,8 @@ wlan_hdd_cfg80211_get_supported_features(struct wiphy *wiphy,
* @data: Pointer to the data to be passed via vendor interface
* @data_len:Length of the data to be passed
*
- * Set the MAC address that is to be used for scanning.
+ * Set the MAC OUI which will be used to spoof sa and enable sq.no randomization
+ * of probe req frames
*
* Return: Return the Success or Failure code.
*/
@@ -1955,6 +1956,8 @@ __wlan_hdd_cfg80211_set_scanning_mac_oui(struct wiphy *wiphy,
struct nlattr *tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI_MAX + 1];
QDF_STATUS status;
int ret;
+ struct net_device *ndev = wdev->netdev;
+ hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(ndev);
ENTER_DEV(wdev->netdev);
@@ -1989,8 +1992,13 @@ __wlan_hdd_cfg80211_set_scanning_mac_oui(struct wiphy *wiphy,
nla_memcpy(&pReqMsg->oui[0],
tb[QCA_WLAN_VENDOR_ATTR_SET_SCANNING_MAC_OUI],
sizeof(pReqMsg->oui));
- hdd_notice("Oui (%02x:%02x:%02x)", pReqMsg->oui[0],
- pReqMsg->oui[1], pReqMsg->oui[2]);
+
+ /* populate pReqMsg for mac addr randomization */
+ pReqMsg->vdev_id = adapter->sessionId;
+ pReqMsg->enb_probe_req_sno_randomization = true;
+
+ hdd_notice("Oui (%02x:%02x:%02x), vdev_id = %d", pReqMsg->oui[0],
+ pReqMsg->oui[1], pReqMsg->oui[2], pReqMsg->vdev_id);
status = sme_set_scanning_mac_oui(pHddCtx->hHal, pReqMsg);
if (!QDF_IS_STATUS_SUCCESS(status)) {
hdd_err("sme_set_scanning_mac_oui failed(err=%d)", status);
@@ -9186,6 +9194,19 @@ int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
return 0;
}
+#if defined(CFG80211_SCAN_RANDOM_MAC_ADDR) || \
+ (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
+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)
+{
+}
+#endif
+
/*
* FUNCTION: wlan_hdd_cfg80211_init
* This function is called by hdd_wlan_startup()
@@ -9410,6 +9431,7 @@ int wlan_hdd_cfg80211_init(struct device *dev,
#endif
wiphy->features |= NL80211_FEATURE_INACTIVITY_TIMER;
hdd_add_channel_switch_support(&wiphy->flags);
+ wlan_hdd_cfg80211_scan_randomization_init(wiphy);
EXIT();
return 0;
diff --git a/core/hdd/src/wlan_hdd_scan.c b/core/hdd/src/wlan_hdd_scan.c
index c5d529757f73..558fc3d60eac 100644
--- a/core/hdd/src/wlan_hdd_scan.c
+++ b/core/hdd/src/wlan_hdd_scan.c
@@ -1455,6 +1455,88 @@ static int wlan_hdd_update_scan_ies(hdd_adapter_t *adapter,
return 0;
}
+#if defined(CFG80211_SCAN_RANDOM_MAC_ADDR) || \
+ (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
+/**
+ * wlan_hdd_update_scan_rand_attrs - fill the host/pno scan rand attrs
+ * @scan_req: pointer to scan_req containing destination mac addr and mac mask
+ * @cfg_scan_req: pointer to cfg scan containing to source mac addr and mac mask
+ * @scan_type: type of scan from enum wlan_hdd_scan_type
+ *
+ * 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: 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;
+ bool *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 {
+ hdd_err("invalid scan type for randomization");
+ return;
+ }
+
+ /* enable mac randomization */
+ *scan_randomization = true;
+ memcpy(scan_mac_addr, cfg_mac_addr, QDF_MAC_ADDR_SIZE);
+ memcpy(scan_mac_addr_mask, cfg_mac_addr_mask, QDF_MAC_ADDR_SIZE);
+
+ hdd_info("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)
+{
+}
+#endif
+
/**
* __wlan_hdd_cfg80211_scan() - API to process cfg80211 scan request
* @wiphy: Pointer to wiphy
@@ -1867,6 +1949,9 @@ static int __wlan_hdd_cfg80211_scan(struct wiphy *wiphy,
if (request->flags & NL80211_SCAN_FLAG_FLUSH)
sme_scan_flush_result(WLAN_HDD_GET_HAL_CTX(pAdapter));
#endif
+ wlan_hdd_update_scan_rand_attrs((void *)&scan_req, (void *)request,
+ WLAN_HDD_HOST_SCAN);
+
qdf_runtime_pm_prevent_suspend(pHddCtx->runtime_context.scan);
status = sme_scan_request(WLAN_HDD_GET_HAL_CTX(pAdapter),
pAdapter->sessionId, &scan_req,
@@ -2053,6 +2138,69 @@ static inline void wlan_hdd_copy_bssid(struct cfg80211_scan_request *request,
}
#endif
+#if defined(CFG80211_SCAN_RANDOM_MAC_ADDR) || \
+ (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0))
+/**
+ * wlan_hdd_vendor_scan_random_attr() - check and fill scan randomization attrs
+ * @wiphy: Pointer to wiphy
+ * @request: Pointer to scan request
+ * @wdev: Pointer to wireless device
+ * @tb: Pointer to nl attributes
+ *
+ * This function is invoked to check whether vendor scan needs
+ * probe req source addr , if so populates mac_addr and mac_addr_mask
+ * in scan request with nl attrs.
+ *
+ * Return: 0 - on success, negative value on failure
+ */
+
+static int wlan_hdd_vendor_scan_random_attr(struct wiphy *wiphy,
+ struct cfg80211_scan_request *request,
+ struct wireless_dev *wdev,
+ struct nlattr **tb)
+{
+ uint32_t i;
+
+ if (!(request->flags & NL80211_SCAN_FLAG_RANDOM_ADDR))
+ return 0;
+
+ if (!(wiphy->features & NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR) ||
+ (wdev->current_bss)) {
+ hdd_err("SCAN RANDOMIZATION not supported");
+ return -EOPNOTSUPP;
+ }
+
+ if (!tb[QCA_WLAN_VENDOR_ATTR_SCAN_MAC] ||
+ !tb[QCA_WLAN_VENDOR_ATTR_SCAN_MAC_MASK])
+ return -EINVAL;
+
+ qdf_mem_copy(request->mac_addr,
+ nla_data(tb[QCA_WLAN_VENDOR_ATTR_SCAN_MAC]),
+ QDF_MAC_ADDR_SIZE);
+ qdf_mem_copy(request->mac_addr_mask,
+ nla_data(tb[QCA_WLAN_VENDOR_ATTR_SCAN_MAC_MASK]),
+ QDF_MAC_ADDR_SIZE);
+
+ /* avoid configure on multicast address */
+ if (!qdf_is_group_addr(request->mac_addr_mask) ||
+ qdf_is_group_addr(request->mac_addr))
+ return -EINVAL;
+
+ for (i = 0; i < ETH_ALEN; i++)
+ request->mac_addr[i] &= request->mac_addr_mask[i];
+
+ return 0;
+}
+#else
+static int wlan_hdd_vendor_scan_random_attr(struct wiphy *wiphy,
+ struct cfg80211_scan_request *request,
+ struct wireless_dev *wdev,
+ struct nlattr **tb)
+{
+ return 0;
+}
+#endif
+
/**
* __wlan_hdd_cfg80211_vendor_scan() - API to process venor scan request
* @wiphy: Pointer to wiphy
@@ -2222,6 +2370,9 @@ static int __wlan_hdd_cfg80211_vendor_scan(struct wiphy *wiphy,
hdd_err("LOW PRIORITY SCAN not supported");
goto error;
}
+
+ if (wlan_hdd_vendor_scan_random_attr(wiphy, request, wdev, tb))
+ goto error;
}
if (tb[QCA_WLAN_VENDOR_ATTR_SCAN_BSSID]) {
@@ -2832,6 +2983,9 @@ static int __wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
hdd_info("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_set_preferred_network_list(WLAN_HDD_GET_HAL_CTX(pAdapter),
pPnoRequest,
pAdapter->sessionId,
diff --git a/core/hdd/src/wlan_hdd_scan.h b/core/hdd/src/wlan_hdd_scan.h
index 2094ffd9e0c6..96c96f423615 100644
--- a/core/hdd/src/wlan_hdd_scan.h
+++ b/core/hdd/src/wlan_hdd_scan.h
@@ -47,6 +47,19 @@ enum scan_source {
VENDOR_SCAN,
};
+/**
+ * enum wlan_hdd_scan_type - 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 {
+ WLAN_HDD_HOST_SCAN,
+ WLAN_HDD_PNO_SCAN,
+};
+
int iw_get_scan(struct net_device *dev, struct iw_request_info *info,
union iwreq_data *wrqu, char *extra);
diff --git a/core/mac/inc/sir_api.h b/core/mac/inc/sir_api.h
index 52753a94dae6..9fce9fab620f 100644
--- a/core/mac/inc/sir_api.h
+++ b/core/mac/inc/sir_api.h
@@ -904,6 +904,11 @@ typedef struct sSirSmeScanReq {
uint16_t uIEFieldLen;
uint16_t uIEFieldOffset;
+ /* mac address randomization attributes */
+ bool enable_scan_randomization;
+ uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
+ uint8_t mac_addr_mask[QDF_MAC_ADDR_SIZE];
+
/* channelList MUST be the last field of this structure */
tSirChannelList channelList;
/*-----------------------------
@@ -2943,6 +2948,11 @@ typedef struct sSirPNOScanReq {
enum wmi_dwelltime_adaptive_mode pnoscan_adaptive_dwell_mode;
uint32_t channel_prediction_full_scan;
#endif
+
+ /* mac address randomization attributes */
+ bool enable_pno_scan_randomization;
+ uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
+ uint8_t mac_addr_mask[QDF_MAC_ADDR_SIZE];
} tSirPNOScanReq, *tpSirPNOScanReq;
/* Preferred Network Found Indication */
@@ -3770,6 +3780,12 @@ typedef struct sSirScanOffloadReq {
enum wmi_dwelltime_adaptive_mode scan_adaptive_dwell_mode;
uint16_t uIEFieldLen;
uint16_t uIEFieldOffset;
+
+ /* mac address randomization attributes */
+ bool enable_scan_randomization;
+ uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
+ uint8_t mac_addr_mask[QDF_MAC_ADDR_SIZE];
+
tSirChannelList channelList;
/*-----------------------------
sSirScanOffloadReq....
@@ -4928,6 +4944,8 @@ struct power_stats_response {
typedef struct {
uint8_t oui[WIFI_SCANNING_MAC_OUI_LENGTH];
+ uint32_t vdev_id;
+ bool enb_probe_req_sno_randomization;
} tSirScanMacOui, *tpSirScanMacOui;
enum {
diff --git a/core/mac/src/pe/lim/lim_process_sme_req_messages.c b/core/mac/src/pe/lim/lim_process_sme_req_messages.c
index d1c2b5fb1cff..382605aaaf2a 100644
--- a/core/mac/src/pe/lim/lim_process_sme_req_messages.c
+++ b/core/mac/src/pe/lim/lim_process_sme_req_messages.c
@@ -1325,6 +1325,15 @@ static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
(uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
pScanReq->uIEFieldLen);
+ pScanOffloadReq->enable_scan_randomization =
+ pScanReq->enable_scan_randomization;
+ if (pScanOffloadReq->enable_scan_randomization) {
+ qdf_mem_copy(pScanOffloadReq->mac_addr, pScanReq->mac_addr,
+ QDF_MAC_ADDR_SIZE);
+ qdf_mem_copy(pScanOffloadReq->mac_addr_mask,
+ pScanReq->mac_addr_mask, QDF_MAC_ADDR_SIZE);
+ }
+
rc = wma_post_ctrl_msg(pMac, &msg);
if (rc != eSIR_SUCCESS) {
lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
diff --git a/core/sme/inc/csr_api.h b/core/sme/inc/csr_api.h
index 9c7462ae46b3..249b4bb949e3 100644
--- a/core/sme/inc/csr_api.h
+++ b/core/sme/inc/csr_api.h
@@ -293,6 +293,10 @@ typedef struct tagCsrScanRequest {
bool bcnRptReqScan; /* is Scan issued by Beacon Report Request */
uint32_t scan_id;
uint32_t timestamp;
+
+ bool enable_scan_randomization;
+ uint8_t mac_addr[QDF_MAC_ADDR_SIZE];
+ uint8_t mac_addr_mask[QDF_MAC_ADDR_SIZE];
} tCsrScanRequest;
typedef struct tagCsrScanResultInfo {
diff --git a/core/sme/src/csr/csr_api_scan.c b/core/sme/src/csr/csr_api_scan.c
index 3ebbf73a46df..cdbd77ca2787 100644
--- a/core/sme/src/csr/csr_api_scan.c
+++ b/core/sme/src/csr/csr_api_scan.c
@@ -5188,6 +5188,15 @@ static QDF_STATUS csr_send_mb_scan_req(tpAniSirGlobal pMac, uint16_t sessionId,
pMsg->p2pSearch = pScanReq->p2pSearch;
pMsg->scan_id = pScanReq->scan_id;
+ pMsg->enable_scan_randomization =
+ pScanReq->enable_scan_randomization;
+ if (pMsg->enable_scan_randomization) {
+ qdf_mem_copy(pMsg->mac_addr, pScanReq->mac_addr,
+ QDF_MAC_ADDR_SIZE);
+ qdf_mem_copy(pMsg->mac_addr_mask, pScanReq->mac_addr_mask,
+ QDF_MAC_ADDR_SIZE);
+ }
+
send_scan_req:
sms_log(pMac, LOG1,
FL("scanId %d domainIdCurrent %d scanType %s (%d) bssType %s (%d) requestType %s (%d) numChannels %d"),
diff --git a/core/wma/src/wma_scan_roam.c b/core/wma/src/wma_scan_roam.c
index 92df6201a036..0cba8ff1560a 100644
--- a/core/wma/src/wma_scan_roam.c
+++ b/core/wma/src/wma_scan_roam.c
@@ -277,6 +277,12 @@ QDF_STATUS wma_get_buf_start_scan_cmd(tp_wma_handle wma_handle,
*/
cmd->burst_duration = 0;
+ /* mac randomization attributes */
+ cmd->enable_scan_randomization = scan_req->enable_scan_randomization;
+ qdf_mem_copy(cmd->mac_addr, scan_req->mac_addr, QDF_MAC_ADDR_SIZE);
+ qdf_mem_copy(cmd->mac_addr_mask, scan_req->mac_addr_mask,
+ QDF_MAC_ADDR_SIZE);
+
if (!scan_req->p2pScanType) {
WMA_LOGD("Normal Scan request");
cmd->scan_ctrl_flags |= WMI_SCAN_ADD_CCK_RATES;
@@ -3079,6 +3085,12 @@ QDF_STATUS wma_pno_start(tp_wma_handle wma, tpSirPNOScanReq pno)
WMI_MAC_MAX_SSID_LENGTH);
}
+ params->enable_pno_scan_randomization =
+ pno->enable_pno_scan_randomization;
+ qdf_mem_copy(params->mac_addr, pno->mac_addr, QDF_MAC_ADDR_SIZE);
+ qdf_mem_copy(params->mac_addr_mask, pno->mac_addr_mask,
+ QDF_MAC_ADDR_SIZE);
+
status = wmi_unified_pno_start_cmd(wma->wmi_handle,
params, channel_list);
if (QDF_IS_STATUS_SUCCESS(status)) {
@@ -5521,6 +5533,10 @@ QDF_STATUS wma_scan_probe_setoui(tp_wma_handle wma, tSirScanMacOui *psetoui)
qdf_mem_copy(set_oui.oui, psetoui->oui,
WMI_WIFI_SCANNING_MAC_OUI_LENGTH);
+ set_oui.vdev_id = psetoui->vdev_id;
+ set_oui.enb_probe_req_sno_randomization =
+ psetoui->enb_probe_req_sno_randomization;
+
return wmi_unified_scan_probe_setoui_cmd(wma->wmi_handle,
&set_oui);
}