[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [qemu-xen-traditional master] blkif: Avoid double access to src->nr_segments



commit a82794b1d5a6da06062a333b1db404e2448345dd
Author:     Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
AuthorDate: Fri Nov 20 10:56:00 2015 -0500
Commit:     Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CommitDate: Fri Dec 18 14:55:17 2015 +0000

    blkif: Avoid double access to src->nr_segments
    
    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 <stefano.stabellini@xxxxxxxxxxxxx>
    Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
---
 hw/xen_blkif.h |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/xen_blkif.h b/hw/xen_blkif.h
index ca3a65b..eb29cb1 100644
--- a/hw/xen_blkif.h
+++ b/hw/xen_blkif.h
@@ -79,8 +79,10 @@ 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;
+       /* prevent the compiler from optimizing the code and using 
src->nr_segments instead */
+       xen_mb();
+       if (n > dst->nr_segments)
+               n = dst->nr_segments;
        for (i = 0; i < n; i++)
                dst->seg[i] = src->seg[i];
 }
@@ -94,8 +96,10 @@ 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;
+       /* prevent the compiler from optimizing the code and using 
src->nr_segments instead */
+       xen_mb();
+       if (n > dst->nr_segments)
+               n = dst->nr_segments;
        for (i = 0; i < n; i++)
                dst->seg[i] = src->seg[i];
 }
--
generated by git-patchbot for /home/xen/git/qemu-xen-traditional.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.