Linux Device Mapper development
 help / color / mirror / Atom feed
From: Martin Wilck <mwilck@suse.com>
To: dm-devel@redhat.com
Subject: Re: [PATCH 3/5] libmultipath: fix partition detection
Date: Thu, 11 May 2017 15:07:19 +0200	[thread overview]
Message-ID: <1494508039.6093.21.camel@suse.com> (raw)
In-Reply-To: <1493073570-17167-4-git-send-email-bmarzins@redhat.com>

On Mon, 2017-04-24 at 17:39 -0500, Benjamin Marzinski wrote:
> The do_foreach_partmaps code could incorrectly list a device as a
> partition of another device, because of two issues.  First, the check
> to
> compare the dm UUID of two devices would allow two partition devices
> to
> match, or a partition device to match with itself, instead of only
> having a partition device match with the multipath device that it
> belongs to.  Second, the code to check if a multipath device's
> major:minor appeared in a partition device's table only used strstr
> to check of the existance of the major:minor string. This meant that
> any device with a minor number that started with the same digits
> would
> match. for instance, checking for "253:10" would also match
> "253:102".

Good catch! I missed that in my kpartx series although I was trying to
be paranoid ;-)

> -/*
> - * returns:
> - *    0 : if both uuids end with same suffix which starts with
> UUID_PREFIX
> - *    1 : otherwise
> - */
> -int
> -dm_compare_uuid(const char* mapname1, const char* mapname2)
> +static int
> +is_mpath_part(const char *part_name, const char *map_name)
>  {
> -	char *p1, *p2;
> -	char uuid1[WWID_SIZE], uuid2[WWID_SIZE];
> +	char *p;
> +	char part_uuid[WWID_SIZE], map_uuid[WWID_SIZE];
>  
> -	if (dm_get_prefixed_uuid(mapname1, uuid1))
> -		return 1;
> +	if (dm_get_prefixed_uuid(part_name, part_uuid))
> +		return 0;
>  
> -	if (dm_get_prefixed_uuid(mapname2, uuid2))
> -		return 1;
> +	if (dm_get_prefixed_uuid(map_name, map_uuid))
> +		return 0;
>  
> -	p1 = strstr(uuid1, UUID_PREFIX);
> -	p2 = strstr(uuid2, UUID_PREFIX);
> -	if (p1 && p2 && !strcmp(p1, p2))
> +	if (strncmp(part_uuid, "part", 4) != 0)
>  		return 0;
>  
> -	return 1;
> +	p = strstr(part_uuid, UUID_PREFIX);
> +	if (p && !strcmp(p, map_uuid))
> +		return 1;
> +
> +	return 0;
>  }

While we've got this far, we might actually implement proper parsing of
 the UUID instead of "strstr" which would also match something like
"partially_recovered-mpath...".

ACK nonetheless, further checks can be added on top of this.

Martin

-- 
Dr. Martin Wilck <mwilck@suse.com>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

  reply	other threads:[~2017-05-11 13:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-24 22:39 [PATCH 0/5] More misc patches Benjamin Marzinski
2017-04-24 22:39 ` [PATCH 1/5] multipath: Merge the DELL MD3xxx device configs Benjamin Marzinski
2017-04-24 22:39 ` [PATCH 2/5] multipath: fix up position independent code Benjamin Marzinski
2017-05-11 13:12   ` Martin Wilck
2017-04-24 22:39 ` [PATCH 3/5] libmultipath: fix partition detection Benjamin Marzinski
2017-05-11 13:07   ` Martin Wilck [this message]
2017-04-24 22:39 ` [PATCH 4/5] kpartx: default to running in sync mode Benjamin Marzinski
2017-04-25 10:12   ` Steffen Maier
2017-04-25 15:52     ` Benjamin Marzinski
2017-04-25 17:48       ` Steffen Maier
2017-05-10 22:42   ` Xose Vazquez Perez
2017-05-11 12:42   ` Martin Wilck
2017-05-11 17:46     ` Benjamin Marzinski
2017-05-11 20:01       ` Martin Wilck
2017-04-24 22:39 ` [PATCH 5/5] libmultipath: force udev reloads Benjamin Marzinski

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=1494508039.6093.21.camel@suse.com \
    --to=mwilck@suse.com \
    --cc=dm-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox