dm ioctl: Refuse to create device named "control"
authorDemi Marie Obenour <demi@invisiblethingslab.com>
Sat, 3 Jun 2023 14:52:43 +0000 (10:52 -0400)
committerMike Snitzer <snitzer@kernel.org>
Fri, 23 Jun 2023 14:31:51 +0000 (10:31 -0400)
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>
drivers/md/dm-ioctl.c

index bfaebc02833a015b14550b357e50a464c94eacf8..e172a91e88dc7383511f4c34f6ce02fe7a99911c 100644 (file)
@@ -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;
        }