Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1716818 > unrolled thread
| Started by | "Michael S. Tsirkin" <mst@redhat.com> |
|---|---|
| First post | 2017-08-21 21:50 +0200 |
| Last post | 2017-08-22 16:50 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] vhost: fix end of range for access_ok "Michael S. Tsirkin" <mst@redhat.com> - 2017-08-21 21:50 +0200
Re: [PATCH] vhost: fix end of range for access_ok Koichiro Den <den@klaipeden.com> - 2017-08-22 16:50 +0200
| From | "Michael S. Tsirkin" <mst@redhat.com> |
|---|---|
| Date | 2017-08-21 21:50 +0200 |
| Subject | [PATCH] vhost: fix end of range for access_ok |
| Message-ID | <uh0RZ-6N-29@gated-at.bofh.it> |
During access_ok checks, addr increases as we iterate over the data
structure, thus addr + len - 1 will point beyond the end of region we
are translating. Harmless since we then verify that the region covers
addr, but let's not waste cpu cycles.
Reported-by: Koichiro Den <den@klaipeden.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
Lightly tested, would appreciate an ack from reporter.
drivers/vhost/vhost.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index e4613a3..ecd70e4 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -1176,7 +1176,7 @@ static int iotlb_access_ok(struct vhost_virtqueue *vq,
{
const struct vhost_umem_node *node;
struct vhost_umem *umem = vq->iotlb;
- u64 s = 0, size, orig_addr = addr;
+ u64 s = 0, size, orig_addr = addr, last = addr + len - 1;
if (vhost_vq_meta_fetch(vq, addr, len, type))
return true;
@@ -1184,7 +1184,7 @@ static int iotlb_access_ok(struct vhost_virtqueue *vq,
while (len > s) {
node = vhost_umem_interval_tree_iter_first(&umem->umem_tree,
addr,
- addr + len - 1);
+ last);
if (node == NULL || node->start > addr) {
vhost_iotlb_miss(vq, addr, access);
return false;
--
MST
[toc] | [next] | [standalone]
| From | Koichiro Den <den@klaipeden.com> |
|---|---|
| Date | 2017-08-22 16:50 +0200 |
| Message-ID | <uhiFc-3Hr-25@gated-at.bofh.it> |
| In reply to | #1716818 |
On Mon, 2017-08-21 at 22:45 +0300, Michael S. Tsirkin wrote:
> During access_ok checks, addr increases as we iterate over the data
> structure, thus addr + len - 1 will point beyond the end of region we
> are translating. Harmless since we then verify that the region covers
> addr, but let's not waste cpu cycles.
>
> Reported-by: Koichiro Den <den@klaipeden.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>
> Lightly tested, would appreciate an ack from reporter.
>
> drivers/vhost/vhost.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index e4613a3..ecd70e4 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -1176,7 +1176,7 @@ static int iotlb_access_ok(struct vhost_virtqueue *vq,
> {
> const struct vhost_umem_node *node;
> struct vhost_umem *umem = vq->iotlb;
> - u64 s = 0, size, orig_addr = addr;
> + u64 s = 0, size, orig_addr = addr, last = addr + len - 1;
>
> if (vhost_vq_meta_fetch(vq, addr, len, type))
> return true;
> @@ -1184,7 +1184,7 @@ static int iotlb_access_ok(struct vhost_virtqueue *vq,
> while (len > s) {
> node = vhost_umem_interval_tree_iter_first(&umem->umem_tree,
> addr,
> - addr + len - 1);
> + last);
> if (node == NULL || node->start > addr) {
> vhost_iotlb_miss(vq, addr, access);
> return false;
Michael, Thank you for this one.
Acked-by: Koichiro Den <den@klaipeden.com>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web