From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Amit Shah <amit.shah@redhat.com>,
Rusty Russell <rusty@rustcorp.com.au>
Subject: [ 06/12] virtio: console: return -ENODEV on all read operations after unplug
Date: Mon, 12 Aug 2013 23:35:41 -0700 [thread overview]
Message-ID: <20130813063520.771021769@linuxfoundation.org> (raw)
In-Reply-To: <20130813063520.285638946@linuxfoundation.org>
3.0-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amit Shah <amit.shah@redhat.com>
commit 96f97a83910cdb9d89d127c5ee523f8fc040a804 upstream.
If a port gets unplugged while a user is blocked on read(), -ENODEV is
returned. However, subsequent read()s returned 0, indicating there's no
host-side connection (but not indicating the device went away).
This also happened when a port was unplugged and the user didn't have
any blocking operation pending. If the user didn't monitor the SIGIO
signal, they won't have a chance to find out if the port went away.
Fix by returning -ENODEV on all read()s after the port gets unplugged.
write() already behaves this way.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/char/virtio_console.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -625,6 +625,10 @@ static ssize_t port_fops_read(struct fil
port = filp->private_data;
+ /* Port is hot-unplugged. */
+ if (!port->guest_connected)
+ return -ENODEV;
+
if (!port_has_data(port)) {
/*
* If nothing's connected on the host just return 0 in
@@ -641,7 +645,7 @@ static ssize_t port_fops_read(struct fil
if (ret < 0)
return ret;
}
- /* Port got hot-unplugged. */
+ /* Port got hot-unplugged while we were waiting above. */
if (!port->guest_connected)
return -ENODEV;
/*
next prev parent reply other threads:[~2013-08-13 6:41 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-13 6:35 [ 00/12] 3.0.91-stable review Greg Kroah-Hartman
2013-08-13 6:35 ` [ 01/12] hwmon: (adt7470) Fix incorrect return code check Greg Kroah-Hartman
2013-08-13 6:35 ` [ 02/12] virtio: console: fix race with port unplug and open/close Greg Kroah-Hartman
2013-08-13 6:35 ` [ 03/12] virtio: console: fix race in port_fops_open() and port unplug Greg Kroah-Hartman
2013-08-13 6:35 ` [ 04/12] virtio: console: clean up port data immediately at time of unplug Greg Kroah-Hartman
2013-08-13 6:35 ` [ 05/12] virtio: console: fix raising SIGIO after port unplug Greg Kroah-Hartman
2013-08-13 6:35 ` Greg Kroah-Hartman [this message]
2013-08-13 6:35 ` [ 07/12] debugfs: debugfs_remove_recursive() must not rely on list_empty(d_subdirs) Greg Kroah-Hartman
2013-08-13 6:35 ` [ 08/12] cifs: silence compiler warnings showing up with gcc-4.7.0 Greg Kroah-Hartman
2013-08-13 6:35 ` [ 09/12] tracing: Fix fields of struct trace_iterator that are zeroed by mistake Greg Kroah-Hartman
2013-08-13 6:35 ` [ 10/12] SCSI: nsp32: use mdelay instead of large udelay constants Greg Kroah-Hartman
2013-08-13 6:35 ` [ 11/12] vfs: d_obtain_alias() needs to use "/" as default name Greg Kroah-Hartman
2013-08-13 6:35 ` [ 12/12] perf tools: Add anonymous huge page recognition Greg Kroah-Hartman
2013-08-13 11:46 ` [ 00/12] 3.0.91-stable review Guenter Roeck
2013-08-13 17:59 ` Greg Kroah-Hartman
2013-08-13 17:19 ` Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130813063520.771021769@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=amit.shah@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox