All of lore.kernel.org
 help / color / mirror / Atom feed
From: Milan Broz <mbroz@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH] unknown segment types, part 1
Date: Thu, 09 Jul 2009 22:11:22 +0200	[thread overview]
Message-ID: <4A564EEA.10607@redhat.com> (raw)
In-Reply-To: <87k52h8wep.fsf@twilight.int.mornfall.net.>

I tried some fixes...

- flag segment with unknown flag and skip it for activation
(maybe not in correct place, but demonstrates what I mean)

- fix segment name (possible using of deallocated memory, easily
reproduced if e.g. creating new LV on metadat with unknown segments)

(please ignore some crypto stuff - I am playing with in on my git branch :)

Milan

---
 lib/activate/dev_manager.c |   10 ++++++++++
 lib/metadata/segtype.h     |    2 ++
 lib/unknown/unknown.c      |    4 ++--
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 894c20e..225b2a8 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -914,6 +914,16 @@ static int _add_segment_to_dtree(struct dev_manager *dm,
 		return 0;
 	}
 
+	if (seg_unknown(seg_present)) {
+		if (lv_is_visible(seg->lv))
+			log_error("Skipping LV %s containing unknown segment type %s.",
+				  seg->lv->name, seg_present->segtype->name);
+		else
+			log_debug("Skipping LV %s containing unknown segment type %s.",
+				  seg->lv->name, seg_present->segtype->name);
+		return 0;
+	}
+
 	/* Add mirror log */
 	if (seg->log_lv &&
 	    !_add_new_lv_to_dtree(dm, dtree, seg->log_lv, NULL))
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index c743ac3..8787fed 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -34,6 +34,7 @@ struct dev_manager;
 #define SEG_CANNOT_BE_ZEROED	0x00000040U
 #define SEG_MONITORED		0x00000080U
 #define SEG_AREAS_ENCRYPTED	0x00000100U
+#define SEG_UNKNOWN		0x80000000U
 
 #define seg_is_mirrored(seg)	((seg)->segtype->flags & SEG_AREAS_MIRRORED ? 1 : 0)
 #define seg_is_striped(seg)	((seg)->segtype->flags & SEG_AREAS_STRIPED ? 1 : 0)
@@ -44,6 +45,7 @@ struct dev_manager;
 #define seg_monitored(seg)	((seg)->segtype->flags & SEG_MONITORED ? 1 : 0)
 #define seg_is_encrypted(seg)	((seg)->segtype->flags & SEG_AREAS_ENCRYPTED ? 1 : 0)
 #define seg_is_keystore(seg)	(seg_is_encrypted(seg) && seg_cannot_be_zeroed(seg))
+#define seg_unknown(seg)	((seg)->segtype->flags & SEG_UNKNOWN ? 1 : 0)
 
 #define segtype_is_striped(segtype)	((segtype)->flags & SEG_AREAS_STRIPED ? 1 : 0)
 #define segtype_is_mirrored(segtype)	((segtype)->flags & SEG_AREAS_MIRRORED ? 1 : 0)
diff --git a/lib/unknown/unknown.c b/lib/unknown/unknown.c
index 6fa44b4..e2ed807 100644
--- a/lib/unknown/unknown.c
+++ b/lib/unknown/unknown.c
@@ -93,9 +93,9 @@ struct segment_type *init_unknown_segtype(struct cmd_context *cmd, const char *n
 
 	segtype->cmd = cmd;
 	segtype->ops = &_unknown_ops;
-	segtype->name = name;
+	segtype->name = dm_pool_strdup(cmd->mem, name);
 	segtype->private = NULL;
-	segtype->flags = SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED;
+	segtype->flags = SEG_UNKNOWN | SEG_VIRTUAL | SEG_CANNOT_BE_ZEROED;
 
 	log_very_verbose("Initialised segtype: %s", segtype->name);
 




  reply	other threads:[~2009-07-09 20:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-08  9:18 [PATCH] unknown segment types, part 1 Petr Rockai
2009-07-09 17:27 ` Milan Broz
2009-07-09 17:53   ` Milan Broz
2009-07-09 19:50     ` Petr Rockai
2009-07-09 19:54   ` Petr Rockai
2009-07-09 20:11     ` Milan Broz [this message]
2009-07-21 14:41       ` [PATCH, v2] unknown segment types Petr Rockai
2009-09-29 14:42         ` Petr Rockai
2009-10-07 20:03           ` Dave Wysochanski
2009-10-07 20:53           ` [PATCH, v3] " Petr Rockai

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=4A564EEA.10607@redhat.com \
    --to=mbroz@redhat.com \
    --cc=lvm-devel@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.