2018-11-11 17:40:18 +00:00
|
|
|
From bfad51710e1523650c2cfbf9aff561bb8364d9a7 Mon Sep 17 00:00:00 2001
|
2015-12-17 08:24:01 +00:00
|
|
|
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
|
|
|
|
<marmarek@invisiblethingslab.com>
|
|
|
|
Date: Wed, 16 Dec 2015 05:51:10 +0100
|
2018-08-15 12:57:19 +00:00
|
|
|
Subject: [PATCH] xen-blkfront: make local copy of response before using it
|
2015-12-17 08:24:01 +00:00
|
|
|
MIME-Version: 1.0
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
|
|
|
|
Data on the shared page can be changed at any time by the backend. Make
|
|
|
|
a local copy, which is no longer controlled by the backend. And only
|
|
|
|
then access it.
|
|
|
|
|
|
|
|
This is part of XSA155.
|
|
|
|
|
|
|
|
CC: stable@vger.kernel.org
|
|
|
|
Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
|
|
|
|
---
|
|
|
|
drivers/block/xen-blkfront.c | 34 +++++++++++++++++-----------------
|
|
|
|
1 file changed, 17 insertions(+), 17 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
|
2018-11-11 17:40:18 +00:00
|
|
|
index 3f6df7d98265..e520bc6f6007 100644
|
2015-12-17 08:24:01 +00:00
|
|
|
--- a/drivers/block/xen-blkfront.c
|
|
|
|
+++ b/drivers/block/xen-blkfront.c
|
2018-11-11 17:40:18 +00:00
|
|
|
@@ -1551,7 +1551,7 @@ static bool blkif_completion(unsigned long *id,
|
2015-12-17 08:24:01 +00:00
|
|
|
static irqreturn_t blkif_interrupt(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
struct request *req;
|
|
|
|
- struct blkif_response *bret;
|
|
|
|
+ struct blkif_response bret;
|
|
|
|
RING_IDX i, rp;
|
|
|
|
unsigned long flags;
|
2016-11-11 13:28:22 +00:00
|
|
|
struct blkfront_ring_info *rinfo = (struct blkfront_ring_info *)dev_id;
|
2018-11-11 17:40:18 +00:00
|
|
|
@@ -1568,8 +1568,8 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
|
2016-11-11 13:28:22 +00:00
|
|
|
for (i = rinfo->ring.rsp_cons; i != rp; i++) {
|
2015-12-17 08:24:01 +00:00
|
|
|
unsigned long id;
|
|
|
|
|
2016-11-11 13:28:22 +00:00
|
|
|
- bret = RING_GET_RESPONSE(&rinfo->ring, i);
|
2015-12-17 08:24:01 +00:00
|
|
|
- id = bret->id;
|
2016-11-11 13:28:22 +00:00
|
|
|
+ RING_COPY_RESPONSE(&rinfo->ring, i, &bret);
|
2015-12-17 08:24:01 +00:00
|
|
|
+ id = bret.id;
|
|
|
|
/*
|
|
|
|
* The backend has messed up and given us an id that we would
|
|
|
|
* never have given to it (we stamp it up to BLK_RING_SIZE -
|
2018-11-11 17:40:18 +00:00
|
|
|
@@ -1577,39 +1577,39 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
|
2015-12-17 08:24:01 +00:00
|
|
|
*/
|
2016-01-04 11:54:07 +00:00
|
|
|
if (id >= BLK_RING_SIZE(info)) {
|
2015-12-17 08:24:01 +00:00
|
|
|
WARN(1, "%s: response to %s has incorrect id (%ld)\n",
|
|
|
|
- info->gd->disk_name, op_name(bret->operation), id);
|
|
|
|
+ info->gd->disk_name, op_name(bret.operation), id);
|
|
|
|
/* We can't safely get the 'struct request' as
|
|
|
|
* the id is busted. */
|
|
|
|
continue;
|
|
|
|
}
|
2016-11-11 13:28:22 +00:00
|
|
|
req = rinfo->shadow[id].request;
|
2015-12-17 08:24:01 +00:00
|
|
|
|
2016-11-11 13:28:22 +00:00
|
|
|
- if (bret->operation != BLKIF_OP_DISCARD) {
|
|
|
|
+ if (bret.operation != BLKIF_OP_DISCARD) {
|
|
|
|
/*
|
|
|
|
* We may need to wait for an extra response if the
|
|
|
|
* I/O request is split in 2
|
|
|
|
*/
|
|
|
|
- if (!blkif_completion(&id, rinfo, bret))
|
|
|
|
+ if (!blkif_completion(&id, rinfo, &bret))
|
|
|
|
continue;
|
|
|
|
}
|
2015-12-17 08:24:01 +00:00
|
|
|
|
2016-11-11 13:28:22 +00:00
|
|
|
if (add_id_to_freelist(rinfo, id)) {
|
2015-12-17 08:24:01 +00:00
|
|
|
WARN(1, "%s: response to %s (id %ld) couldn't be recycled!\n",
|
|
|
|
- info->gd->disk_name, op_name(bret->operation), id);
|
|
|
|
+ info->gd->disk_name, op_name(bret.operation), id);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-10-02 03:04:33 +00:00
|
|
|
- if (bret->status == BLKIF_RSP_OKAY)
|
|
|
|
+ if (bret.status == BLKIF_RSP_OKAY)
|
|
|
|
blkif_req(req)->error = BLK_STS_OK;
|
|
|
|
else
|
|
|
|
blkif_req(req)->error = BLK_STS_IOERR;
|
|
|
|
|
2015-12-17 08:24:01 +00:00
|
|
|
- switch (bret->operation) {
|
|
|
|
+ switch (bret.operation) {
|
|
|
|
case BLKIF_OP_DISCARD:
|
|
|
|
- if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) {
|
|
|
|
+ if (unlikely(bret.status == BLKIF_RSP_EOPNOTSUPP)) {
|
|
|
|
struct request_queue *rq = info->rq;
|
|
|
|
printk(KERN_WARNING "blkfront: %s: %s op failed\n",
|
|
|
|
- info->gd->disk_name, op_name(bret->operation));
|
|
|
|
+ info->gd->disk_name, op_name(bret.operation));
|
2017-10-02 03:04:33 +00:00
|
|
|
blkif_req(req)->error = BLK_STS_NOTSUPP;
|
2015-12-17 08:24:01 +00:00
|
|
|
info->feature_discard = 0;
|
|
|
|
info->feature_secdiscard = 0;
|
2018-11-11 17:40:18 +00:00
|
|
|
@@ -1619,15 +1619,15 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
|
2015-12-17 08:24:01 +00:00
|
|
|
break;
|
|
|
|
case BLKIF_OP_FLUSH_DISKCACHE:
|
|
|
|
case BLKIF_OP_WRITE_BARRIER:
|
|
|
|
- if (unlikely(bret->status == BLKIF_RSP_EOPNOTSUPP)) {
|
|
|
|
+ if (unlikely(bret.status == BLKIF_RSP_EOPNOTSUPP)) {
|
|
|
|
printk(KERN_WARNING "blkfront: %s: %s op failed\n",
|
|
|
|
- info->gd->disk_name, op_name(bret->operation));
|
|
|
|
+ info->gd->disk_name, op_name(bret.operation));
|
2017-10-02 03:04:33 +00:00
|
|
|
blkif_req(req)->error = BLK_STS_NOTSUPP;
|
2015-12-17 08:24:01 +00:00
|
|
|
}
|
|
|
|
- if (unlikely(bret->status == BLKIF_RSP_ERROR &&
|
|
|
|
+ if (unlikely(bret.status == BLKIF_RSP_ERROR &&
|
2016-11-11 13:28:22 +00:00
|
|
|
rinfo->shadow[id].req.u.rw.nr_segments == 0)) {
|
2015-12-17 08:24:01 +00:00
|
|
|
printk(KERN_WARNING "blkfront: %s: empty %s op failed\n",
|
|
|
|
- info->gd->disk_name, op_name(bret->operation));
|
|
|
|
+ info->gd->disk_name, op_name(bret.operation));
|
2017-10-02 03:04:33 +00:00
|
|
|
blkif_req(req)->error = BLK_STS_NOTSUPP;
|
2015-12-17 08:24:01 +00:00
|
|
|
}
|
2017-10-02 03:04:33 +00:00
|
|
|
if (unlikely(blkif_req(req)->error)) {
|
2018-11-11 17:40:18 +00:00
|
|
|
@@ -1640,9 +1640,9 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)
|
2015-12-17 08:24:01 +00:00
|
|
|
/* fall through */
|
|
|
|
case BLKIF_OP_READ:
|
|
|
|
case BLKIF_OP_WRITE:
|
|
|
|
- if (unlikely(bret->status != BLKIF_RSP_OKAY))
|
|
|
|
+ if (unlikely(bret.status != BLKIF_RSP_OKAY))
|
|
|
|
dev_dbg(&info->xbdev->dev, "Bad return from blkdev data "
|
|
|
|
- "request: %x\n", bret->status);
|
|
|
|
+ "request: %x\n", bret.status);
|
|
|
|
|
|
|
|
break;
|
2017-10-02 03:04:33 +00:00
|
|
|
default:
|
2015-12-17 08:24:01 +00:00
|
|
|
--
|
2018-08-15 12:57:19 +00:00
|
|
|
2.17.1
|
2015-12-17 08:24:01 +00:00
|
|
|
|