diff mbox series

ath10k: add missing sanity check on diag download

Message ID 20180921204241.34316-1-briannorris@chromium.org (mailing list archive)
State New, archived
Headers show
Series ath10k: add missing sanity check on diag download | expand

Commit Message

Brian Norris Sept. 21, 2018, 8:42 p.m. UTC
ath10k_hw_diag_fast_download() generally has good boundary checking, but
it misses verifying that the next metadata header actually fits in the
remaining buffer space. Add such a check.

Fixes: 39501ea64116 ("ath10k: download firmware via diag Copy Engine for QCA6174 and QCA9377.")
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
 drivers/net/wireless/ath/ath10k/hw.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Kalle Valo Oct. 2, 2018, 4:50 a.m. UTC | #1
Brian Norris <briannorris@chromium.org> wrote:

> ath10k_hw_diag_fast_download() generally has good boundary checking, but
> it misses verifying that the next metadata header actually fits in the
> remaining buffer space. Add such a check.
> 
> Fixes: 39501ea64116 ("ath10k: download firmware via diag Copy Engine for QCA6174 and QCA9377.")
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

Patch applied to ath-next branch of ath.git, thanks.

e720ba1dcc33 ath10k: add missing sanity check on diag download
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath10k/hw.c b/drivers/net/wireless/ath/ath10k/hw.c
index 2c2870e3e84d..af8ae8117c62 100644
--- a/drivers/net/wireless/ath/ath10k/hw.c
+++ b/drivers/net/wireless/ath/ath10k/hw.c
@@ -1044,6 +1044,12 @@  int ath10k_hw_diag_fast_download(struct ath10k *ar,
 	left = length - sizeof(*hdr);
 
 	while (left > 0) {
+		if (left < sizeof(*metadata)) {
+			ath10k_warn(ar, "firmware segment is truncated: %d\n",
+				    left);
+			ret = -EINVAL;
+			break;
+		}
 		base_addr = __le32_to_cpu(metadata->addr);
 		base_len = __le32_to_cpu(metadata->length);
 		buf = metadata->data;