aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-integrity.c
diff options
context:
space:
mode:
authorOndrej Mosnáček <omosnacek@gmail.com>2017-06-05 17:52:39 +0200
committerMike Snitzer <snitzer@redhat.com>2017-06-12 17:05:55 -0400
commit2ad50606f847a902303a5364b7cad64bdd6246f6 (patch)
tree29576817c3611442cd60d2ffb7d3740a516586c2 /drivers/md/dm-integrity.c
parentLinux 4.12-rc5 (diff)
downloadlinux-dev-2ad50606f847a902303a5364b7cad64bdd6246f6.tar.xz
linux-dev-2ad50606f847a902303a5364b7cad64bdd6246f6.zip
dm integrity: reject mappings too large for device
dm-integrity would successfully create mappings with the number of sectors greater than the provided data sector count. Attempts to read sectors of this mapping that were beyond the provided data sector count would then yield run-time messages of the form "device-mapper: integrity: Too big sector number: ...". Fix this by emitting an error when the requested mapping size is bigger than the provided data sector count. Signed-off-by: Ondrej Mosnacek <omosnacek@gmail.com> Acked-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-integrity.c')
-rw-r--r--drivers/md/dm-integrity.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
index 7910bfe50da4..4ab10cf718c9 100644
--- a/drivers/md/dm-integrity.c
+++ b/drivers/md/dm-integrity.c
@@ -3040,6 +3040,11 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
ti->error = "The device is too small";
goto bad;
}
+ if (ti->len > ic->provided_data_sectors) {
+ r = -EINVAL;
+ ti->error = "Not enough provided sectors for requested mapping size";
+ goto bad;
+ }
if (!buffer_sectors)
buffer_sectors = 1;