All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/9] virtio: console: fixes for bugs and races with unplug
@ 2013-07-25 13:58 Amit Shah
  2013-07-25 13:58 ` [PATCH v3 1/9] virtio: console: fix race with port unplug and open/close Amit Shah
                   ` (13 more replies)
  0 siblings, 14 replies; 23+ messages in thread
From: Amit Shah @ 2013-07-25 13:58 UTC (permalink / raw)
  To: Virtualization List; +Cc: Amit Shah

Hello,

This series fixes a few bugs and races with port unplug and the
various file operations: read(), write() and close().

I started coding up an alternative locking mechanism based on the
discussion earlier in this series, but some of what we already have
has to remain, and the new code is sufficiently different, so I'd
rather it bakes for a while, and I ensure there are no regressions wrt
the tests I have so far for a while as well.  Hopefully this will be
in time for the next merge window.

There's one use-after-free I spotted after sending the first two
versions: port_fops_release() calls send_control_msg(), which spins
till the host acknowledges receipt of the buffer.  While it's
spinning, if the device gets unplugged, the vqs go away, and the
spinning function never progresses, causing a softlockup.  This is
difficult to reproduce -- the host usually acknowledges the buffers
fast enough.  A couple of solutions for this case are possible:

1. Mark the control vq in use, and don't proceed with unplug till it's
   marked unused,
2. Similar to the various port-specific i and o vqs, don't spin, but
   queue the buffer and wait for the host to let us know it's done
   with it.

2nd is easier to implement, but 1st fits with the way I'm thinking of
restructuring the locking.  I'm not yet decided on which approach to
take, will think over it.

Other than that, this series does fix all the bugs I see with the
tests I have.  Indeed, the patches marked for stable@ fix all the bugs
too, and the other ones on top add locking where shared structures are
being used.

Please review and apply if appropriate,

v3
 * remove patch 5, "update private_data in struct file only on
   successful open" (Rusty)
 * remove patch 6, "fix race in port_fops_poll() and port unplug",
   (Rusty)
 * remove CC: stable from patches without reproducers

v2
 * add patch 11: Jason found a use-after-free in port unplug
 * patch 7 introduced a regression where the wake_up_interruptible was
   done before guest_connected and host_connected were set to false

Amit Shah (9):
  virtio: console: fix race with port unplug and open/close
  virtio: console: fix race in port_fops_open() and port unplug
  virtio: console: clean up port data immediately at time of unplug
  virtio: console: fix raising SIGIO after port unplug
  virtio: console: return -ENODEV on all read operations after unplug
  virtio: console: add locks around buffer removal in port unplug path
  virtio: console: add locking in port unplug path
  virtio: console: fix locking around send_sigio_to_port()
  virtio: console: prevent use-after-free of port name in port unplug

 drivers/char/virtio_console.c | 64 +++++++++++++++++++++++++++----------------
 1 file changed, 40 insertions(+), 24 deletions(-)

-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2013-08-02  8:39 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-25 13:58 [PATCH v3 0/9] virtio: console: fixes for bugs and races with unplug Amit Shah
2013-07-25 13:58 ` [PATCH v3 1/9] virtio: console: fix race with port unplug and open/close Amit Shah
2013-07-25 13:58 ` [PATCH v3 2/9] virtio: console: fix race in port_fops_open() and port unplug Amit Shah
2013-07-25 13:58 ` [PATCH v3 3/9] virtio: console: clean up port data immediately at time of unplug Amit Shah
2013-07-25 13:58 ` [PATCH v3 4/9] virtio: console: fix raising SIGIO after port unplug Amit Shah
2013-07-25 13:58 ` [PATCH v3 5/9] virtio: console: return -ENODEV on all read operations after unplug Amit Shah
2013-07-25 13:58 ` [PATCH v3 6/9] virtio: console: add locks around buffer removal in port unplug path Amit Shah
2013-07-29  4:53   ` Rusty Russell
2013-07-25 13:58 ` [PATCH v3 7/9] virtio: console: add locking " Amit Shah
2013-07-29  4:54   ` Rusty Russell
2013-07-25 13:58 ` [PATCH v3 8/9] virtio: console: fix locking around send_sigio_to_port() Amit Shah
2013-07-29  4:55   ` Rusty Russell
2013-07-25 13:58 ` [PATCH v3 9/9] virtio: console: prevent use-after-free of port name in port unplug Amit Shah
2013-07-29  4:56   ` Rusty Russell
2013-07-31  8:10     ` Amit Shah
2013-08-01  0:59       ` Rusty Russell
2013-08-02  8:39         ` Amit Shah
     [not found] ` <7ca111ad3bca069f921b4234e5b3ccbbfd7a11d8.1374759439.git.amit.shah@redhat.com>
2013-07-29  4:48   ` [PATCH v3 1/9] virtio: console: fix race with port unplug and open/close Rusty Russell
     [not found]   ` <87ob9m6kej.fsf@rustcorp.com.au>
2013-07-30  9:28     ` Amit Shah
     [not found] ` <d8ffeceebfc527db85406850d22fa3da64aabbe3.1374759439.git.amit.shah@redhat.com>
2013-07-29  4:50   ` [PATCH v3 3/9] virtio: console: clean up port data immediately at time of unplug Rusty Russell
     [not found] ` <a3aca79feb7163e08b940ddefceabf78ab4cd8ce.1374759439.git.amit.shah@redhat.com>
2013-07-29  4:50   ` [PATCH v3 2/9] virtio: console: fix race in port_fops_open() and port unplug Rusty Russell
     [not found] ` <e4199103bd85fae76ce7009d7d6abacf28f1f972.1374759439.git.amit.shah@redhat.com>
2013-07-29  4:51   ` [PATCH v3 4/9] virtio: console: fix raising SIGIO after " Rusty Russell
     [not found] ` <f218052d8d8438fea0d1c3483434e315c7e82db8.1374759439.git.amit.shah@redhat.com>
2013-07-29  4:53   ` [PATCH v3 5/9] virtio: console: return -ENODEV on all read operations after unplug Rusty Russell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.