[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <02a62ea1b8b1083d79cb7c2d2c1cc17fe233248d.1493888632.git.jslaby@suse.cz>
Date: Thu, 4 May 2017 11:04:05 +0200
From: Jiri Slaby <jslaby@...e.cz>
To: stable@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, Omar Sandoval <osandov@...com>,
"Michael S . Tsirkin" <mst@...hat.com>,
Ben Hutchings <ben@...adent.org.uk>,
Brad Spengler <spender@...ecurity.net>,
Jiri Slaby <jslaby@...e.cz>
Subject: [PATCH 3.12 40/86] virtio-console: avoid DMA from stack
From: Omar Sandoval <osandov@...com>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit c4baad50297d84bde1a7ad45e50c73adae4a2192 upstream.
put_chars() stuffs the buffer it gets into an sg, but that buffer may be
on the stack. This breaks with CONFIG_VMAP_STACK=y (for me, it
manifested as printks getting turned into NUL bytes).
Signed-off-by: Omar Sandoval <osandov@...com>
Signed-off-by: Michael S. Tsirkin <mst@...hat.com>
Reviewed-by: Amit Shah <amit.shah@...hat.com>
Cc: Ben Hutchings <ben@...adent.org.uk>
Cc: Brad Spengler <spender@...ecurity.net>
Signed-off-by: Jiri Slaby <jslaby@...e.cz>
---
drivers/char/virtio_console.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 15a3ec940723..55d8b073cc61 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1130,6 +1130,8 @@ static int put_chars(u32 vtermno, const char *buf, int count)
{
struct port *port;
struct scatterlist sg[1];
+ void *data;
+ int ret;
if (unlikely(early_put_chars))
return early_put_chars(vtermno, buf, count);
@@ -1138,8 +1140,14 @@ static int put_chars(u32 vtermno, const char *buf, int count)
if (!port)
return -EPIPE;
- sg_init_one(sg, buf, count);
- return __send_to_port(port, sg, 1, count, (void *)buf, false);
+ data = kmemdup(buf, count, GFP_ATOMIC);
+ if (!data)
+ return -ENOMEM;
+
+ sg_init_one(sg, data, count);
+ ret = __send_to_port(port, sg, 1, count, data, false);
+ kfree(data);
+ return ret;
}
/*
--
2.12.2
Powered by blists - more mailing lists