* [PATCH] vhost: fix error handling in vring ioctls
@ 2010-03-17 14:42 Michael S. Tsirkin
2010-03-17 17:54 ` Laurent Chavey
0 siblings, 1 reply; 3+ messages in thread
From: Michael S. Tsirkin @ 2010-03-17 14:42 UTC (permalink / raw)
To: Michael S. Tsirkin, Jiri Slaby, kvm, virtualization, netdev,
linux-kernel
Stanse found a locking problem in vhost_set_vring:
several returns from VHOST_SET_VRING_KICK, VHOST_SET_VRING_CALL,
VHOST_SET_VRING_ERR with the vq->mutex held.
Fix these up.
Reported-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
drivers/vhost/vhost.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 7cd55e0..7bd7a1e 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -476,8 +476,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
if (r < 0)
break;
eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
- if (IS_ERR(eventfp))
- return PTR_ERR(eventfp);
+ if (IS_ERR(eventfp)) {
+ r = PTR_ERR(eventfp);
+ break;
+ }
if (eventfp != vq->kick) {
pollstop = filep = vq->kick;
pollstart = vq->kick = eventfp;
@@ -489,8 +491,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
if (r < 0)
break;
eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
- if (IS_ERR(eventfp))
- return PTR_ERR(eventfp);
+ if (IS_ERR(eventfp)) {
+ r = PTR_ERR(eventfp);
+ break;
+ }
if (eventfp != vq->call) {
filep = vq->call;
ctx = vq->call_ctx;
@@ -505,8 +509,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
if (r < 0)
break;
eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
- if (IS_ERR(eventfp))
- return PTR_ERR(eventfp);
+ if (IS_ERR(eventfp)) {
+ r = PTR_ERR(eventfp);
+ break;
+ }
if (eventfp != vq->error) {
filep = vq->error;
vq->error = eventfp;
--
1.7.0.18.g0d53a5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] vhost: fix error handling in vring ioctls
2010-03-17 14:42 [PATCH] vhost: fix error handling in vring ioctls Michael S. Tsirkin
@ 2010-03-17 17:54 ` Laurent Chavey
2010-03-17 18:40 ` Laurent Chavey
0 siblings, 1 reply; 3+ messages in thread
From: Laurent Chavey @ 2010-03-17 17:54 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Jiri Slaby, kvm, virtualization, netdev, linux-kernel
Acked-by: chavey@google.com
On Wed, Mar 17, 2010 at 7:42 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
> Stanse found a locking problem in vhost_set_vring:
> several returns from VHOST_SET_VRING_KICK, VHOST_SET_VRING_CALL,
> VHOST_SET_VRING_ERR with the vq->mutex held.
> Fix these up.
>
> Reported-by: Jiri Slaby <jirislaby@gmail.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> drivers/vhost/vhost.c | 18 ++++++++++++------
> 1 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index 7cd55e0..7bd7a1e 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -476,8 +476,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
> if (r < 0)
> break;
> eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
> - if (IS_ERR(eventfp))
> - return PTR_ERR(eventfp);
> + if (IS_ERR(eventfp)) {
> + r = PTR_ERR(eventfp);
> + break;
> + }
> if (eventfp != vq->kick) {
> pollstop = filep = vq->kick;
> pollstart = vq->kick = eventfp;
> @@ -489,8 +491,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
> if (r < 0)
> break;
> eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
> - if (IS_ERR(eventfp))
> - return PTR_ERR(eventfp);
> + if (IS_ERR(eventfp)) {
> + r = PTR_ERR(eventfp);
> + break;
> + }
> if (eventfp != vq->call) {
> filep = vq->call;
> ctx = vq->call_ctx;
> @@ -505,8 +509,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
> if (r < 0)
> break;
> eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
> - if (IS_ERR(eventfp))
> - return PTR_ERR(eventfp);
> + if (IS_ERR(eventfp)) {
> + r = PTR_ERR(eventfp);
> + break;
> + }
> if (eventfp != vq->error) {
> filep = vq->error;
> vq->error = eventfp;
> --
> 1.7.0.18.g0d53a5
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] vhost: fix error handling in vring ioctls
2010-03-17 17:54 ` Laurent Chavey
@ 2010-03-17 18:40 ` Laurent Chavey
0 siblings, 0 replies; 3+ messages in thread
From: Laurent Chavey @ 2010-03-17 18:40 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: Jiri Slaby, kvm, virtualization, netdev, linux-kernel
Acked-by: Laurent Chavey <chavey@google.com>
On Wed, Mar 17, 2010 at 10:54 AM, Laurent Chavey <chavey@google.com> wrote:
> Acked-by: chavey@google.com
>
>
> On Wed, Mar 17, 2010 at 7:42 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
>> Stanse found a locking problem in vhost_set_vring:
>> several returns from VHOST_SET_VRING_KICK, VHOST_SET_VRING_CALL,
>> VHOST_SET_VRING_ERR with the vq->mutex held.
>> Fix these up.
>>
>> Reported-by: Jiri Slaby <jirislaby@gmail.com>
>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>> ---
>> drivers/vhost/vhost.c | 18 ++++++++++++------
>> 1 files changed, 12 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
>> index 7cd55e0..7bd7a1e 100644
>> --- a/drivers/vhost/vhost.c
>> +++ b/drivers/vhost/vhost.c
>> @@ -476,8 +476,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
>> if (r < 0)
>> break;
>> eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
>> - if (IS_ERR(eventfp))
>> - return PTR_ERR(eventfp);
>> + if (IS_ERR(eventfp)) {
>> + r = PTR_ERR(eventfp);
>> + break;
>> + }
>> if (eventfp != vq->kick) {
>> pollstop = filep = vq->kick;
>> pollstart = vq->kick = eventfp;
>> @@ -489,8 +491,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
>> if (r < 0)
>> break;
>> eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
>> - if (IS_ERR(eventfp))
>> - return PTR_ERR(eventfp);
>> + if (IS_ERR(eventfp)) {
>> + r = PTR_ERR(eventfp);
>> + break;
>> + }
>> if (eventfp != vq->call) {
>> filep = vq->call;
>> ctx = vq->call_ctx;
>> @@ -505,8 +509,10 @@ static long vhost_set_vring(struct vhost_dev *d, int ioctl, void __user *argp)
>> if (r < 0)
>> break;
>> eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
>> - if (IS_ERR(eventfp))
>> - return PTR_ERR(eventfp);
>> + if (IS_ERR(eventfp)) {
>> + r = PTR_ERR(eventfp);
>> + break;
>> + }
>> if (eventfp != vq->error) {
>> filep = vq->error;
>> vq->error = eventfp;
>> --
>> 1.7.0.18.g0d53a5
>> --
>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-03-17 18:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-17 14:42 [PATCH] vhost: fix error handling in vring ioctls Michael S. Tsirkin
2010-03-17 17:54 ` Laurent Chavey
2010-03-17 18:40 ` Laurent Chavey
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.