--- drivers/md/dm-flakey.c | 7 +++++++ drivers/md/dm-linear.c | 10 +++++++++- drivers/md/dm-mpath.c | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) Index: linux/drivers/md/dm-flakey.c =================================================================== --- linux.orig/drivers/md/dm-flakey.c +++ linux/drivers/md/dm-flakey.c @@ -369,6 +369,13 @@ static int flakey_ioctl(struct dm_target { struct flakey_c *fc = ti->private; + /* + * Only pass ioctls through if the device sizes match exactly. + */ + if (fc->start || + ti->len != i_size_read(fc->dev->bdev->bd_inode) >> SECTOR_SHIFT) + return -ENOTTY; + return __blkdev_driver_ioctl(fc->dev->bdev, fc->dev->mode, cmd, arg); } Index: linux/drivers/md/dm-linear.c =================================================================== --- linux.orig/drivers/md/dm-linear.c +++ linux/drivers/md/dm-linear.c @@ -115,7 +115,15 @@ static int linear_status(struct dm_targe static int linear_ioctl(struct dm_target *ti, unsigned int cmd, unsigned long arg) { - struct linear_c *lc = (struct linear_c *) ti->private; + struct linear_c *lc = ti->private; + + /* + * Only pass ioctls through if the device sizes match exactly. + */ + if (lc->start || + ti->len != i_size_read(lc->dev->bdev->bd_inode) >> SECTOR_SHIFT) + return -ENOTTY; + return __blkdev_driver_ioctl(lc->dev->bdev, lc->dev->mode, cmd, arg); } Index: linux/drivers/md/dm-mpath.c =================================================================== --- linux.orig/drivers/md/dm-mpath.c +++ linux/drivers/md/dm-mpath.c @@ -1520,6 +1520,12 @@ static int multipath_ioctl(struct dm_tar spin_unlock_irqrestore(&m->lock, flags); + /* + * Only pass ioctls through if the device sizes match exactly. + */ + if (ti->len != i_size_read(bdev->bd_inode) >> SECTOR_SHIFT) + return -ENOTTY; + return r ? : __blkdev_driver_ioctl(bdev, mode, cmd, arg); }