diff options
| author | Mikulas Patocka <mpatocka@redhat.com> | 2025-03-14 13:51:32 +0100 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-05-29 11:02:17 +0200 |
| commit | 174dedce648aaad39e4a9d514a7d73dc06786b64 (patch) | |
| tree | 10dc6c3764398df01d32ebbe6ba39545c44f4ff8 /drivers/md | |
| parent | ee87fc3a1271fa50a1b6cb5523bc10f4f5d9ad38 (diff) | |
| download | linux-174dedce648aaad39e4a9d514a7d73dc06786b64.tar.gz linux-174dedce648aaad39e4a9d514a7d73dc06786b64.tar.bz2 linux-174dedce648aaad39e4a9d514a7d73dc06786b64.zip | |
dm: restrict dm device size to 2^63-512 bytes
[ Upstream commit 45fc728515c14f53f6205789de5bfd72a95af3b8 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/md')
| -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 3dc5bc3d29d6..883f01e78324 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -698,6 +698,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) { |
