summaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-delay.c
diff options
context:
space:
mode:
authorMilan Broz2018-11-07 22:24:55 +0100
committerGreg Kroah-Hartman2019-01-26 09:32:42 +0100
commit887b1c9a7d17c919bc1b8204da2631be419e9a31 (patch)
tree367babbfdcf0b62278db1b00552bd5545c3a1cf4 /drivers/md/dm-delay.c
parentclocksource/drivers/integrator-ap: Add missing of_node_put() (diff)
downloadkernel-qcow2-linux-887b1c9a7d17c919bc1b8204da2631be419e9a31.tar.gz
kernel-qcow2-linux-887b1c9a7d17c919bc1b8204da2631be419e9a31.tar.xz
kernel-qcow2-linux-887b1c9a7d17c919bc1b8204da2631be419e9a31.zip
dm: Check for device sector overflow if CONFIG_LBDAF is not set
[ Upstream commit ef87bfc24f9b8da82c89aff493df20f078bc9cb1 ] Reference to a device in device-mapper table contains offset in sectors. If the sector_t is 32bit integer (CONFIG_LBDAF is not set), then several device-mapper targets can overflow this offset and validity check is then performed on a wrong offset and a wrong table is activated. See for example (on 32bit without CONFIG_LBDAF) this overflow: # dmsetup create test --table "0 2048 linear /dev/sdg 4294967297" # dmsetup table test 0 2048 linear 8:96 1 This patch adds explicit check for overflow if the offset is sector_t type. Signed-off-by: Milan Broz <gmazyland@gmail.com> Reviewed-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/md/dm-delay.c')
-rw-r--r--drivers/md/dm-delay.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/md/dm-delay.c b/drivers/md/dm-delay.c
index 2fb7bb4304ad..fddffe251bf6 100644
--- a/drivers/md/dm-delay.c
+++ b/drivers/md/dm-delay.c
@@ -141,7 +141,7 @@ static int delay_class_ctr(struct dm_target *ti, struct delay_class *c, char **a
unsigned long long tmpll;
char dummy;
- if (sscanf(argv[1], "%llu%c", &tmpll, &dummy) != 1) {
+ if (sscanf(argv[1], "%llu%c", &tmpll, &dummy) != 1 || tmpll != (sector_t)tmpll) {
ti->error = "Invalid device sector";
return -EINVAL;
}