Re: [PATCH] HID: debug: check length before copy_to_user()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 02, 2018 at 04:59:37PM -0700, Daniel Rosenberg wrote:
> If our length is greater than the size of the buffer, we
> overflow the buffer

Hmm...

How about this:
	buf = list->hid_debug_buf;
	if (list->tail < list->head) {
		ret = simple_read_from_buffer(buffer, count, &list->head,
					buf, HID_DEBUG_BUFSIZE);
		if (ret < 0)
			break;
		if (list->head != buf + HID_DEBUG_BUFSIZE)
			break;
		list->head = 0;
	}
	n = simple_read_from_buffer(buffer + ret, count - ret, &list->head,
					buf, list->tail);
	if (n >= 0)
		ret += n;
	if (list->head == buf + HID_DEBUG_BUFSIZE)
		list->head = 0;
instead?
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux