public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: zkabelac@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2 ./WHATS_NEW lib/metadata/metadata.c lib/m ...
Date: Fri, 04 Nov 2011 22:49:00 -0000	[thread overview]
Message-ID: <20111104224954.4844.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-11-04 22:49:53

Modified files:
	.              : WHATS_NEW 
	lib/metadata   : metadata.c vg.c vg.h 
	tools          : lvresize.c 

Log message:
	Avoid lvextend to overflow
	
	Add extra check to extent_count overflow.
	Use internal define MAX_EXTENT_COUNT instead UINT32_MAX.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2177&r2=1.2178
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.471&r2=1.472
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.h.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.140&r2=1.141

--- LVM2/WHATS_NEW	2011/11/04 01:31:23	1.2177
+++ LVM2/WHATS_NEW	2011/11/04 22:49:53	1.2178
@@ -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.
--- LVM2/lib/metadata/metadata.c	2011/10/28 20:12:55	1.471
+++ LVM2/lib/metadata/metadata.c	2011/11/04 22:49:53	1.472
@@ -276,12 +276,12 @@
 	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 @@
 			  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;
 	}
--- LVM2/lib/metadata/vg.c	2011/08/11 17:24:24	1.12
+++ LVM2/lib/metadata/vg.c	2011/11/04 22:49:53	1.13
@@ -261,7 +261,7 @@
 
 	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;
--- LVM2/lib/metadata/vg.h	2011/08/11 17:24:24	1.15
+++ LVM2/lib/metadata/vg.h	2011/11/04 22:49:53	1.16
@@ -37,6 +37,8 @@
 	struct pvcreate_params *pp;
 };
 
+#define MAX_EXTENT_COUNT  (UINT32_MAX)
+
 struct volume_group {
 	struct cmd_context *cmd;
 	struct dm_pool *vgmem;
--- LVM2/tools/lvresize.c	2011/10/28 20:31:01	1.140
+++ LVM2/tools/lvresize.c	2011/11/04 22:49:53	1.141
@@ -459,8 +459,14 @@
 			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) {


             reply	other threads:[~2011-11-04 22:49 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-04 22:49 zkabelac [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-08-10 20:17 zkabelac
2010-09-23 12:02 prajnoha
2010-07-07  2:53 agk
2010-03-31 17:21 mbroz
2009-03-16 14:35 mbroz
2008-06-23 19:04 wysochanski
2008-04-22 12:54 agk
2007-07-12 15:38 wysochanski
2007-07-12  5:04 wysochanski
2007-07-11 23:33 wysochanski
2007-06-06 19:40 wysochanski
2007-04-25 20:03 wysochanski
2007-02-07 13:29 agk
2005-04-18 14:56 agk
2004-06-19 19:27 agk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111104224954.4844.qmail@sourceware.org \
    --to=zkabelac@sourceware.org \
    --cc=lvm-devel@redhat.com \
    --cc=lvm2-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).