search for: the_virtio_vsock_mutex

Displaying 20 results from an estimated 64 matches for "the_virtio_vsock_mutex".

2019 May 28
0
[PATCH 1/4] vsock/virtio: fix locking around 'the_virtio_vsock'
...port.c index 96ab344f17bb..d3ba7747aa73 100644 --- a/net/vmw_vsock/virtio_transport.c +++ b/net/vmw_vsock/virtio_transport.c @@ -68,7 +68,13 @@ struct virtio_vsock { static struct virtio_vsock *virtio_vsock_get(void) { - return the_virtio_vsock; + struct virtio_vsock *vsock; + + mutex_lock(&the_virtio_vsock_mutex); + vsock = the_virtio_vsock; + mutex_unlock(&the_virtio_vsock_mutex); + + return vsock; } static u32 virtio_transport_get_local_cid(void) @@ -592,7 +598,6 @@ static int virtio_vsock_probe(struct virtio_device *vdev) atomic_set(&vsock->queued_replies, 0); vdev->priv = vsock;...
2019 Jul 05
0
[PATCH v3 1/3] vsock/virtio: use RCU to avoid use-after-free on the_virtio_vsock
..._vsock_rx_fill(struct virtio_vsock *vsock) @@ -565,7 +581,8 @@ static int virtio_vsock_probe(struct virtio_device *vdev) return ret; /* Only one virtio-vsock device per guest is supported */ - if (the_virtio_vsock) { + if (rcu_dereference_protected(the_virtio_vsock, + lockdep_is_held(&the_virtio_vsock_mutex))) { ret = -EBUSY; goto out; } @@ -590,8 +607,6 @@ static int virtio_vsock_probe(struct virtio_device *vdev) vsock->rx_buf_max_nr = 0; atomic_set(&vsock->queued_replies, 0); - vdev->priv = vsock; - the_virtio_vsock = vsock; mutex_init(&vsock->tx_lock); mutex_in...
2019 May 28
8
[PATCH 0/4] vsock/virtio: several fixes in the .probe() and .remove()
During the review of "[PATCH] vsock/virtio: Initialize core virtio vsock before registering the driver", Stefan pointed out some possible issues in the .probe() and .remove() callbacks of the virtio-vsock driver. This series tries to solve these issues: - Patch 1 postpones the 'the_virtio_vsock' assignment at the end of the .probe() to avoid that some sockets queue works when
2019 May 28
8
[PATCH 0/4] vsock/virtio: several fixes in the .probe() and .remove()
During the review of "[PATCH] vsock/virtio: Initialize core virtio vsock before registering the driver", Stefan pointed out some possible issues in the .probe() and .remove() callbacks of the virtio-vsock driver. This series tries to solve these issues: - Patch 1 postpones the 'the_virtio_vsock' assignment at the end of the .probe() to avoid that some sockets queue works when
2019 May 29
2
[PATCH 3/4] vsock/virtio: fix flush of works during the .remove()
...t; + flush_work(&vsock->send_pkt_work); > +} > + > static void virtio_vsock_remove(struct virtio_device *vdev) > { > struct virtio_vsock *vsock = vdev->priv; > @@ -668,12 +677,6 @@ static void virtio_vsock_remove(struct virtio_device *vdev) > mutex_lock(&the_virtio_vsock_mutex); > the_virtio_vsock = NULL; > > - flush_work(&vsock->loopback_work); > - flush_work(&vsock->rx_work); > - flush_work(&vsock->tx_work); > - flush_work(&vsock->event_work); > - flush_work(&vsock->send_pkt_work); > - > /* Reset al...
2019 May 29
2
[PATCH 3/4] vsock/virtio: fix flush of works during the .remove()
...t; + flush_work(&vsock->send_pkt_work); > +} > + > static void virtio_vsock_remove(struct virtio_device *vdev) > { > struct virtio_vsock *vsock = vdev->priv; > @@ -668,12 +677,6 @@ static void virtio_vsock_remove(struct virtio_device *vdev) > mutex_lock(&the_virtio_vsock_mutex); > the_virtio_vsock = NULL; > > - flush_work(&vsock->loopback_work); > - flush_work(&vsock->rx_work); > - flush_work(&vsock->tx_work); > - flush_work(&vsock->event_work); > - flush_work(&vsock->send_pkt_work); > - > /* Reset al...
2019 Jun 28
0
[PATCH v2 1/3] vsock/virtio: use RCU to avoid use-after-free on the_virtio_vsock
..._lock); mutex_init(&vsock->event_lock); @@ -613,6 +627,9 @@ static int virtio_vsock_probe(struct virtio_device *vdev) virtio_vsock_event_fill(vsock); mutex_unlock(&vsock->event_lock); + vdev->priv = vsock; + rcu_assign_pointer(the_virtio_vsock, vsock); + mutex_unlock(&the_virtio_vsock_mutex); return 0; @@ -627,6 +644,12 @@ static void virtio_vsock_remove(struct virtio_device *vdev) struct virtio_vsock *vsock = vdev->priv; struct virtio_vsock_pkt *pkt; + mutex_lock(&the_virtio_vsock_mutex); + + vdev->priv = NULL; + rcu_assign_pointer(the_virtio_vsock, NULL); + synch...
2019 May 30
2
[PATCH 3/4] vsock/virtio: fix flush of works during the .remove()
...+} >>> + >>> static void virtio_vsock_remove(struct virtio_device *vdev) >>> { >>> struct virtio_vsock *vsock = vdev->priv; >>> @@ -668,12 +677,6 @@ static void virtio_vsock_remove(struct virtio_device *vdev) >>> mutex_lock(&the_virtio_vsock_mutex); >>> the_virtio_vsock = NULL; >>> - flush_work(&vsock->loopback_work); >>> - flush_work(&vsock->rx_work); >>> - flush_work(&vsock->tx_work); >>> - flush_work(&vsock->event_work); >>> - flush_work(&vsock->s...
2019 May 30
2
[PATCH 3/4] vsock/virtio: fix flush of works during the .remove()
...+} >>> + >>> static void virtio_vsock_remove(struct virtio_device *vdev) >>> { >>> struct virtio_vsock *vsock = vdev->priv; >>> @@ -668,12 +677,6 @@ static void virtio_vsock_remove(struct virtio_device *vdev) >>> mutex_lock(&the_virtio_vsock_mutex); >>> the_virtio_vsock = NULL; >>> - flush_work(&vsock->loopback_work); >>> - flush_work(&vsock->rx_work); >>> - flush_work(&vsock->tx_work); >>> - flush_work(&vsock->event_work); >>> - flush_work(&vsock->s...
2019 Jul 03
3
[PATCH v2 1/3] vsock/virtio: use RCU to avoid use-after-free on the_virtio_vsock
...mutex_unlock(&vsock->event_lock); > > + vdev->priv = vsock; > + rcu_assign_pointer(the_virtio_vsock, vsock); You probably need to use rcu_dereference_protected() to access the_virtio_vsock in the function in order to survive from sparse. > + > mutex_unlock(&the_virtio_vsock_mutex); > return 0; > > @@ -627,6 +644,12 @@ static void virtio_vsock_remove(struct virtio_device *vdev) > struct virtio_vsock *vsock = vdev->priv; > struct virtio_vsock_pkt *pkt; > > + mutex_lock(&the_virtio_vsock_mutex); > + > + vdev->priv = NULL; &gt...
2019 Jul 03
3
[PATCH v2 1/3] vsock/virtio: use RCU to avoid use-after-free on the_virtio_vsock
...mutex_unlock(&vsock->event_lock); > > + vdev->priv = vsock; > + rcu_assign_pointer(the_virtio_vsock, vsock); You probably need to use rcu_dereference_protected() to access the_virtio_vsock in the function in order to survive from sparse. > + > mutex_unlock(&the_virtio_vsock_mutex); > return 0; > > @@ -627,6 +644,12 @@ static void virtio_vsock_remove(struct virtio_device *vdev) > struct virtio_vsock *vsock = vdev->priv; > struct virtio_vsock_pkt *pkt; > > + mutex_lock(&the_virtio_vsock_mutex); > + > + vdev->priv = NULL; &gt...
2019 May 30
1
[PATCH 1/4] vsock/virtio: fix locking around 'the_virtio_vsock'
...ano Garzarella <sgarzare at redhat.com> Date: Tue, 28 May 2019 12:56:20 +0200 > @@ -68,7 +68,13 @@ struct virtio_vsock { > > static struct virtio_vsock *virtio_vsock_get(void) > { > - return the_virtio_vsock; > + struct virtio_vsock *vsock; > + > + mutex_lock(&the_virtio_vsock_mutex); > + vsock = the_virtio_vsock; > + mutex_unlock(&the_virtio_vsock_mutex); > + > + return vsock; This doesn't do anything as far as I can tell. No matter what, you will either get the value before it's changed or after it's changed. Since you should never publish the...
2019 Jul 05
4
[PATCH v3 0/3] vsock/virtio: several fixes in the .probe() and .remove()
During the review of "[PATCH] vsock/virtio: Initialize core virtio vsock before registering the driver", Stefan pointed out some possible issues in the .probe() and .remove() callbacks of the virtio-vsock driver. This series tries to solve these issues: - Patch 1 adds RCU critical sections to avoid use-after-free of 'the_virtio_vsock' pointer. - Patch 2 stops workers before to
2019 May 30
2
[PATCH 3/4] vsock/virtio: fix flush of works during the .remove()
...tatic void virtio_vsock_remove(struct virtio_device *vdev) >>>>> { >>>>> struct virtio_vsock *vsock = vdev->priv; >>>>> @@ -668,12 +677,6 @@ static void virtio_vsock_remove(struct virtio_device *vdev) >>>>> mutex_lock(&the_virtio_vsock_mutex); >>>>> the_virtio_vsock = NULL; >>>>> - flush_work(&vsock->loopback_work); >>>>> - flush_work(&vsock->rx_work); >>>>> - flush_work(&vsock->tx_work); >>>>> - flush_work(&vsock->event_work); &...
2019 May 30
2
[PATCH 3/4] vsock/virtio: fix flush of works during the .remove()
...tatic void virtio_vsock_remove(struct virtio_device *vdev) >>>>> { >>>>> struct virtio_vsock *vsock = vdev->priv; >>>>> @@ -668,12 +677,6 @@ static void virtio_vsock_remove(struct virtio_device *vdev) >>>>> mutex_lock(&the_virtio_vsock_mutex); >>>>> the_virtio_vsock = NULL; >>>>> - flush_work(&vsock->loopback_work); >>>>> - flush_work(&vsock->rx_work); >>>>> - flush_work(&vsock->tx_work); >>>>> - flush_work(&vsock->event_work); &...
2019 Jun 28
11
[PATCH v2 0/3] vsock/virtio: several fixes in the .probe() and .remove()
During the review of "[PATCH] vsock/virtio: Initialize core virtio vsock before registering the driver", Stefan pointed out some possible issues in the .probe() and .remove() callbacks of the virtio-vsock driver. This series tries to solve these issues: - Patch 1 adds RCU critical sections to avoid use-after-free of 'the_virtio_vsock' pointer. - Patch 2 stops workers before to
2019 Jun 28
11
[PATCH v2 0/3] vsock/virtio: several fixes in the .probe() and .remove()
During the review of "[PATCH] vsock/virtio: Initialize core virtio vsock before registering the driver", Stefan pointed out some possible issues in the .probe() and .remove() callbacks of the virtio-vsock driver. This series tries to solve these issues: - Patch 1 adds RCU critical sections to avoid use-after-free of 'the_virtio_vsock' pointer. - Patch 2 stops workers before to
2019 Feb 01
3
[PATCH v3 0/2] vsock/virtio: fix issues on device hot-unplug
These patches try to handle the hot-unplug of vsock virtio transport device in a proper way. Maybe move the vsock_core_init()/vsock_core_exit() functions in the module_init and module_exit of vsock_virtio_transport module can't be the best way, but the architecture of vsock_core forces us to this approach for now. The vsock_core proto_ops expect a valid pointer to the transport device, so we
2019 Feb 01
3
[PATCH v3 0/2] vsock/virtio: fix issues on device hot-unplug
These patches try to handle the hot-unplug of vsock virtio transport device in a proper way. Maybe move the vsock_core_init()/vsock_core_exit() functions in the module_init and module_exit of vsock_virtio_transport module can't be the best way, but the architecture of vsock_core forces us to this approach for now. The vsock_core proto_ops expect a valid pointer to the transport device, so we
2015 Dec 09
0
[PATCH v3 2/4] VSOCK: Introduce virtio-vsock.ko
...+#include <linux/virtio_config.h> +#include <linux/virtio_vsock.h> +#include <net/sock.h> +#include <linux/mutex.h> +#include <net/af_vsock.h> + +static struct workqueue_struct *virtio_vsock_workqueue; +static struct virtio_vsock *the_virtio_vsock; +static DEFINE_MUTEX(the_virtio_vsock_mutex); /* protects the_virtio_vsock */ +static void virtio_vsock_rx_fill(struct virtio_vsock *vsock); + +struct virtio_vsock { + /* Virtio device */ + struct virtio_device *vdev; + /* Virtio virtqueue */ + struct virtqueue *vqs[VSOCK_VQ_MAX]; + /* Wait queue for send pkt */ + wait_queue_head_t queue_wai...