]>
Commit | Line | Data |
---|---|---|
6530a37c GKH |
1 | From f6efe96edd9c41c624c8f4ddbc4930c1a2d8f1e1 Mon Sep 17 00:00:00 2001 |
2 | From: Pontus Fuchs <pontus.fuchs@gmail.com> | |
3 | Date: Tue, 18 Oct 2011 09:23:42 +0200 | |
4 | Subject: wl12xx: Check buffer bound when processing nvs data | |
5 | ||
6 | From: Pontus Fuchs <pontus.fuchs@gmail.com> | |
7 | ||
8 | commit f6efe96edd9c41c624c8f4ddbc4930c1a2d8f1e1 upstream. | |
9 | ||
10 | An nvs with malformed contents could cause the processing of the | |
11 | calibration data to read beyond the end of the buffer. Prevent this | |
12 | from happening by adding bound checking. | |
13 | ||
14 | Signed-off-by: Pontus Fuchs <pontus.fuchs@gmail.com> | |
15 | Reviewed-by: Luciano Coelho <coelho@ti.com> | |
16 | Signed-off-by: Luciano Coelho <coelho@ti.com> | |
17 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
18 | ||
19 | --- | |
20 | drivers/net/wireless/wl12xx/boot.c | 14 ++++++++++++++ | |
21 | 1 file changed, 14 insertions(+) | |
22 | ||
23 | --- a/drivers/net/wireless/wl12xx/boot.c | |
24 | +++ b/drivers/net/wireless/wl12xx/boot.c | |
25 | @@ -358,6 +358,9 @@ static int wl1271_boot_upload_nvs(struct | |
26 | nvs_ptr += 3; | |
27 | ||
28 | for (i = 0; i < burst_len; i++) { | |
29 | + if (nvs_ptr + 3 >= (u8 *) wl->nvs + nvs_len) | |
30 | + goto out_badnvs; | |
31 | + | |
32 | val = (nvs_ptr[0] | (nvs_ptr[1] << 8) | |
33 | | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24)); | |
34 | ||
35 | @@ -369,6 +372,9 @@ static int wl1271_boot_upload_nvs(struct | |
36 | nvs_ptr += 4; | |
37 | dest_addr += 4; | |
38 | } | |
39 | + | |
40 | + if (nvs_ptr >= (u8 *) wl->nvs + nvs_len) | |
41 | + goto out_badnvs; | |
42 | } | |
43 | ||
44 | /* | |
45 | @@ -380,6 +386,10 @@ static int wl1271_boot_upload_nvs(struct | |
46 | */ | |
47 | nvs_ptr = (u8 *)wl->nvs + | |
48 | ALIGN(nvs_ptr - (u8 *)wl->nvs + 7, 4); | |
49 | + | |
50 | + if (nvs_ptr >= (u8 *) wl->nvs + nvs_len) | |
51 | + goto out_badnvs; | |
52 | + | |
53 | nvs_len -= nvs_ptr - (u8 *)wl->nvs; | |
54 | ||
55 | /* Now we must set the partition correctly */ | |
56 | @@ -395,6 +405,10 @@ static int wl1271_boot_upload_nvs(struct | |
57 | ||
58 | kfree(nvs_aligned); | |
59 | return 0; | |
60 | + | |
61 | +out_badnvs: | |
62 | + wl1271_error("nvs data is malformed"); | |
63 | + return -EILSEQ; | |
64 | } | |
65 | ||
66 | static void wl1271_boot_enable_interrupts(struct wl1271 *wl) |