Skip to content

Commit

Permalink
dm ioctl: Refuse to create device named "control"
Browse files Browse the repository at this point in the history
Typical userspace setups create a symlink under /dev/mapper with the
name of the device, but /dev/mapper/control is reserved for DM's control
device.  Therefore, trying to create such a device is almost certain to
be a userspace bug.

Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
  • Loading branch information
Demi Marie Obenour authored and Mike Snitzer committed Jun 23, 2023
1 parent 249bed8 commit a85f1a9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/md/dm-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,12 @@ static int get_target_version(struct file *filp, struct dm_ioctl *param, size_t
static int check_name(const char *name)
{
if (strchr(name, '/')) {
DMERR("invalid device name");
DMERR("device name cannot contain '/'");
return -EINVAL;
}

if (strcmp(name, DM_CONTROL_NODE) == 0) {
DMERR("device name cannot be \"%s\"", DM_CONTROL_NODE);
return -EINVAL;
}

Expand Down

0 comments on commit a85f1a9

Please sign in to comment.