From be3510b204ad05e6af7fa8f0b4b06729143bfd5f Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Wed, 2 Mar 2011 20:00:09 +0000 Subject: [PATCH] PE size overflows, on most architectures it is catch by "PE cannot be 0" but s390x unfortunately return something usable. Always use unit64 in inital parameter check. --- WHATS_NEW | 2 +- lib/metadata/metadata-exported.h | 1 + tools/toollib.c | 6 ++++++ tools/vgchange.c | 6 ++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/WHATS_NEW b/WHATS_NEW index 19cb9ae75..82588208d 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,6 +1,6 @@ Version 2.02.85 - =================================== - Fix possible overwlow in maximum stripe size. + Fix possible overflow in maximum stripe size and physical extent size. Add test for failed allocation from dm_task_set_uuid() in dmeventd. Improve pvremove error message when PV belongs to a VG. Extend normal policy to allow mirror logs on same PVs as images if necessary. diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index 15d17154c..d1794c203 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -34,6 +34,7 @@ #define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */ #define STRIPE_SIZE_LIMIT ((UINT_MAX >> 2) + 1) #define MAX_RESTRICTED_LVS 255 /* Used by FMT_RESTRICTED_LVIDS */ +#define MAX_EXTENT_SIZE ((uint32_t) -1) /* Layer suffix */ #define MIRROR_SYNC_LAYER "_mimagetmp" diff --git a/tools/toollib.c b/tools/toollib.c index b9019b8d4..e67198762 100644 --- a/tools/toollib.c +++ b/tools/toollib.c @@ -1238,6 +1238,12 @@ int vgcreate_params_set_from_args(struct cmd_context *cmd, return 1; } + if (arg_uint64_value(cmd, physicalextentsize_ARG, 0) > MAX_EXTENT_SIZE) { + log_error("Physical extent size cannot be larger than %s", + display_size(cmd, (uint64_t) MAX_EXTENT_SIZE)); + return 1; + } + if (arg_sign_value(cmd, maxlogicalvolumes_ARG, 0) == SIGN_MINUS) { log_error("Max Logical Volumes may not be negative"); return 1; diff --git a/tools/vgchange.c b/tools/vgchange.c index 4266d6333..6dc241b93 100644 --- a/tools/vgchange.c +++ b/tools/vgchange.c @@ -356,6 +356,12 @@ static int _vgchange_pesize(struct cmd_context *cmd, struct volume_group *vg) { uint32_t extent_size; + if (arg_uint64_value(cmd, physicalextentsize_ARG, 0) > MAX_EXTENT_SIZE) { + log_error("Physical extent size cannot be larger than %s", + display_size(cmd, (uint64_t) MAX_EXTENT_SIZE)); + return 1; + } + extent_size = arg_uint_value(cmd, physicalextentsize_ARG, 0); /* FIXME: remove check - redundant with vg_change_pesize */ if (extent_size == vg->extent_size) { -- 2.43.5