* [PATCH] virtio: fix oops on OOM
@ 2010-07-23 6:18 Rusty Russell
2010-07-23 14:52 ` [stable] " Chuck Ebbert
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Rusty Russell @ 2010-07-23 6:18 UTC (permalink / raw)
To: Linus Torvalds
Cc: virtualization, linux-kernel, Michael S. Tsirkin, Chris Mason
From: "Michael S. Tsirkin" <mst@redhat.com>
virtio ring was changed to return an error code on OOM,
but one caller was missed and still checks for vq->vring.num.
The fix is just to check for <0 error code.
Long term it might make sense to change goto add_head to
just return an error on oom instead, but let's apply
a minimal fix for 2.6.35.
Reported-by: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Tested-by: Chris Mason <chris.mason@oracle.com>
---
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index dd35b34..bffec32 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -164,7 +164,8 @@ int virtqueue_add_buf_gfp(struct virtqueue *_vq,
gfp_t gfp)
{
struct vring_virtqueue *vq = to_vvq(_vq);
- unsigned int i, avail, head, uninitialized_var(prev);
+ unsigned int i, avail, uninitialized_var(prev);
+ int head;
START_USE(vq);
@@ -174,8 +175,8 @@ int virtqueue_add_buf_gfp(struct virtqueue *_vq,
* buffers, then go indirect. FIXME: tune this threshold */
if (vq->indirect && (out + in) > 1 && vq->num_free) {
head = vring_add_indirect(vq, sg, out, in, gfp);
- if (head != vq->vring.num)
+ if (likely(head >= 0))
goto add_head;
}
BUG_ON(out + in > vq->vring.num);
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [stable] [PATCH] virtio: fix oops on OOM
2010-07-23 6:18 [PATCH] virtio: fix oops on OOM Rusty Russell
2010-07-23 14:52 ` [stable] " Chuck Ebbert
@ 2010-07-23 14:52 ` Chuck Ebbert
2010-07-26 7:25 ` Rusty Russell
2010-07-26 7:25 ` Rusty Russell
3 siblings, 0 replies; 5+ messages in thread
From: Chuck Ebbert @ 2010-07-23 14:52 UTC (permalink / raw)
To: Rusty Russell
Cc: Linus Torvalds, virtualization, linux-kernel, Michael S. Tsirkin,
Chris Mason, stable
On Fri, 23 Jul 2010 15:48:37 +0930
Rusty Russell <rusty@rustcorp.com.au> wrote:
Note that commit 686d363786a53ed28ee875b84ef24e6d5126ef6f,
which caused this problem, is already queued for -stable,
so it should either be removed or this should be sent for
-stable as well.
> From: "Michael S. Tsirkin" <mst@redhat.com>
>
> virtio ring was changed to return an error code on OOM,
> but one caller was missed and still checks for vq->vring.num.
> The fix is just to check for <0 error code.
>
> Long term it might make sense to change goto add_head to
> just return an error on oom instead, but let's apply
> a minimal fix for 2.6.35.
>
> Reported-by: Chris Mason <chris.mason@oracle.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> Tested-by: Chris Mason <chris.mason@oracle.com>
> ---
>
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index dd35b34..bffec32 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -164,7 +164,8 @@ int virtqueue_add_buf_gfp(struct virtqueue *_vq,
> gfp_t gfp)
> {
> struct vring_virtqueue *vq = to_vvq(_vq);
> - unsigned int i, avail, head, uninitialized_var(prev);
> + unsigned int i, avail, uninitialized_var(prev);
> + int head;
>
> START_USE(vq);
>
> @@ -174,8 +175,8 @@ int virtqueue_add_buf_gfp(struct virtqueue *_vq,
> * buffers, then go indirect. FIXME: tune this threshold */
> if (vq->indirect && (out + in) > 1 && vq->num_free) {
> head = vring_add_indirect(vq, sg, out, in, gfp);
> - if (head != vq->vring.num)
> + if (likely(head >= 0))
> goto add_head;
> }
>
> BUG_ON(out + in > vq->vring.num);
> --
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [stable] [PATCH] virtio: fix oops on OOM
2010-07-23 6:18 [PATCH] virtio: fix oops on OOM Rusty Russell
@ 2010-07-23 14:52 ` Chuck Ebbert
2010-07-23 14:52 ` Chuck Ebbert
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Chuck Ebbert @ 2010-07-23 14:52 UTC (permalink / raw)
To: Rusty Russell
Cc: Michael S. Tsirkin, linux-kernel, virtualization, Linus Torvalds,
stable, Chris Mason
On Fri, 23 Jul 2010 15:48:37 +0930
Rusty Russell <rusty@rustcorp.com.au> wrote:
Note that commit 686d363786a53ed28ee875b84ef24e6d5126ef6f,
which caused this problem, is already queued for -stable,
so it should either be removed or this should be sent for
-stable as well.
> From: "Michael S. Tsirkin" <mst@redhat.com>
>
> virtio ring was changed to return an error code on OOM,
> but one caller was missed and still checks for vq->vring.num.
> The fix is just to check for <0 error code.
>
> Long term it might make sense to change goto add_head to
> just return an error on oom instead, but let's apply
> a minimal fix for 2.6.35.
>
> Reported-by: Chris Mason <chris.mason@oracle.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> Tested-by: Chris Mason <chris.mason@oracle.com>
> ---
>
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index dd35b34..bffec32 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -164,7 +164,8 @@ int virtqueue_add_buf_gfp(struct virtqueue *_vq,
> gfp_t gfp)
> {
> struct vring_virtqueue *vq = to_vvq(_vq);
> - unsigned int i, avail, head, uninitialized_var(prev);
> + unsigned int i, avail, uninitialized_var(prev);
> + int head;
>
> START_USE(vq);
>
> @@ -174,8 +175,8 @@ int virtqueue_add_buf_gfp(struct virtqueue *_vq,
> * buffers, then go indirect. FIXME: tune this threshold */
> if (vq->indirect && (out + in) > 1 && vq->num_free) {
> head = vring_add_indirect(vq, sg, out, in, gfp);
> - if (head != vq->vring.num)
> + if (likely(head >= 0))
> goto add_head;
> }
>
> BUG_ON(out + in > vq->vring.num);
> --
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] virtio: fix oops on OOM
2010-07-23 6:18 [PATCH] virtio: fix oops on OOM Rusty Russell
2010-07-23 14:52 ` [stable] " Chuck Ebbert
2010-07-23 14:52 ` Chuck Ebbert
@ 2010-07-26 7:25 ` Rusty Russell
2010-07-26 7:25 ` Rusty Russell
3 siblings, 0 replies; 5+ messages in thread
From: Rusty Russell @ 2010-07-26 7:25 UTC (permalink / raw)
To: virtualization
Cc: Linus Torvalds, Michael S. Tsirkin, linux-kernel, Chris Mason
From: "Michael S. Tsirkin" <mst@redhat.com>
virtio ring was changed to return an error code on OOM,
but one caller was missed and still checks for vq->vring.num.
The fix is just to check for <0 error code.
Long term it might make sense to change goto add_head to
just return an error on oom instead, but let's apply
a minimal fix for 2.6.35.
Reported-by: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Tested-by: Chris Mason <chris.mason@oracle.com>
Cc: stable@kernel.org # .34.x
---
drivers/virtio/virtio_ring.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index dd35b34..bffec32 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -164,7 +164,8 @@ int virtqueue_add_buf_gfp(struct virtqueue *_vq,
gfp_t gfp)
{
struct vring_virtqueue *vq = to_vvq(_vq);
- unsigned int i, avail, head, uninitialized_var(prev);
+ unsigned int i, avail, uninitialized_var(prev);
+ int head;
START_USE(vq);
@@ -174,8 +175,8 @@ int virtqueue_add_buf_gfp(struct virtqueue *_vq,
* buffers, then go indirect. FIXME: tune this threshold */
if (vq->indirect && (out + in) > 1 && vq->num_free) {
head = vring_add_indirect(vq, sg, out, in, gfp);
- if (head != vq->vring.num)
+ if (likely(head >= 0))
goto add_head;
}
BUG_ON(out + in > vq->vring.num);
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] virtio: fix oops on OOM
2010-07-23 6:18 [PATCH] virtio: fix oops on OOM Rusty Russell
` (2 preceding siblings ...)
2010-07-26 7:25 ` Rusty Russell
@ 2010-07-26 7:25 ` Rusty Russell
3 siblings, 0 replies; 5+ messages in thread
From: Rusty Russell @ 2010-07-26 7:25 UTC (permalink / raw)
To: virtualization
Cc: Linus Torvalds, linux-kernel, Chris Mason, Michael S. Tsirkin
From: "Michael S. Tsirkin" <mst@redhat.com>
virtio ring was changed to return an error code on OOM,
but one caller was missed and still checks for vq->vring.num.
The fix is just to check for <0 error code.
Long term it might make sense to change goto add_head to
just return an error on oom instead, but let's apply
a minimal fix for 2.6.35.
Reported-by: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Tested-by: Chris Mason <chris.mason@oracle.com>
Cc: stable@kernel.org # .34.x
---
drivers/virtio/virtio_ring.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index dd35b34..bffec32 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -164,7 +164,8 @@ int virtqueue_add_buf_gfp(struct virtqueue *_vq,
gfp_t gfp)
{
struct vring_virtqueue *vq = to_vvq(_vq);
- unsigned int i, avail, head, uninitialized_var(prev);
+ unsigned int i, avail, uninitialized_var(prev);
+ int head;
START_USE(vq);
@@ -174,8 +175,8 @@ int virtqueue_add_buf_gfp(struct virtqueue *_vq,
* buffers, then go indirect. FIXME: tune this threshold */
if (vq->indirect && (out + in) > 1 && vq->num_free) {
head = vring_add_indirect(vq, sg, out, in, gfp);
- if (head != vq->vring.num)
+ if (likely(head >= 0))
goto add_head;
}
BUG_ON(out + in > vq->vring.num);
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-07-26 7:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-23 6:18 [PATCH] virtio: fix oops on OOM Rusty Russell
2010-07-23 14:52 ` [stable] " Chuck Ebbert
2010-07-23 14:52 ` Chuck Ebbert
2010-07-26 7:25 ` Rusty Russell
2010-07-26 7:25 ` 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.