aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPontus Fuchs <pontus.fuchs@gmail.com>2011-10-18 03:23:42 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2012-01-12 14:35:02 -0500
commita7b8c32b67b60fe9e8b53bb86bb7a04631e6e262 (patch)
treefa30a9638c3063b0b65bcfde0025a1438bee4e17
parent4b2bb3c98c134fb26332afd5ad54078c53a30c44 (diff)
wl12xx: Check buffer bound when processing nvs data
commit f6efe96edd9c41c624c8f4ddbc4930c1a2d8f1e1 upstream. An nvs with malformed contents could cause the processing of the calibration data to read beyond the end of the buffer. Prevent this from happening by adding bound checking. Signed-off-by: Pontus Fuchs <pontus.fuchs@gmail.com> Reviewed-by: Luciano Coelho <coelho@ti.com> Signed-off-by: Luciano Coelho <coelho@ti.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/net/wireless/wl12xx/boot.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/boot.c
index b07f8b7e5f1..e0e16888fe8 100644
--- a/drivers/net/wireless/wl12xx/boot.c
+++ b/drivers/net/wireless/wl12xx/boot.c
@@ -328,6 +328,9 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
328 nvs_ptr += 3; 328 nvs_ptr += 3;
329 329
330 for (i = 0; i < burst_len; i++) { 330 for (i = 0; i < burst_len; i++) {
331 if (nvs_ptr + 3 >= (u8 *) wl->nvs + nvs_len)
332 goto out_badnvs;
333
331 val = (nvs_ptr[0] | (nvs_ptr[1] << 8) 334 val = (nvs_ptr[0] | (nvs_ptr[1] << 8)
332 | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24)); 335 | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24));
333 336
@@ -339,6 +342,9 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
339 nvs_ptr += 4; 342 nvs_ptr += 4;
340 dest_addr += 4; 343 dest_addr += 4;
341 } 344 }
345
346 if (nvs_ptr >= (u8 *) wl->nvs + nvs_len)
347 goto out_badnvs;
342 } 348 }
343 349
344 /* 350 /*
@@ -350,6 +356,10 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
350 */ 356 */
351 nvs_ptr = (u8 *)wl->nvs + 357 nvs_ptr = (u8 *)wl->nvs +
352 ALIGN(nvs_ptr - (u8 *)wl->nvs + 7, 4); 358 ALIGN(nvs_ptr - (u8 *)wl->nvs + 7, 4);
359
360 if (nvs_ptr >= (u8 *) wl->nvs + nvs_len)
361 goto out_badnvs;
362
353 nvs_len -= nvs_ptr - (u8 *)wl->nvs; 363 nvs_len -= nvs_ptr - (u8 *)wl->nvs;
354 364
355 /* Now we must set the partition correctly */ 365 /* Now we must set the partition correctly */
@@ -365,6 +375,10 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
365 375
366 kfree(nvs_aligned); 376 kfree(nvs_aligned);
367 return 0; 377 return 0;
378
379out_badnvs:
380 wl1271_error("nvs data is malformed");
381 return -EILSEQ;
368} 382}
369 383
370static void wl1271_boot_enable_interrupts(struct wl1271 *wl) 384static void wl1271_boot_enable_interrupts(struct wl1271 *wl)