aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas
diff options
context:
space:
mode:
authorRoel Kluin <roel.kluin@gmail.com>2009-08-02 03:44:12 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-08-28 14:40:35 -0400
commit1e3d31c589a6bcb05cd7fccccf9657c27b0e3dd1 (patch)
treee8a3cee9d0e1680a06db7b557bae254d465c912d /drivers/net/wireless/libertas
parent1c4e9ab3f1cc458306b3b910000371ba4f71c4d2 (diff)
libertas: Read buffer overflow
Check whether index is within bounds before testing the element. (also includes "Libertas: Association request to the driver failed" The size of the tmp buffer was too small, causing a regression rates->rates has an arraysize of 1, so a memcpy with MAX_RATES (14) was already causing reads out of bounds. In get_common_rates() the memset/memcpy can be moved upwards. -- JWL) Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Tested-by: Daniel Mack <daniel@caiaq.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas')
-rw-r--r--drivers/net/wireless/libertas/assoc.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index 81f86ef26990..a9440a96b2e7 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -44,12 +44,11 @@ static int get_common_rates(struct lbs_private *priv,
44{ 44{
45 u8 *card_rates = lbs_bg_rates; 45 u8 *card_rates = lbs_bg_rates;
46 size_t num_card_rates = sizeof(lbs_bg_rates); 46 size_t num_card_rates = sizeof(lbs_bg_rates);
47 int ret = 0, i, j; 47 int i, j;
48 u8 *tmp; 48 u8 *tmp;
49 size_t tmp_size = 0; 49 size_t tmp_size = 0;
50 50
51 tmp = kzalloc((ARRAY_SIZE(lbs_bg_rates) - 1) * (*rates_size - 1), 51 tmp = kzalloc(MAX_RATES * ARRAY_SIZE(lbs_bg_rates), GFP_KERNEL);
52 GFP_KERNEL);
53 if (!tmp) 52 if (!tmp)
54 return -1; 53 return -1;
55 54
@@ -66,24 +65,24 @@ static int get_common_rates(struct lbs_private *priv,
66 lbs_deb_hex(LBS_DEB_JOIN, "common rates", tmp, tmp_size); 65 lbs_deb_hex(LBS_DEB_JOIN, "common rates", tmp, tmp_size);
67 lbs_deb_join("TX data rate 0x%02x\n", priv->cur_rate); 66 lbs_deb_join("TX data rate 0x%02x\n", priv->cur_rate);
68 67
68 memset(rates, 0, *rates_size);
69 *rates_size = min_t(u16, tmp_size, *rates_size);
70 memcpy(rates, tmp, *rates_size);
71
69 if (!priv->enablehwauto) { 72 if (!priv->enablehwauto) {
70 for (i = 0; i < tmp_size; i++) { 73 for (i = 0; i < tmp_size; i++) {
71 if (tmp[i] == priv->cur_rate) 74 if (tmp[i] == priv->cur_rate)
72 goto done; 75 break;
76 }
77 if (i == tmp_size) {
78 lbs_pr_alert("Previously set fixed data rate %#x isn't "
79 "compatible with the network.\n",
80 priv->cur_rate);
81 return -1;
73 } 82 }
74 lbs_pr_alert("Previously set fixed data rate %#x isn't "
75 "compatible with the network.\n", priv->cur_rate);
76 ret = -1;
77 goto done;
78 } 83 }
79 ret = 0;
80
81done:
82 memset(rates, 0, *rates_size);
83 *rates_size = min_t(int, tmp_size, *rates_size);
84 memcpy(rates, tmp, *rates_size);
85 kfree(tmp); 84 kfree(tmp);
86 return ret; 85 return 0;
87} 86}
88 87
89 88
@@ -325,8 +324,8 @@ static int lbs_associate(struct lbs_private *priv,
325 324
326 rates = (struct mrvl_ie_rates_param_set *) pos; 325 rates = (struct mrvl_ie_rates_param_set *) pos;
327 rates->header.type = cpu_to_le16(TLV_TYPE_RATES); 326 rates->header.type = cpu_to_le16(TLV_TYPE_RATES);
328 memcpy(&rates->rates, &bss->rates, MAX_RATES);
329 tmplen = MAX_RATES; 327 tmplen = MAX_RATES;
328 memcpy(&rates->rates, &bss->rates, tmplen);
330 if (get_common_rates(priv, rates->rates, &tmplen)) { 329 if (get_common_rates(priv, rates->rates, &tmplen)) {
331 ret = -1; 330 ret = -1;
332 goto done; 331 goto done;