Skip to content

Commit 45fc728

Browse files
author
Mikulas Patocka
committed
dm: restrict dm device size to 2^63-512 bytes
The devices with size >= 2^63 bytes can't be used reliably by userspace because the type off_t is a signed 64-bit integer. Therefore, we limit the maximum size of a device mapper device to 2^63-512 bytes. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
1 parent c2662b1 commit 45fc728

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/md/dm-table.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,10 @@ int dm_table_add_target(struct dm_table *t, const char *type,
697697
DMERR("%s: zero-length target", dm_device_name(t->md));
698698
return -EINVAL;
699699
}
700+
if (start + len < start || start + len > LLONG_MAX >> SECTOR_SHIFT) {
701+
DMERR("%s: too large device", dm_device_name(t->md));
702+
return -EINVAL;
703+
}
700704

701705
ti->type = dm_get_target_type(type);
702706
if (!ti->type) {

0 commit comments

Comments
 (0)