]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
macvtap: Fix race between device delete and open.
authorVlad Yasevich <vyasevich@gmail.com>
Mon, 22 Sep 2014 20:34:17 +0000 (16:34 -0400)
committerJiri Slaby <jslaby@suse.cz>
Fri, 17 Oct 2014 07:43:17 +0000 (09:43 +0200)
commit34596a866103f99702a0fd2b89f25da063a886fa
tree8043342b710515939386bb7663c62c28889ef4c6
parent2a9e5d6b68e0d88843caeeb69944e17c632f8a73
macvtap: Fix race between device delete and open.

[ Upstream commit 40b8fe45d1f094e3babe7b2dc2b71557ab71401d ]

In macvtap device delete and open calls can race and
this causes a list curruption of the vlan queue_list.

The race intself is triggered by the idr accessors
that located the vlan device.  The device is stored
into and removed from the idr under both an rtnl and
a mutex.  However, when attempting to locate the device
in idr, only a mutex is taken.  As a result, once cpu
perfoming a delete may take an rtnl and wait for the mutex,
while another cput doing an open() will take the idr
mutex first to fetch the device pointer and later take
an rtnl to add a queue for the device which may have
just gotten deleted.

With this patch, we now hold the rtnl for the duration
of the macvtap_open() call thus making sure that
open will not race with delete.

CC: Michael S. Tsirkin <mst@redhat.com>
CC: Jason Wang <jasowang@redhat.com>
Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/net/macvtap.c