]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.1.9/wl12xx-check-buffer-bound-when-processing-nvs-data.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.1.9 / wl12xx-check-buffer-bound-when-processing-nvs-data.patch
CommitLineData
6530a37c
GKH
1From f6efe96edd9c41c624c8f4ddbc4930c1a2d8f1e1 Mon Sep 17 00:00:00 2001
2From: Pontus Fuchs <pontus.fuchs@gmail.com>
3Date: Tue, 18 Oct 2011 09:23:42 +0200
4Subject: wl12xx: Check buffer bound when processing nvs data
5
6From: Pontus Fuchs <pontus.fuchs@gmail.com>
7
8commit f6efe96edd9c41c624c8f4ddbc4930c1a2d8f1e1 upstream.
9
10An nvs with malformed contents could cause the processing of the
11calibration data to read beyond the end of the buffer. Prevent this
12from happening by adding bound checking.
13
14Signed-off-by: Pontus Fuchs <pontus.fuchs@gmail.com>
15Reviewed-by: Luciano Coelho <coelho@ti.com>
16Signed-off-by: Luciano Coelho <coelho@ti.com>
17Signed-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)