aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhu Jianmin <jianminz@codeaurora.org>2018-07-10 21:04:01 +0800
committerShirle Yuen <shirleyshukyee@google.com>2018-07-30 10:29:01 -0700
commit20e5187a5f6539e17df1716afc4501c5ab9b6d2a (patch)
treea17a5967b3d5db73cab11a8c56290c223a619ca9
parentcdf571b72435e1267ffd1c2863ba514d0b0faa88 (diff)
downloadqcom-msm8x09-v3.10-20e5187a5f6539e17df1716afc4501c5ab9b6d2a.tar.gz
qcacld-2.0: Reject the unsafe IOCTL's in the WEXT
WEXT IOCTL's iw_set_mode and iw_get_mode is very unsafe to the driver and it needs to be rejected. Add changes to reject the IOCTL's iw_set_mode and iw_get_mode. Change-Id: Icba218feadabd5783568a75956a08cea09484be3 CRs-Fixed: 2232322 Bug: 111289931 (cherry picked from commit 67c353eb7abe8d9ff2f290d9a7b8e8292c8fd801)
-rw-r--r--drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_hostapd.c54
-rw-r--r--drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_wext.c186
2 files changed, 3 insertions, 237 deletions
diff --git a/drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_hostapd.c b/drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_hostapd.c
index f925c244351..f38eb00b85f 100644
--- a/drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_hostapd.c
+++ b/drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_hostapd.c
@@ -6053,58 +6053,6 @@ static int iw_get_ap_freq(struct net_device *dev,
return ret;
}
-/**
- * __iw_get_mode() - get mode
- * @dev - Pointer to the net device.
- * @info - Pointer to the iw_request_info.
- * @wrqu - Pointer to the iwreq_data.
- * @extra - Pointer to the data.
- *
- * Return: 0 for success, non zero for failure.
- */
-static int __iw_get_mode(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu,
- char *extra)
-{
- hdd_adapter_t *adapter;
- hdd_context_t *hdd_ctx;
- int ret;
-
- adapter = WLAN_HDD_GET_PRIV_PTR(dev);
- hdd_ctx = WLAN_HDD_GET_CTX(adapter);
- ret = wlan_hdd_validate_context(hdd_ctx);
- if (0 != ret)
- return ret;
-
- wrqu->mode = IW_MODE_MASTER;
-
- return ret;
-}
-
-/**
- * iw_get_mode() - Wrapper function to protect __iw_get_mode from the SSR.
- * @dev - Pointer to the net device.
- * @info - Pointer to the iw_request_info.
- * @wrqu - Pointer to the iwreq_data.
- * @extra - Pointer to the data.
- *
- * Return: 0 for success, non zero for failure.
- */
-static int iw_get_mode(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- int ret;
-
- vos_ssr_protect(__func__);
- ret = __iw_get_mode(dev, info, wrqu, extra);
- vos_ssr_unprotect(__func__);
-
- return ret;
-}
-
-
static int __iw_softap_stopbss(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu,
@@ -6837,7 +6785,7 @@ static const iw_handler hostapd_handler[] =
(iw_handler) NULL, /* SIOCSIWFREQ */
(iw_handler) iw_get_ap_freq, /* SIOCGIWFREQ */
(iw_handler) NULL, /* SIOCSIWMODE */
- (iw_handler) iw_get_mode, /* SIOCGIWMODE */
+ (iw_handler) NULL, /* SIOCGIWMODE */
(iw_handler) NULL, /* SIOCSIWSENS */
(iw_handler) NULL, /* SIOCGIWSENS */
(iw_handler) NULL, /* SIOCSIWRANGE */
diff --git a/drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_wext.c b/drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_wext.c
index 877c23e9627..a494c09fb8f 100644
--- a/drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_wext.c
+++ b/drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_wext.c
@@ -2003,188 +2003,6 @@ static int iw_get_name(struct net_device *dev,
return ret;
}
-
-/**
- * __iw_set_mode() - SIOCSIWMODE ioctl handler
- * @dev: device upon which the ioctl was received
- * @info: ioctl request information
- * @wrqu: ioctl request data
- * @extra: ioctl extra data
- *
- * Return: 0 on success, non-zero on error
- */
-static int __iw_set_mode(struct net_device *dev, struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- hdd_wext_state_t *pWextState;
- hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
- tCsrRoamProfile *pRoamProfile;
- eCsrRoamBssType LastBSSType;
- eMib_dot11DesiredBssType connectedBssType;
- hdd_config_t *pConfig;
- struct wireless_dev *wdev;
- hdd_context_t *hdd_ctx;
- int ret;
-
- ENTER();
-
- hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
- ret = wlan_hdd_validate_context(hdd_ctx);
- if (0 != ret)
- return ret;
-
- pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
- wdev = dev->ieee80211_ptr;
- pRoamProfile = &pWextState->roamProfile;
- LastBSSType = pRoamProfile->BSSType;
-
- hddLog(LOG1, "%s Old Bss type = %d", __func__, LastBSSType);
-
- switch (wrqu->mode)
- {
- case IW_MODE_ADHOC:
- hddLog(LOG1, "%s Setting AP Mode as IW_MODE_ADHOC", __func__);
- pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
- // Set the phymode correctly for IBSS.
- pConfig = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
- pWextState->roamProfile.phyMode = hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
- pAdapter->device_mode = WLAN_HDD_IBSS;
- wdev->iftype = NL80211_IFTYPE_ADHOC;
- break;
- case IW_MODE_INFRA:
- hddLog(LOG1, "%s Setting AP Mode as IW_MODE_INFRA", __func__);
- pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
- wdev->iftype = NL80211_IFTYPE_STATION;
- break;
- case IW_MODE_AUTO:
- hddLog(LOG1, "%s Setting AP Mode as IW_MODE_AUTO", __func__);
- pRoamProfile->BSSType = eCSR_BSS_TYPE_ANY;
- break;
- default:
- hddLog(LOGE, "%s Unknown AP Mode value %d ", __func__, wrqu->mode);
- return -EOPNOTSUPP;
- }
-
- if ( LastBSSType != pRoamProfile->BSSType )
- {
- //the BSS mode changed
- // We need to issue disconnect if connected or in IBSS disconnect state
- if ( hdd_connGetConnectedBssType( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
- ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
- {
- VOS_STATUS vosStatus;
- // need to issue a disconnect to CSR.
- INIT_COMPLETION(pAdapter->disconnect_comp_var);
- vosStatus = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
- pAdapter->sessionId,
- eCSR_DISCONNECT_REASON_IBSS_LEAVE );
- if(VOS_STATUS_SUCCESS == vosStatus)
- {
- unsigned long rc;
- rc = wait_for_completion_timeout(
- &pAdapter->disconnect_comp_var,
- msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
- if (!rc)
- hddLog(VOS_TRACE_LEVEL_ERROR,
- FL("failed wait on disconnect_comp_var"));
- }
- }
- }
-
- EXIT();
- return 0;
-}
-
-/**
- * iw_set_mode() - SSR wrapper for __iw_set_mode()
- * @dev: pointer to net_device
- * @info: pointer to iw_request_info
- * @wrqu: pointer to iwreq_data
- * @extra: pointer to extra ioctl payload
- *
- * Return: 0 on success, error number otherwise
- */
-static int iw_set_mode(struct net_device *dev, struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- int ret;
-
- vos_ssr_protect(__func__);
- ret = __iw_set_mode(dev, info, wrqu, extra);
- vos_ssr_unprotect(__func__);
-
- return ret;
-}
-
-/**
- * __iw_get_mode() - SIOCGIWMODE ioctl handler
- * @dev: device upon which the ioctl was received
- * @info: ioctl request information
- * @wrqu: ioctl request data
- * @extra: ioctl extra data
- *
- * Return: 0 on success, non-zero on error
- */
-static int
-__iw_get_mode(struct net_device *dev, struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- hdd_wext_state_t *pWextState;
- hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
- hdd_context_t *hdd_ctx;
- int ret;
-
- ENTER();
-
- hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
- ret = wlan_hdd_validate_context(hdd_ctx);
- if (0 != ret)
- return ret;
-
- pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
-
- switch (pWextState->roamProfile.BSSType) {
- case eCSR_BSS_TYPE_INFRASTRUCTURE:
- hddLog(LOG1, FL("returns IW_MODE_INFRA"));
- wrqu->mode = IW_MODE_INFRA;
- break;
- case eCSR_BSS_TYPE_IBSS:
- case eCSR_BSS_TYPE_START_IBSS:
- hddLog(LOG1, FL("returns IW_MODE_ADHOC"));
- wrqu->mode = IW_MODE_ADHOC;
- break;
- case eCSR_BSS_TYPE_ANY:
- default:
- hddLog(LOG1, FL("returns IW_MODE_AUTO"));
- wrqu->mode = IW_MODE_AUTO;
- break;
- }
-
- EXIT();
- return 0;
-}
-
-/**
- * iw_get_mode() - SSR wrapper for __iw_get_mode()
- * @dev: pointer to net_device
- * @info: pointer to iw_request_info
- * @wrqu: pointer to iwreq_data
- * @extra: pointer to extra ioctl payload
- *
- * Return: 0 on success, error number otherwise
- */
-static int iw_get_mode(struct net_device *dev, struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- int ret;
-
- vos_ssr_protect(__func__);
- ret = __iw_get_mode(dev, info, wrqu, extra);
- vos_ssr_unprotect(__func__);
-
- return ret;
-}
-
/**
* __iw_set_freq() - SIOCSIWFREQ ioctl handler
* @dev: device upon which the ioctl was received
@@ -11433,8 +11251,8 @@ static const iw_handler we_handler[] =
(iw_handler) NULL, /* SIOCGIWNWID */
(iw_handler) iw_set_freq, /* SIOCSIWFREQ */
(iw_handler) iw_get_freq, /* SIOCGIWFREQ */
- (iw_handler) iw_set_mode, /* SIOCSIWMODE */
- (iw_handler) iw_get_mode, /* SIOCGIWMODE */
+ (iw_handler) NULL, /* SIOCSIWMODE */
+ (iw_handler) NULL, /* SIOCGIWMODE */
(iw_handler) NULL, /* SIOCSIWSENS */
(iw_handler) NULL, /* SIOCGIWSENS */
(iw_handler) NULL, /* SIOCSIWRANGE */