dm ioctl: validate name length when renaming

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Tuesday, March 17, 2009 - 10:00 am

Gitweb:     http://git.kernel.org/linus/bc0fd67feba2e0770aad85393500ba77c6489f1c
Commit:     bc0fd67feba2e0770aad85393500ba77c6489f1c
Parent:     5bee17f18b595937e6beafeee5197868a3f74a06
Author:     Milan Broz <mbroz@redhat.com>
AuthorDate: Mon Mar 16 16:56:01 2009 +0000
Committer:  Alasdair G Kergon <agk@redhat.com>
CommitDate: Mon Mar 16 16:56:01 2009 +0000

    dm ioctl: validate name length when renaming
    
    When renaming a mapped device validate the length of the new name.
    
    The rename ioctl accepted any correctly-terminated string enclosed
    within the data passed from userspace.  The other ioctls enforce a
    size limit of DM_NAME_LEN.  If the name is changed and becomes longer
    than that, the device can no longer be addressed by name.
    
    Fix it by properly checking for device name length (including
    terminating zero).
    
    Cc: stable@kernel.org
    Signed-off-by: Milan Broz <mbroz@redhat.com>
    Reviewed-by: Jonathan Brassow <jbrassow@redhat.com>
    Reviewed-by: Alasdair G Kergon <agk@redhat.com>
    Signed-off-by: Alasdair G Kergon <agk@redhat.com>
---
 drivers/md/dm-ioctl.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 54d0588..977f366 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -704,7 +704,8 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size)
 	char *new_name = (char *) param + param->data_start;
 
 	if (new_name < param->data ||
-	    invalid_str(new_name, (void *) param + param_size)) {
+	    invalid_str(new_name, (void *) param + param_size) ||
+	    strlen(new_name) > DM_NAME_LEN - 1) {
 		DMWARN("Invalid new logical volume name supplied.");
 		return -EINVAL;
 	}
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
dm ioctl: validate name length when renaming, Linux Kernel Mailing ..., (Tue Mar 17, 10:00 am)