Skip to content

Commit

Permalink
dm ioctl: Refuse to create device named "." or ".."
Browse files Browse the repository at this point in the history
Using either of these is going to greatly confuse userspace, as they are
not valid symlink names and so creating the usual /dev/mapper/NAME
symlink will not be possible.  As creating a device with either of these
names is almost certainly a userspace bug, just error out.

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 a85f1a9 commit 81ca2db
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/md/dm-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,8 +771,10 @@ static int check_name(const char *name)
return -EINVAL;
}

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

Expand Down

0 comments on commit 81ca2db

Please sign in to comment.