diff mbox

dm ioctl: prevent rename to empty name or uuid

Message ID 20130829153745.GA12181@agk-dp.fab.redhat.com (mailing list archive)
State Awaiting Upstream, archived
Delegated to: Mike Snitzer
Headers show

Commit Message

Alasdair G Kergon Aug. 29, 2013, 3:37 p.m. UTC
Try something like this?

From: Alasdair G Kergon <agk@redhat.com>

A device-mapper device must always have a name consisting of a non-empty
string.  If the device also has a uuid, this similarly must not be an
empty string.

The DM_DEV_CREATE_CMD ioctl enforces these rules when the device is
created, but this patch is needed to enforce them when DM_DEV_RENAME_CMD
is used to change the name or uuid.

Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Cc: Mike Snitzer <snitzer@redhat.com>                                                                                                                                                  
Cc: Mikulas Patocka <mpatocka@redhat.com>   
Reported-by: Zdenek Kabelac <zkabelac@redhat.com>    

---
 drivers/md/dm-ioctl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


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

Comments

Mikulas Patocka Aug. 29, 2013, 5:48 p.m. UTC | #1
Acked-by: Mikulas Patocka <mpatocka@redhat.com>

On Thu, 29 Aug 2013, Alasdair G Kergon wrote:

> Try something like this?
> 
> From: Alasdair G Kergon <agk@redhat.com>
> 
> A device-mapper device must always have a name consisting of a non-empty
> string.  If the device also has a uuid, this similarly must not be an
> empty string.
> 
> The DM_DEV_CREATE_CMD ioctl enforces these rules when the device is
> created, but this patch is needed to enforce them when DM_DEV_RENAME_CMD
> is used to change the name or uuid.
> 
> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
> Cc: Mike Snitzer <snitzer@redhat.com>                                                                                                                                                  
> Cc: Mikulas Patocka <mpatocka@redhat.com>   
> Reported-by: Zdenek Kabelac <zkabelac@redhat.com>    
> 
> ---
>  drivers/md/dm-ioctl.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Index: linux/drivers/md/dm-ioctl.c
> ===================================================================
> --- linux.orig/drivers/md/dm-ioctl.c
> +++ linux/drivers/md/dm-ioctl.c
> @@ -877,7 +877,7 @@ static int dev_rename(struct dm_ioctl *p
>  	unsigned change_uuid = (param->flags & DM_UUID_FLAG) ? 1 : 0;
>  
>  	if (new_data < param->data ||
> -	    invalid_str(new_data, (void *) param + param_size) ||
> +	    invalid_str(new_data, (void *) param + param_size) || !*new_data ||
>  	    strlen(new_data) > (change_uuid ? DM_UUID_LEN - 1 : DM_NAME_LEN - 1)) {
>  		DMWARN("Invalid new mapped device name or uuid string supplied.");
>  		return -EINVAL;
> 

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

Patch

Index: linux/drivers/md/dm-ioctl.c
===================================================================
--- linux.orig/drivers/md/dm-ioctl.c
+++ linux/drivers/md/dm-ioctl.c
@@ -877,7 +877,7 @@  static int dev_rename(struct dm_ioctl *p
 	unsigned change_uuid = (param->flags & DM_UUID_FLAG) ? 1 : 0;
 
 	if (new_data < param->data ||
-	    invalid_str(new_data, (void *) param + param_size) ||
+	    invalid_str(new_data, (void *) param + param_size) || !*new_data ||
 	    strlen(new_data) > (change_uuid ? DM_UUID_LEN - 1 : DM_NAME_LEN - 1)) {
 		DMWARN("Invalid new mapped device name or uuid string supplied.");
 		return -EINVAL;