wil6210: missing length check in wmi_set_ie
authorLior David <qca_liord@qca.qualcomm.com>
Tue, 14 Nov 2017 13:25:39 +0000 (15:25 +0200)
committerKalle Valo <kvalo@qca.qualcomm.com>
Sat, 2 Dec 2017 14:18:42 +0000 (16:18 +0200)
Add a length check in wmi_set_ie to detect unsigned integer
overflow.

Signed-off-by: Lior David <qca_liord@qca.qualcomm.com>
Signed-off-by: Maya Erez <qca_merez@qca.qualcomm.com>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
drivers/net/wireless/ath/wil6210/wmi.c

index 16aa624a986acc81f9865d9a2fb060bc81c77bcb..dd25f6369ce34aeff576f25206b8ab7107b8611d 100644 (file)
@@ -1616,8 +1616,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;