Skip to content

Commit

Permalink
HVM-842 QEMU might succumb to compiler enthusiasm and read twice (CVE…
Browse files Browse the repository at this point in the history
  • Loading branch information
jclulow committed Feb 5, 2016
1 parent d2d7039 commit 90b6c3f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
20 changes: 16 additions & 4 deletions hw/xen_blkif.h
Expand Up @@ -79,8 +79,14 @@ static inline void blkif_get_x86_32_req(blkif_request_t *dst, blkif_x86_32_reque
dst->handle = src->handle;
dst->id = src->id;
dst->sector_number = src->sector_number;
if (n > src->nr_segments)
n = src->nr_segments;

/*
* Ensure we use a consistent view of "nr_segments", which is shared
* with the guest:
*/
barrier();
if (n > dst->nr_segments)
n = dst->nr_segments;
for (i = 0; i < n; i++)
dst->seg[i] = src->seg[i];
}
Expand All @@ -94,8 +100,14 @@ static inline void blkif_get_x86_64_req(blkif_request_t *dst, blkif_x86_64_reque
dst->handle = src->handle;
dst->id = src->id;
dst->sector_number = src->sector_number;
if (n > src->nr_segments)
n = src->nr_segments;

/*
* Ensure we use a consistent view of "nr_segments", which is shared
* with the guest:
*/
barrier();
if (n > dst->nr_segments)
n = dst->nr_segments;
for (i = 0; i < n; i++)
dst->seg[i] = src->seg[i];
}
Expand Down
10 changes: 6 additions & 4 deletions hw/xenfb.c
Expand Up @@ -787,18 +787,20 @@ static void xenfb_invalidate(void *opaque)

static void xenfb_handle_events(struct XenFB *xenfb)
{
uint32_t prod, cons;
uint32_t prod, cons, out_cons;
struct xenfb_page *page = xenfb->c.page;

prod = page->out_prod;
if (prod == page->out_cons)
out_cons = page->out_cons;
if (prod == out_cons)
return;
xen_rmb(); /* ensure we see ring contents up to prod */
for (cons = page->out_cons; cons != prod; cons++) {
for (cons = out_cons; cons != prod; cons++) {
union xenfb_out_event *event = &XENFB_OUT_RING_REF(page, cons);
uint8_t type = event->type;
int x, y, w, h;

switch (event->type) {
switch (type) {
case XENFB_TYPE_UPDATE:
if (xenfb->up_count == UP_QUEUE)
xenfb->up_fullscreen = 1;
Expand Down

0 comments on commit 90b6c3f

Please sign in to comment.