mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
Avoid lvextend to overflow
Add extra check to extent_count overflow. Use internal define MAX_EXTENT_COUNT instead UINT32_MAX.
This commit is contained in:
parent
7060c9d942
commit
4079a8f298
@ -1,5 +1,6 @@
|
||||
Version 2.02.89 -
|
||||
==================================
|
||||
Fix extent_count overflow with lvextend.
|
||||
Add missing lvrename mirrored log recursion in for_each_sub_lv.
|
||||
Improve lv_extend stack reporting.
|
||||
Increase virtual segment size instead of creating multiple segment list.
|
||||
|
@ -276,12 +276,12 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
|
||||
if (!alloc_pv_segment_whole_pv(mem, pv))
|
||||
return_0;
|
||||
|
||||
if ((uint64_t) vg->extent_count + pv->pe_count > UINT32_MAX) {
|
||||
if ((uint64_t) vg->extent_count + pv->pe_count > MAX_EXTENT_COUNT) {
|
||||
log_error("Unable to add %s to %s: new extent count (%"
|
||||
PRIu64 ") exceeds limit (%" PRIu32 ").",
|
||||
pv_name, vg->name,
|
||||
(uint64_t) vg->extent_count + pv->pe_count,
|
||||
UINT32_MAX);
|
||||
MAX_EXTENT_COUNT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1000,12 +1000,12 @@ uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size,
|
||||
display_size(cmd, size));
|
||||
}
|
||||
|
||||
if (size > (uint64_t) UINT32_MAX * extent_size) {
|
||||
if (size > (uint64_t) MAX_EXTENT_COUNT * extent_size) {
|
||||
log_error("Volume too large (%s) for extent size %s. "
|
||||
"Upper limit is %s.",
|
||||
display_size(cmd, size),
|
||||
display_size(cmd, (uint64_t) extent_size),
|
||||
display_size(cmd, (uint64_t) UINT32_MAX *
|
||||
display_size(cmd, (uint64_t) MAX_EXTENT_COUNT *
|
||||
extent_size));
|
||||
return 0;
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ static int _recalc_extents(uint32_t *extents, const char *desc1,
|
||||
|
||||
size /= new_size;
|
||||
|
||||
if (size > UINT32_MAX) {
|
||||
if (size > MAX_EXTENT_COUNT) {
|
||||
log_error("New extent count %" PRIu64 " for %s%s exceeds "
|
||||
"32 bits.", size, desc1, desc2);
|
||||
return 0;
|
||||
|
@ -37,6 +37,8 @@ struct pv_to_create {
|
||||
struct pvcreate_params *pp;
|
||||
};
|
||||
|
||||
#define MAX_EXTENT_COUNT (UINT32_MAX)
|
||||
|
||||
struct volume_group {
|
||||
struct cmd_context *cmd;
|
||||
struct dm_pool *vgmem;
|
||||
|
@ -459,8 +459,14 @@ static int _lvresize(struct cmd_context *cmd, struct volume_group *vg,
|
||||
break;
|
||||
}
|
||||
|
||||
if (lp->sign == SIGN_PLUS)
|
||||
if (lp->sign == SIGN_PLUS) {
|
||||
if (lp->extents >= (MAX_EXTENT_COUNT - lv->le_count)) {
|
||||
log_error("Unable to extend %s by %u extents, exceeds limit (%u).",
|
||||
lp->lv_name, lv->le_count, MAX_EXTENT_COUNT);
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
lp->extents += lv->le_count;
|
||||
}
|
||||
|
||||
if (lp->sign == SIGN_MINUS) {
|
||||
if (lp->extents >= lv->le_count) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user