diff options
author | Gabriel Krisman Bertazi <krisman@collabora.com> | 2020-03-16 20:45:06 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-04-23 10:30:19 +0200 |
commit | 1421615c646a43b905055a41a7ca62215f4662f9 (patch) | |
tree | c5ee081a3279cf28f743980c3499fc8c22f04bb2 /arch/um | |
parent | 6e2fa8b3b8d6cea619a850940b1b96fd208d44ae (diff) | |
download | linux-stable-1421615c646a43b905055a41a7ca62215f4662f9.tar.gz linux-stable-1421615c646a43b905055a41a7ca62215f4662f9.tar.bz2 linux-stable-1421615c646a43b905055a41a7ca62215f4662f9.zip |
um: ubd: Prevent buffer overrun on command completion
[ Upstream commit 6e682d53fc1ef73a169e2a5300326cb23abb32ee ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch/um')
-rw-r--r-- | arch/um/drivers/ubd_kern.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 83c470364dfb..748bd0921dff 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c @@ -1574,7 +1574,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; } else { |