]> git.baikalelectronics.ru Git - kernel.git/commitdiff
habanalabs: prevent user buff overflow
authorMoti Haimovski <mhaimovski@habana.ai>
Wed, 19 Aug 2020 14:40:33 +0000 (17:40 +0300)
committerOded Gabbay <oded.gabbay@gmail.com>
Mon, 31 Aug 2020 12:10:27 +0000 (15:10 +0300)
This commit fixes a potential debugfs issue that may occur when
reading the clock gating mask into the user buffer since the
user buffer size was not taken into consideration.

Signed-off-by: Moti Haimovski <mhaimovski@habana.ai>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
drivers/misc/habanalabs/common/debugfs.c

index 37701e4f9d5afffb32417fee3824d92dcca82dcb..aa77771635d33fca449c13e8bc7cde97315a3130 100644 (file)
@@ -982,7 +982,7 @@ static ssize_t hl_clk_gate_read(struct file *f, char __user *buf,
                return 0;
 
        sprintf(tmp_buf, "0x%llx\n", hdev->clock_gating_mask);
-       rc = simple_read_from_buffer(buf, strlen(tmp_buf) + 1, ppos, tmp_buf,
+       rc = simple_read_from_buffer(buf, count, ppos, tmp_buf,
                        strlen(tmp_buf) + 1);
 
        return rc;