]> git.baikalelectronics.ru Git - kernel.git/commit
vhost: fix a theoretical race in device cleanup
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 13 Feb 2014 09:45:11 +0000 (11:45 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 13 Feb 2014 23:47:30 +0000 (18:47 -0500)
commit52a0abfdb3135d8415738128e0905dbd78cf7c65
tree328353448d8946ef639ed9c0d5be239e38058859
parent99a3084bc1887d02a8d85f0ae6e34aa98ddcc093
vhost: fix a theoretical race in device cleanup

vhost_zerocopy_callback accesses VQ right after it drops a ubuf
reference.  In theory, this could race with device removal which waits
on the ubuf kref, and crash on use after free.

Do all accesses within rcu read side critical section, and synchronize
on release.

Since callbacks are always invoked from bh, synchronize_rcu_bh seems
enough and will help release complete a bit faster.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/vhost/net.c