Skip to content

Commit 6e682d5

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: Gabriel Krisman Bertazi <krisman@collabora.com> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent 598f563 commit 6e682d5

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎arch/um/drivers/ubd_kern.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,9 @@ int io_thread(void *arg)
16071607
written = 0;
16081608

16091609
do {
1610-
res = os_write_file(kernel_fd, ((char *) io_req_buffer) + written, n);
1610+
res = os_write_file(kernel_fd,
1611+
((char *) io_req_buffer) + written,
1612+
n - written);
16111613
if (res >= 0) {
16121614
written += res;
16131615
}

0 commit comments

Comments
 (0)