Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 360e898f authored by Saket Saurabh's avatar Saket Saurabh
Browse files

hsic_sysmon_test: Add check for userspace buffer size count



hsic_sysmon_test local buffer size limit is 4096 bytes. If user space
tries to write data with size greater than 4096 bytes, memory corruption
would happen. Hence, add check for userspace buffer size count before
writing data from userspace buffer to hsic_sysmon_test local buffer.

CRs-Fixed: 547489
Change-Id: Ic54bf5309bf635ee1e5d6f33662b6dbdbffe440b
Signed-off-by: default avatarSaket Saurabh <ssaurabh@codeaurora.org>
parent 27c6afde
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -63,9 +63,13 @@ static ssize_t sysmon_test_write(struct file *file, const char __user *ubuf,
	if (!dev)
		return -ENODEV;

	/* Add check for user buf count greater than RD_BUF_SIZE */
	if (count > RD_BUF_SIZE)
		count = RD_BUF_SIZE;

	if (copy_from_user(dev->buf, ubuf, count)) {
		pr_err("error copying for writing");
		return 0;
		return -EFAULT;
	}

	ret = hsic_sysmon_write(id, dev->buf, count, 1000);