Commit 6e682d53 authored by Gabriel Krisman Bertazi's avatar Gabriel Krisman Bertazi Committed by Richard Weinberger
Browse files

um: ubd: Prevent buffer overrun on command completion



On the hypervisor side, when completing commands and the pipe is full,
we retry writing only the entries that failed, by offsetting
io_req_buffer, but we don't reduce the number of bytes written, which
can cause a buffer overrun of io_req_buffer, and write garbage to the
pipe.

Cc: Martyn Welch <martyn.welch@collabora.com>
Signed-off-by: default avatarGabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent 598f5630
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1607,7 +1607,9 @@ int io_thread(void *arg)
		written = 0;

		do {
			res = os_write_file(kernel_fd, ((char *) io_req_buffer) + written, n);
			res = os_write_file(kernel_fd,
					    ((char *) io_req_buffer) + written,
					    n - written);
			if (res >= 0) {
				written += res;
			}