[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/35] xen/blkif: Avoid double access to src->nr_seg
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 05/35] xen/blkif: Avoid double access to src->nr_segments |
Date: |
Mon, 21 Mar 2016 12:28:03 -0500 |
From: Stefano Stabellini <address@hidden>
src is stored in shared memory and src->nr_segments is dereferenced
twice at the end of the function. If a compiler decides to compile this
into two separate memory accesses then the size limitation could be
bypassed.
Fix it by removing the double access to src->nr_segments.
This is part of XSA-155.
Signed-off-by: Stefano Stabellini <address@hidden>
(cherry picked from commit f9e98e5d7a67367b862941e339a98b8322fa0cea)
Signed-off-by: Michael Roth <address@hidden>
---
hw/block/xen_blkif.h | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/hw/block/xen_blkif.h b/hw/block/xen_blkif.h
index 711b692..c68487cb 100644
--- a/hw/block/xen_blkif.h
+++ b/hw/block/xen_blkif.h
@@ -85,8 +85,10 @@ static inline void blkif_get_x86_32_req(blkif_request_t
*dst, blkif_x86_32_reque
d->nr_sectors = s->nr_sectors;
return;
}
- if (n > src->nr_segments)
- n = src->nr_segments;
+ /* prevent the compiler from optimizing the code and using
src->nr_segments instead */
+ barrier();
+ if (n > dst->nr_segments)
+ n = dst->nr_segments;
for (i = 0; i < n; i++)
dst->seg[i] = src->seg[i];
}
@@ -106,8 +108,10 @@ static inline void blkif_get_x86_64_req(blkif_request_t
*dst, blkif_x86_64_reque
d->nr_sectors = s->nr_sectors;
return;
}
- if (n > src->nr_segments)
- n = src->nr_segments;
+ /* prevent the compiler from optimizing the code and using
src->nr_segments instead */
+ barrier();
+ if (n > dst->nr_segments)
+ n = dst->nr_segments;
for (i = 0; i < n; i++)
dst->seg[i] = src->seg[i];
}
--
1.9.1
- [Qemu-devel] [PATCH 30/35] hw/virtio: group virtio flags into an enum, (continued)
- [Qemu-devel] [PATCH 30/35] hw/virtio: group virtio flags into an enum, Michael Roth, 2016/03/21
- [Qemu-devel] [PATCH 31/35] fw_cfg: unbreak migration compatibility for 2.4 and earlier machines, Michael Roth, 2016/03/21
- [Qemu-devel] [PATCH 22/35] fw_cfg: avoid calculating invalid current entry pointer, Michael Roth, 2016/03/21
- [Qemu-devel] [PATCH 34/35] quorum: Fix crash in quorum_aio_cb(), Michael Roth, 2016/03/21
- [Qemu-devel] [PATCH 33/35] target-arm: Make reserved ranges in ID_AA64* spaces RAZ, not UNDEF, Michael Roth, 2016/03/21
- [Qemu-devel] [PATCH 28/35] spapr: skip configuration section during migration of older machines, Michael Roth, 2016/03/21
- [Qemu-devel] [PATCH 02/35] net: vmxnet3: avoid memory leakage in activate_device, Michael Roth, 2016/03/21
- [Qemu-devel] [PATCH 04/35] configure: Fix shell syntax to placate OpenBSD's pdksh, Michael Roth, 2016/03/21
- [Qemu-devel] [PATCH 05/35] xen/blkif: Avoid double access to src->nr_segments,
Michael Roth <=
- [Qemu-devel] [PATCH 06/35] xenfb: avoid reading twice the same fields from the shared page, Michael Roth, 2016/03/21
- [Qemu-devel] [PATCH 08/35] scsi: initialise info object with appropriate size, Michael Roth, 2016/03/21
- [Qemu-devel] [PATCH 07/35] virtio-9p: use accessor to get thread_pool, Michael Roth, 2016/03/21
- [Qemu-devel] [PATCH 35/35] vl.c: Fix regression in machine error message, Michael Roth, 2016/03/21
- [Qemu-devel] [PATCH 03/35] target-ppc: kvm: fix floating point registers sync on little-endian hosts, Michael Roth, 2016/03/21
- Re: [Qemu-devel] [Qemu-stable] [PATCH 00/35] Patch Round-up for stable 2.5.1, freeze on 2016-03-25, Cole Robinson, 2016/03/21
- Re: [Qemu-devel] [Qemu-stable] [PATCH 00/35] Patch Round-up for stable 2.5.1, freeze on 2016-03-25, Peter Lieven, 2016/03/22