diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2025-03-14 15:51:32 +0300 |
---|---|---|
committer | Mikulas Patocka <mpatocka@redhat.com> | 2025-03-14 15:58:33 +0300 |
commit | 45fc728515c14f53f6205789de5bfd72a95af3b8 (patch) | |
tree | 1e897f26ec835c5eec09c2b258a98a20b6a41cb7 | |
parent | c2662b1544cbd8ea3181381bb899b8e681dfedc7 (diff) | |
download | linux-45fc728515c14f53f6205789de5bfd72a95af3b8.tar.xz |
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>
-rw-r--r-- | drivers/md/dm-table.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 0ef5203387b2..04b3e9758e53 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -697,6 +697,10 @@ int dm_table_add_target(struct dm_table *t, const char *type, DMERR("%s: zero-length target", dm_device_name(t->md)); return -EINVAL; } + if (start + len < start || start + len > LLONG_MAX >> SECTOR_SHIFT) { + DMERR("%s: too large device", dm_device_name(t->md)); + return -EINVAL; + } ti->type = dm_get_target_type(type); if (!ti->type) { |