|
|
3eefce9 |
From e029d62efa5eb46831a9e1414468e582379b743f Mon Sep 17 00:00:00 2001
|
|
|
3eefce9 |
From: Konrad Rzeszutek Wilk <konrad.wilk () oracle com>
|
|
|
3eefce9 |
Date: Wed, 16 Jan 2013 11:33:52 -0500
|
|
|
3eefce9 |
Subject: [PATCH] xen/blkback: Check device permissions before allowing
|
|
|
3eefce9 |
OP_DISCARD
|
|
|
3eefce9 |
|
|
|
3eefce9 |
We need to make sure that the device is not RO or that
|
|
|
3eefce9 |
the request is not past the number of sectors we want to
|
|
|
3eefce9 |
issue the DISCARD operation for.
|
|
|
3eefce9 |
|
|
|
3eefce9 |
Cc: stable () vger kernel org
|
|
|
3eefce9 |
Acked-by: Jan Beulich <JBeulich () suse com>
|
|
|
3eefce9 |
Acked-by: Ian Campbell <Ian.Campbell () citrix com>
|
|
|
3eefce9 |
[v1: Made it pr_warn instead of pr_debug]
|
|
|
3eefce9 |
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk () oracle com>
|
|
|
3eefce9 |
---
|
|
|
3eefce9 |
drivers/block/xen-blkback/blkback.c | 13 ++++++++++++-
|
|
|
3eefce9 |
1 file changed, 12 insertions(+), 1 deletion(-)
|
|
|
3eefce9 |
|
|
|
3eefce9 |
diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
|
|
|
3eefce9 |
index e79ab45..4119bcd 100644
|
|
|
3eefce9 |
--- a/drivers/block/xen-blkback/blkback.c
|
|
|
3eefce9 |
+++ b/drivers/block/xen-blkback/blkback.c
|
|
|
3eefce9 |
@@ -876,7 +876,18 @@ static int dispatch_discard_io(struct xen_blkif *blkif,
|
|
|
3eefce9 |
int status = BLKIF_RSP_OKAY;
|
|
|
3eefce9 |
struct block_device *bdev = blkif->vbd.bdev;
|
|
|
3eefce9 |
unsigned long secure;
|
|
|
3eefce9 |
+ struct phys_req preq;
|
|
|
3eefce9 |
+
|
|
|
3eefce9 |
+ preq.sector_number = req->u.discard.sector_number;
|
|
|
3eefce9 |
+ preq.nr_sects = req->u.discard.nr_sectors;
|
|
|
3eefce9 |
|
|
|
3eefce9 |
+ err = xen_vbd_translate(&preq, blkif, WRITE);
|
|
|
3eefce9 |
+ if (err) {
|
|
|
3eefce9 |
+ pr_warn(DRV_PFX "access denied: DISCARD [%llu->%llu] on dev=%04x\n",
|
|
|
3eefce9 |
+ preq.sector_number,
|
|
|
3eefce9 |
+ preq.sector_number + preq.nr_sects, blkif->vbd.pdevice);
|
|
|
3eefce9 |
+ goto fail_response;
|
|
|
3eefce9 |
+ }
|
|
|
3eefce9 |
blkif->st_ds_req++;
|
|
|
3eefce9 |
|
|
|
3eefce9 |
xen_blkif_get(blkif);
|
|
|
3eefce9 |
@@ -887,7 +898,7 @@ static int dispatch_discard_io(struct xen_blkif *blkif,
|
|
|
3eefce9 |
err = blkdev_issue_discard(bdev, req->u.discard.sector_number,
|
|
|
3eefce9 |
req->u.discard.nr_sectors,
|
|
|
3eefce9 |
GFP_KERNEL, secure);
|
|
|
3eefce9 |
-
|
|
|
3eefce9 |
+fail_response:
|
|
|
3eefce9 |
if (err == -EOPNOTSUPP) {
|
|
|
3eefce9 |
pr_debug(DRV_PFX "discard op failed, not supported\n");
|
|
|
3eefce9 |
status = BLKIF_RSP_EOPNOTSUPP;
|
|
|
3eefce9 |
--
|
|
|
3eefce9 |
1.8.1.4
|
|
|
3eefce9 |
|