4.14-stable review patch.  If anyone has any objections, please let me know.

------------------

commit b5a8ffcae4103a9d823ea3aa3a761f65779fbe2a upstream.

Add a length check in wmi_set_ie to detect unsigned integer
overflow.

Signed-off-by: Lior David <qca_li...@qca.qualcomm.com>
Signed-off-by: Maya Erez <qca_me...@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kv...@qca.qualcomm.com>
Signed-off-by: Ben Hutchings <ben.hutchi...@codethink.co.uk>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---
 drivers/net/wireless/ath/wil6210/wmi.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/wil6210/wmi.c 
b/drivers/net/wireless/ath/wil6210/wmi.c
index ffdd2fa401b1..d63d7c326801 100644
--- a/drivers/net/wireless/ath/wil6210/wmi.c
+++ b/drivers/net/wireless/ath/wil6210/wmi.c
@@ -1380,8 +1380,14 @@ int wmi_set_ie(struct wil6210_priv *wil, u8 type, u16 
ie_len, const void *ie)
        };
        int rc;
        u16 len = sizeof(struct wmi_set_appie_cmd) + ie_len;
-       struct wmi_set_appie_cmd *cmd = kzalloc(len, GFP_KERNEL);
+       struct wmi_set_appie_cmd *cmd;
 
+       if (len < ie_len) {
+               rc = -EINVAL;
+               goto out;
+       }
+
+       cmd = kzalloc(len, GFP_KERNEL);
        if (!cmd) {
                rc = -ENOMEM;
                goto out;
-- 
2.17.1



Reply via email to