]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/bnxt_re: Fix buffer overflow in debugfs code
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 7 Feb 2025 09:16:19 +0000 (12:16 +0300)
committerLeon Romanovsky <leon@kernel.org>
Sun, 9 Feb 2025 09:58:22 +0000 (04:58 -0500)
Add some bounds checking to prevent memory corruption in
bnxt_re_cc_config_set().  This is debugfs code so the bug can only be
triggered by root.

Fixes: 656dff55da19 ("RDMA/bnxt_re: Congestion control settings using debugfs hook")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://patch.msgid.link/a6b081ab-55fe-4d0c-8f69-c5e5a59e9141@stanley.mountain
Acked-by: Selvin Xavier <selvin.xavier@broadcom.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/bnxt_re/debugfs.c

index f4dd2fb51867d15a337475a7ecdecbb6b5ec7e65..d7354e7753fe389b24ebe335adb2f8ca0b63f09c 100644 (file)
@@ -285,6 +285,9 @@ static ssize_t bnxt_re_cc_config_set(struct file *filp, const char __user *buffe
        u32 val;
        int rc;
 
+       if (count >= sizeof(buf))
+               return -EINVAL;
+
        if (copy_from_user(buf, buffer, count))
                return -EFAULT;