* [PATCH] virtio: Avoid possible kernel panic if DEBUG is enabled.
@ 2015-02-06 12:05 Tetsuo Handa
2015-02-09 0:02 ` Rusty Russell
0 siblings, 1 reply; 2+ messages in thread
From: Tetsuo Handa @ 2015-02-06 12:05 UTC (permalink / raw)
To: rusty, mst; +Cc: virtualization
From 11fd997d724f520ca628615e7ffbfd7901c40b62 Mon Sep 17 00:00:00 2001
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Date: Fri, 6 Feb 2015 13:28:38 +0900
Subject: [PATCH] virtio: Avoid possible kernel panic if DEBUG is enabled.
The virtqueue_add() calls START_USE() upon entry. The virtqueue_kick() is
called if vq->num_added == (1 << 16) - 1 before calling END_USE().
The virtqueue_kick_prepare() called via virtqueue_kick() calls START_USE()
upon entry, and will call panic() if DEBUG is enabled.
Move this virtqueue_kick() call to after END_USE() call.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
drivers/virtio/virtio_ring.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index 00ec6b3..596735b 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -245,14 +245,14 @@ static inline int virtqueue_add(struct virtqueue *_vq,
vq->vring.avail->idx = cpu_to_virtio16(_vq->vdev, virtio16_to_cpu(_vq->vdev, vq->vring.avail->idx) + 1);
vq->num_added++;
+ pr_debug("Added buffer head %i to %p\n", head, vq);
+ END_USE(vq);
+
/* This is very unlikely, but theoretically possible. Kick
* just in case. */
if (unlikely(vq->num_added == (1 << 16) - 1))
virtqueue_kick(_vq);
- pr_debug("Added buffer head %i to %p\n", head, vq);
- END_USE(vq);
-
return 0;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] virtio: Avoid possible kernel panic if DEBUG is enabled.
2015-02-06 12:05 [PATCH] virtio: Avoid possible kernel panic if DEBUG is enabled Tetsuo Handa
@ 2015-02-09 0:02 ` Rusty Russell
0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2015-02-09 0:02 UTC (permalink / raw)
To: Tetsuo Handa, mst; +Cc: virtualization
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> writes:
>>From 11fd997d724f520ca628615e7ffbfd7901c40b62 Mon Sep 17 00:00:00 2001
> From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Date: Fri, 6 Feb 2015 13:28:38 +0900
> Subject: [PATCH] virtio: Avoid possible kernel panic if DEBUG is enabled.
>
> The virtqueue_add() calls START_USE() upon entry. The virtqueue_kick() is
> called if vq->num_added == (1 << 16) - 1 before calling END_USE().
> The virtqueue_kick_prepare() called via virtqueue_kick() calls START_USE()
> upon entry, and will call panic() if DEBUG is enabled.
> Move this virtqueue_kick() call to after END_USE() call.
Thanks, applied.
Cheers,
Rusty.
>
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> ---
> drivers/virtio/virtio_ring.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index 00ec6b3..596735b 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -245,14 +245,14 @@ static inline int virtqueue_add(struct virtqueue *_vq,
> vq->vring.avail->idx = cpu_to_virtio16(_vq->vdev, virtio16_to_cpu(_vq->vdev, vq->vring.avail->idx) + 1);
> vq->num_added++;
>
> + pr_debug("Added buffer head %i to %p\n", head, vq);
> + END_USE(vq);
> +
> /* This is very unlikely, but theoretically possible. Kick
> * just in case. */
> if (unlikely(vq->num_added == (1 << 16) - 1))
> virtqueue_kick(_vq);
>
> - pr_debug("Added buffer head %i to %p\n", head, vq);
> - END_USE(vq);
> -
> return 0;
> }
>
> --
> 1.8.3.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-09 0:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-06 12:05 [PATCH] virtio: Avoid possible kernel panic if DEBUG is enabled Tetsuo Handa
2015-02-09 0:02 ` Rusty Russell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).