summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnson <jjohnson@codeaurora.org>2016-11-11 17:57:13 -0800
committerqcabuildsw <qcabuildsw@localhost>2016-11-21 16:49:47 -0800
commite6bea7849a75238aa05a8dc879202c44d2f048fb (patch)
tree921b0b4624e926960c88dd3b45122a66b5e5879a
parentb5fd7c5da01445cee10cccd706868a69b4f18c68 (diff)
qcacld-3.0: Avoid overflow of EXTSCAN bucket list
This is a qcacld-2.0 to qcacld-3.0 propagation. Currently when processing an EXTSCAN vendor command the "num buckets" attribute is limit checked and if it exceeds a MAX value then a warning message is issued. But beyond that the "num buckets" attribute is not used. Instead when the buckets are actually parsed the number of buckets is calculated dynamically based upon the number of attributes present in the request. Unfortunately when the bucket attributes are parsed there is no check to make sure the number of buckets processed does not exceed the MAX value, and as a result a buffer overflow can occur. Address this issue by aborting the bucket parsing once the expected number of records have been parsed. Change-Id: Ic260dd65dc99118afbb8042d102acb5b26d1e123 CRs-Fixed: 1087797
-rw-r--r--core/hdd/src/wlan_hdd_ext_scan.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/core/hdd/src/wlan_hdd_ext_scan.c b/core/hdd/src/wlan_hdd_ext_scan.c
index 570567005e15..1a7cf50339f6 100644
--- a/core/hdd/src/wlan_hdd_ext_scan.c
+++ b/core/hdd/src/wlan_hdd_ext_scan.c
@@ -2740,6 +2740,7 @@ static int hdd_extscan_start_fill_bucket_channel_spec(
int rem1, rem2;
QDF_STATUS status;
uint8_t bkt_index, j, num_channels, total_channels = 0;
+ uint32_t expected_buckets;
uint32_t chan_list[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
uint32_t min_dwell_time_active_bucket =
@@ -2751,7 +2752,6 @@ static int hdd_extscan_start_fill_bucket_channel_spec(
uint32_t max_dwell_time_passive_bucket =
hdd_ctx->config->extscan_passive_max_chn_time;
- bkt_index = 0;
req_msg->min_dwell_time_active =
req_msg->max_dwell_time_active =
hdd_ctx->config->extscan_active_max_chn_time;
@@ -2759,10 +2759,19 @@ static int hdd_extscan_start_fill_bucket_channel_spec(
req_msg->min_dwell_time_passive =
req_msg->max_dwell_time_passive =
hdd_ctx->config->extscan_passive_max_chn_time;
+
+ expected_buckets = req_msg->numBuckets;
req_msg->numBuckets = 0;
+ bkt_index = 0;
nla_for_each_nested(buckets,
tb[QCA_WLAN_VENDOR_ATTR_EXTSCAN_BUCKET_SPEC], rem1) {
+
+ if (bkt_index >= expected_buckets) {
+ hdd_warn("ignoring excess buckets");
+ break;
+ }
+
if (nla_parse(bucket,
QCA_WLAN_VENDOR_ATTR_EXTSCAN_SUBCMD_CONFIG_PARAM_MAX,
nla_data(buckets), nla_len(buckets), NULL)) {
@@ -3256,8 +3265,10 @@ __wlan_hdd_cfg80211_extscan_start(struct wiphy *wiphy,
if (num_buckets > WLAN_EXTSCAN_MAX_BUCKETS) {
hdd_warn("Exceeded MAX number of buckets: %d",
WLAN_EXTSCAN_MAX_BUCKETS);
+ num_buckets = WLAN_EXTSCAN_MAX_BUCKETS;
}
hdd_info("Input: Number of Buckets %d", num_buckets);
+ pReqMsg->numBuckets = num_buckets;
/* This is optional attribute, if not present set it to 0 */
if (!tb[PARAM_CONFIG_FLAGS])