aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPontus Fuchs <pontus.fuchs@gmail.com>2011-10-18 03:23:42 -0400
committerLuciano Coelho <coelho@ti.com>2011-12-01 08:55:42 -0500
commitf6efe96edd9c41c624c8f4ddbc4930c1a2d8f1e1 (patch)
tree45c3098bce60b712b9a33a4fbfef73a5b6c030c3
parent2131d3c2f99b081806fdae7662c92fe6acda52af (diff)
wl12xx: Check buffer bound when processing nvs data
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> Cc: stable@kernel.org Reviewed-by: Luciano Coelho <coelho@ti.com> Signed-off-by: Luciano Coelho <coelho@ti.com>
-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 6e140bf4e236..8f9cf5a816ea 100644
--- a/drivers/net/wireless/wl12xx/boot.c
+++ b/drivers/net/wireless/wl12xx/boot.c
@@ -348,6 +348,9 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
348 nvs_ptr += 3; 348 nvs_ptr += 3;
349 349
350 for (i = 0; i < burst_len; i++) { 350 for (i = 0; i < burst_len; i++) {
351 if (nvs_ptr + 3 >= (u8 *) wl->nvs + nvs_len)
352 goto out_badnvs;
353
351 val = (nvs_ptr[0] | (nvs_ptr[1] << 8) 354 val = (nvs_ptr[0] | (nvs_ptr[1] << 8)
352 | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24)); 355 | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24));
353 356
@@ -359,6 +362,9 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
359 nvs_ptr += 4; 362 nvs_ptr += 4;
360 dest_addr += 4; 363 dest_addr += 4;
361 } 364 }
365
366 if (nvs_ptr >= (u8 *) wl->nvs + nvs_len)
367 goto out_badnvs;
362 } 368 }
363 369
364 /* 370 /*
@@ -370,6 +376,10 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
370 */ 376 */
371 nvs_ptr = (u8 *)wl->nvs + 377 nvs_ptr = (u8 *)wl->nvs +
372 ALIGN(nvs_ptr - (u8 *)wl->nvs + 7, 4); 378 ALIGN(nvs_ptr - (u8 *)wl->nvs + 7, 4);
379
380 if (nvs_ptr >= (u8 *) wl->nvs + nvs_len)
381 goto out_badnvs;
382
373 nvs_len -= nvs_ptr - (u8 *)wl->nvs; 383 nvs_len -= nvs_ptr - (u8 *)wl->nvs;
374 384
375 /* Now we must set the partition correctly */ 385 /* Now we must set the partition correctly */
@@ -385,6 +395,10 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
385 395
386 kfree(nvs_aligned); 396 kfree(nvs_aligned);
387 return 0; 397 return 0;
398
399out_badnvs:
400 wl1271_error("nvs data is malformed");
401 return -EILSEQ;
388} 402}
389 403
390static void wl1271_boot_enable_interrupts(struct wl1271 *wl) 404static void wl1271_boot_enable_interrupts(struct wl1271 *wl)