提交 67e0208a 编写于 作者: I Ido Yariv 提交者: John W. Linville

wl1271: Fix overflow in wl1271_boot_upload_nvs

Due to miscalculation of nvs_len, excessive data was sent to the
firmware.
Fix this by first setting nvs_ptr to point to the first NVS table,
and computing the total size of all NVS tables accordingly.
Signed-off-by: NIdo Yariv <ido@wizery.com>
Tested-By: NTuomas Katila <ext-tuomas.2.katila@nokia.com>
Acked-by: NLuciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 87fd2e6c
...@@ -274,11 +274,11 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl) ...@@ -274,11 +274,11 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
/* /*
* We've reached the first zero length, the first NVS table * We've reached the first zero length, the first NVS table
* is 7 bytes further. * is located at an aligned offset which is at least 7 bytes further.
*/ */
nvs_ptr += 7; nvs_ptr = (u8 *)wl->nvs->nvs +
ALIGN(nvs_ptr - (u8 *)wl->nvs->nvs + 7, 4);
nvs_len -= nvs_ptr - (u8 *)wl->nvs->nvs; nvs_len -= nvs_ptr - (u8 *)wl->nvs->nvs;
nvs_len = ALIGN(nvs_len, 4);
/* FIXME: The driver sets the partition here, but this is not needed, /* FIXME: The driver sets the partition here, but this is not needed,
since it sets to the same one as currently in use */ since it sets to the same one as currently in use */
...@@ -286,14 +286,9 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl) ...@@ -286,14 +286,9 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl)
wl1271_set_partition(wl, &part_table[PART_WORK]); wl1271_set_partition(wl, &part_table[PART_WORK]);
/* Copy the NVS tables to a new block to ensure alignment */ /* Copy the NVS tables to a new block to ensure alignment */
/* FIXME: We jump 3 more bytes before uploading the NVS. It seems nvs_aligned = kmemdup(nvs_ptr, nvs_len, GFP_KERNEL);
that our NVS files have three extra zeros here. I'm not sure whether if (!nvs_aligned)
the problem is in our NVS generation or we should really jumpt these return -ENOMEM;
3 bytes here */
nvs_ptr += 3;
nvs_aligned = kmemdup(nvs_ptr, nvs_len, GFP_KERNEL); if
(!nvs_aligned) return -ENOMEM;
/* And finally we upload the NVS tables */ /* And finally we upload the NVS tables */
/* FIXME: In wl1271, we upload everything at once. /* FIXME: In wl1271, we upload everything at once.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册