summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2010-09-14 09:56:16 +0200
committerRusty Russell <rusty@rustcorp.com.au>2010-09-21 03:24:01 +0200
commit65745422a898741ee0e7068ef06624ab06e8aefa (patch)
treeadee25ae37886d79f8319ce69673a75036423c28
parentvirtio: console: Fix poll blocking even though there is data to read (diff)
downloadlinux-65745422a898741ee0e7068ef06624ab06e8aefa.tar.xz
linux-65745422a898741ee0e7068ef06624ab06e8aefa.zip
virtio: console: Prevent userspace from submitting NULL buffers
A userspace could submit a buffer with 0 length to be written to the host. Prevent such a situation. This was not needed previously, but recent changes in the way write() works exposed this condition to trigger a virtqueue event to the host, causing a NULL buffer to be sent across. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> CC: stable@kernel.org
-rw-r--r--drivers/char/virtio_console.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 2f2e31b58b34..c810481a5bc2 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -596,6 +596,10 @@ static ssize_t port_fops_write(struct file *filp, const char __user *ubuf,
ssize_t ret;
bool nonblock;
+ /* Userspace could be out to fool us */
+ if (!count)
+ return 0;
+
port = filp->private_data;
nonblock = filp->f_flags & O_NONBLOCK;