ath10k: fix information leak in debugfs
authorVenkateswara Naralasetty <vnaralas@codeaurora.org>
Wed, 25 Apr 2018 08:36:40 +0000 (11:36 +0300)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 27 Apr 2018 11:24:25 +0000 (14:24 +0300)
During write to some of debugfs in ath10k, few variables exposing stack
data when process user input. which leads to possible information leak.

This patch fix this issue by initializing buffer and checks
the return valure of 'simple_write_to_buffer'.

Signed-off-by: Venkateswara Naralasetty <vnaralas@codeaurora.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/ath/ath10k/debug.c
drivers/net/wireless/ath/ath10k/debugfs_sta.c

index bac832ce1873f9958cb2ef36168104a08d7b482a..57d22cd976e5d5a62810b2a58ffe039ae06a729e 100644 (file)
@@ -987,13 +987,13 @@ static ssize_t ath10k_write_htt_max_amsdu_ampdu(struct file *file,
 {
        struct ath10k *ar = file->private_data;
        int res;
-       char buf[64];
+       char buf[64] = {0};
        unsigned int amsdu, ampdu;
 
-       simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
-
-       /* make sure that buf is null terminated */
-       buf[sizeof(buf) - 1] = 0;
+       res = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
+                                    user_buf, count);
+       if (res <= 0)
+               return res;
 
        res = sscanf(buf, "%u %u", &amsdu, &ampdu);
 
@@ -1043,14 +1043,14 @@ static ssize_t ath10k_write_fw_dbglog(struct file *file,
 {
        struct ath10k *ar = file->private_data;
        int ret;
-       char buf[96];
+       char buf[96] = {0};
        unsigned int log_level;
        u64 mask;
 
-       simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
-
-       /* make sure that buf is null terminated */
-       buf[sizeof(buf) - 1] = 0;
+       ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
+                                    user_buf, count);
+       if (ret <= 0)
+               return ret;
 
        ret = sscanf(buf, "%llx %u", &mask, &log_level);
 
index 8f688f136c225259c16f844c91b459c37506a577..a63c97e2c50c5d29915b334d2937eca5b3892601 100644 (file)
@@ -254,12 +254,12 @@ static ssize_t ath10k_dbg_sta_write_addba(struct file *file,
        struct ath10k *ar = arsta->arvif->ar;
        u32 tid, buf_size;
        int ret;
-       char buf[64];
+       char buf[64] = {0};
 
-       simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
-
-       /* make sure that buf is null terminated */
-       buf[sizeof(buf) - 1] = '\0';
+       ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
+                                    user_buf, count);
+       if (ret <= 0)
+               return ret;
 
        ret = sscanf(buf, "%u %u", &tid, &buf_size);
        if (ret != 2)
@@ -305,12 +305,12 @@ static ssize_t ath10k_dbg_sta_write_addba_resp(struct file *file,
        struct ath10k *ar = arsta->arvif->ar;
        u32 tid, status;
        int ret;
-       char buf[64];
-
-       simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
+       char buf[64] = {0};
 
-       /* make sure that buf is null terminated */
-       buf[sizeof(buf) - 1] = '\0';
+       ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
+                                    user_buf, count);
+       if (ret <= 0)
+               return ret;
 
        ret = sscanf(buf, "%u %u", &tid, &status);
        if (ret != 2)
@@ -355,12 +355,12 @@ static ssize_t ath10k_dbg_sta_write_delba(struct file *file,
        struct ath10k *ar = arsta->arvif->ar;
        u32 tid, initiator, reason;
        int ret;
-       char buf[64];
-
-       simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
+       char buf[64] = {0};
 
-       /* make sure that buf is null terminated */
-       buf[sizeof(buf) - 1] = '\0';
+       ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
+                                    user_buf, count);
+       if (ret <= 0)
+               return ret;
 
        ret = sscanf(buf, "%u %u %u", &tid, &initiator, &reason);
        if (ret != 3)