Commit 61a295e8 authored by Kevin Corry's avatar Kevin Corry Committed by Linus Torvalds

[PATCH] dm: prevent possible buffer overflow in ioctl interface

Use the correct size for "name" in register_with_devfs().

During Al Viro's devfs cleanup a few versions ago, this function was
rewritten, and the "name" string added. The 32-byte size is not large
enough to prevent a possible buffer overflow in the sprintf() call,
since the hash cell can have a name up to 128 characters.
parent 7e2ec88a
......@@ -173,14 +173,18 @@ static void free_cell(struct hash_cell *hc)
*/
static int register_with_devfs(struct hash_cell *hc)
{
char name[32];
struct gendisk *disk = dm_disk(hc->md);
char *name = kmalloc(DM_NAME_LEN + strlen(DM_DIR) + 1);
if (!name) {
return -ENOMEM;
}
sprintf(name, DM_DIR "/%s", hc->name);
devfs_register(NULL, name, DEVFS_FL_CURRENT_OWNER,
disk->major, disk->first_minor,
S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP,
&dm_blk_dops, NULL);
kfree(name);
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment