aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Pau Monné <roger.pau@citrix.com>2015-11-03 11:34:09 -0500
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2015-12-18 10:00:32 -0500
commit1f13d75ccb806260079e0679d55d9253e370ec8a (patch)
treea791cbe758b8c1c4feaf3a88603c7f96f7a4b7ba
parent68a33bfd8403e4e22847165d149823a2e0e67c9c (diff)
xen-blkback: only read request operation from shared ring once
A compiler may load a switch statement value multiple times, which could be bad when the value is in memory shared with the frontend. When converting a non-native request to a native one, ensure that src->operation is only loaded once by using READ_ONCE(). This is part of XSA155. CC: stable@vger.kernel.org Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Signed-off-by: David Vrabel <david.vrabel@citrix.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
-rw-r--r--drivers/block/xen-blkback/common.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index 68e87a037b99..c929ae22764c 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -408,8 +408,8 @@ static inline void blkif_get_x86_32_req(struct blkif_request *dst,
408 struct blkif_x86_32_request *src) 408 struct blkif_x86_32_request *src)
409{ 409{
410 int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST, j; 410 int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST, j;
411 dst->operation = src->operation; 411 dst->operation = READ_ONCE(src->operation);
412 switch (src->operation) { 412 switch (dst->operation) {
413 case BLKIF_OP_READ: 413 case BLKIF_OP_READ:
414 case BLKIF_OP_WRITE: 414 case BLKIF_OP_WRITE:
415 case BLKIF_OP_WRITE_BARRIER: 415 case BLKIF_OP_WRITE_BARRIER:
@@ -456,8 +456,8 @@ static inline void blkif_get_x86_64_req(struct blkif_request *dst,
456 struct blkif_x86_64_request *src) 456 struct blkif_x86_64_request *src)
457{ 457{
458 int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST, j; 458 int i, n = BLKIF_MAX_SEGMENTS_PER_REQUEST, j;
459 dst->operation = src->operation; 459 dst->operation = READ_ONCE(src->operation);
460 switch (src->operation) { 460 switch (dst->operation) {
461 case BLKIF_OP_READ: 461 case BLKIF_OP_READ:
462 case BLKIF_OP_WRITE: 462 case BLKIF_OP_WRITE:
463 case BLKIF_OP_WRITE_BARRIER: 463 case BLKIF_OP_WRITE_BARRIER: