Skip to content

Commit 2ad5060

Browse files
WOnder93snitm
authored andcommitted
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>
1 parent 32c1431 commit 2ad5060

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/md/dm-integrity.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3040,6 +3040,11 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
30403040
ti->error = "The device is too small";
30413041
goto bad;
30423042
}
3043+
if (ti->len > ic->provided_data_sectors) {
3044+
r = -EINVAL;
3045+
ti->error = "Not enough provided sectors for requested mapping size";
3046+
goto bad;
3047+
}
30433048

30443049
if (!buffer_sectors)
30453050
buffer_sectors = 1;

0 commit comments

Comments
 (0)