wifi: ath12k: Fix buffer overflow in debugfs
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 9 Apr 2025 11:01:25 +0000 (14:01 +0300)
committerJeff Johnson <jeff.johnson@oss.qualcomm.com>
Sat, 12 Apr 2025 04:19:29 +0000 (21:19 -0700)
If the user tries to write more than 32 bytes then it results in memory
corruption.  Fortunately, this is debugfs so it's limited to root users.

Fixes: 3f73c24f28b3 ("wifi: ath12k: Add support to enable debugfs_htt_stats")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com>
Link: https://patch.msgid.link/35daefbd-d493-41d9-b192-96177d521b40@stanley.mountain
Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
drivers/net/wireless/ath/ath12k/debugfs_htt_stats.c

index 1c0d5fa39a8dcbd8861628efb4c12808b2edf44c..aeaf970339d4dc41b06b6836950d7118b030e7ca 100644 (file)
@@ -5377,6 +5377,9 @@ static ssize_t ath12k_write_htt_stats_type(struct file *file,
        const int size = 32;
        int num_args;
 
+       if (count > size)
+               return -EINVAL;
+
        char *buf __free(kfree) = kzalloc(size, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;